Skip to content

Commit

Permalink
✅ feat(PlantUML) generate images gh action
Browse files Browse the repository at this point in the history
  • Loading branch information
polesskiy-dev committed Aug 1, 2024
1 parent 21f0eae commit 78ea4e9
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/doxygen-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: doxygen-docs
on:
push:
branches:
[ main ] #TODO remove not main branch
[ main ]

jobs:
gh-pages-doxygen-deploy:
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/plantuml-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Generate and Insert PlantUML SVG

on:
push:
branches:
- main
pull_request:
branches:
[ main ]

jobs:
generate-and-insert:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'adopt-openjdk'
java-version: '11'

- name: Install PlantUML
run: |
mkdir -p ~/.local/bin
wget https://sourceforge.net/projects/plantuml/files/plantuml.jar/download -O ~/.local/bin/plantuml.jar
chmod +x ~/.local/bin/plantuml.jar
- name: Generate SVG and update Markdown files
run: |
# Create directories for diagrams
mkdir -p diagrams
# Process each markdown file
for file in $(find . -name '*.md'); do
# Create a temporary file for updated content
temp_file="updated_$(basename "$file")"
# Read the file line by line
while IFS= read -r line; do
if [[ "$line" =~ ^@startuml ]]; then
# Extract the PlantUML diagram block
diagram=""
while IFS= read -r diagram_line && [[ ! "$diagram_line" =~ ^@enduml ]]; do
diagram+="$diagram_line\n"
done
# Generate the SVG
svg_file="diagrams/$(basename "$file" .md)_diagram.svg"
echo "$diagram" | java -jar ~/.local/bin/plantuml.jar -tsvg -pipe > "$svg_file"
# Insert SVG image link into temporary file
echo "![Diagram]($svg_file)" >> "$temp_file"
echo "" >> "$temp_file" # Add a blank line after the image link
# Add the PlantUML block to the temporary file
echo "$line" >> "$temp_file"
while IFS= read -r diagram_line && [[ ! "$diagram_line" =~ ^@enduml ]]; do
echo "$diagram_line" >> "$temp_file"
done
echo "$diagram_line" >> "$temp_file" # Add the @enduml line
else
# Copy other lines to the temporary file
echo "$line" >> "$temp_file"
fi
done < "$file"
# Move updated file to the original location
mv "$temp_file" "$file"
done
- name: Commit changes
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add .
git commit -m "Add PlantUML diagrams as SVG images in markdown files"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions firmware/iot-risk-logger-stm32l4/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ EXTRACT_PACKAGE = NO
# included in the documentation.
# The default value is: NO.

EXTRACT_STATIC = NO
EXTRACT_STATIC = YES

# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
# locally in source files will be included in the documentation. If set to NO,
Expand Down Expand Up @@ -2615,7 +2615,7 @@ DIAFILE_DIRS =
# a preprocessing step. Doxygen will generate a warning when it encounters a
# \startuml command in this case and will not generate output for the diagram.

PLANTUML_JAR_PATH =
PLANTUML_JAR_PATH = $(PLANTUML_INSTALL_DIR)/plantuml.jar

# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
# configuration file for plantuml.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### State Diagram

```plantuml
@startuml
@startuml{light_sensor_fsm.png}
title Light Sensor FSM
hide empty description
TURNED_OFF: Initialized, turned off\nready for commands, low power mode
Expand All @@ -25,10 +25,5 @@ ERROR --> TURNED_OFF : RECOVER
TURNED_OFF --> ERROR : ERROR
CONTINUOUS_MEASURE --> ERROR : ERROR
OUT_OF_RANGE --> ERROR : ERROR
json rawLux {
"exponent[15:12]":"0b111",
"mantissa[12:0]":"0b111"
}
@enduml
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file light_sensor.h
* @brief Brief description of the file.
*
* Detailed description of the file.
* TODO Detailed description of the file.
*
* @date 28/07/2024
* @author artempolisskyi
Expand Down

0 comments on commit 78ea4e9

Please sign in to comment.