Skip to content

Commit

Permalink
Create smaller svg files
Browse files Browse the repository at this point in the history
  • Loading branch information
havan committed Dec 7, 2023
1 parent bdd0210 commit 4e5d348
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ jobs:
- uses: actions/checkout@v4
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
- name: Install librsvg2-bin
run: sudo apt-get install -y librsvg2-bin

# Generate diagrams
- name: Generate Diagrams
Expand Down
5 changes: 5 additions & 0 deletions scripts/generate_protodot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ for protofile in `find ${PROTO_DIR} -type f -name '*.proto'`; do

# Create the protodot diagram
${PROTODOT} -generated ${protofile_dir} -src ${protofile} -output $(basename ${protofile})

# Create a scaled version of the diagram
svg_filename="${protofile}.dot.svg"
xs_filename="${protofile}.dot.xs.svg"
rsvg-convert "${svg_filename}" -w 850 -f svg -o "${xs_filename}"
done

# When generating finished, revert the truncated big enums
Expand Down
16 changes: 16 additions & 0 deletions scripts/insert_diagram_link.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Directory to search
directory="proto"

# Process each .proto file found
find "$directory" -type f -name "*.proto" | while read -r proto_file; do
awk '
!inserted && /^enum|^message/ {
gsub(/\/path\/to\/directory\//, "", FILENAME) # Remove the base directory path
print "// ![Click for diagram](https://storage.googleapis.com/docs-cmp-files/diagrams/" FILENAME ".dot.svg)"
inserted=1
}
{ print }
' "$proto_file" > temp_file && mv -v temp_file "$proto_file"
done

0 comments on commit 4e5d348

Please sign in to comment.