I document most things using Graphviz and repeatedly recreating the image files becomes a PITA not long after you've started. Since I've a makefile lying around from Sphinx and since I'm creating said diagrams for the sphinx documentation, addding a task there would make sense. As with anything involving
make, the syntax is a bit obtuse:
DOT = $(wildcard *.dot) PNG = $(patsubst %.dot,_static/images/%.png,$(DOT)) _static/images/%.png: %.dot @echo "Converting $<" @dot -Tpng $< > $@ dotfiles: $(PNG)
make dotfiles I end up with all .dot files in the current directory as PNGs within
_static/images/. One nice benefit of using Make for this sort of thing is you get it's filee difference handling "for free", so re-running will only process changed or new files.
I've distilled this with a couple of small tweaks from this article On Digital Ocean by Justin Ellingwood, it goes through a bunch of handy syntax pointers.