Skip to content

Commit

Permalink
docs(diagrams): add Makefile to render PlantUML and Graphviz PE-4997
Browse files Browse the repository at this point in the history
We'd like to use PlantUML and in particular C4 to illustrate gateway
architecture so that it's easier for new developers to get up to speed
on it. This adds a Makefile that downloads the PlantUML jar and uses it
to render PlantUML diagrams as PNGs. Also, since I copied this from
another project that had the functionality already and it's generally
useful, it renders Graphviz dot diagrams too.
  • Loading branch information
djwhitt committed Nov 15, 2023
1 parent 18846ca commit 4caf437
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/docker-entrypoint.sh text eol=lf
/envoy/docker-entrypoint.sh text eol=lf
/envoy/install-ytt.sh text eol=lf
**/*.sh text eol=lf
**/*.sh text eol=lf
*.png filter=lfs diff=lfs merge=lfs -text
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Renders PlantUML and Graphviz dot diagrams source files in 'docs/diagrams'

.PHONY: all dot_files puml_files

plantuml_version := 1.2023.12
plantuml_jar := plantuml-$(plantuml_version).jar
plantuml_jar_path := vendor/$(plantuml_jar)

dot_pngs := $(patsubst docs/diagrams/%.dot,docs/diagrams/%.png,$(wildcard docs/diagrams/*.dot))
puml_pngs := $(patsubst docs/diagrams/%.puml,docs/diagrams/%.png,$(wildcard docs/diagrams/*.puml))

all: $(plantuml_jar_path) $(dot_pngs) $(puml_pngs)

# Download PlantUML jar
$(plantuml_jar_path):
mkdir -p vendor
curl -L -o $(plantuml_jar_path) https://github.com/plantuml/plantuml/releases/download/v$(plantuml_version)/$(plantuml_jar)

# Render Graphviz dot files
$(dot_pngs): docs/diagrams/%.png: docs/diagrams/%.dot
dot -Tpng -o $@ $<

# Render PlantUML files
$(puml_pngs): docs/diagrams/%.png: docs/diagrams/%.puml
java -jar $(plantuml_jar_path) -o $(CURDIR)/docs/diagrams -tpng $<

0 comments on commit 4caf437

Please sign in to comment.