Most programmers would agree that coding is preferable over WYSIWYG editing, no matter it’s a webpage or printed matter. When I write a software document, I usually use LaTeX. But when it comes to the diagrams in that document, especially the UML diagrams, I had to use a WYSIWYG editors such as Microsoft Visio. Finally, I had to make the diagrams in a graphic interface and export the pictures into LaTeX, and that is painful!
Recently I’ve been tried to make UMLs with PlantUML, which converts text codes to image files of UML diagrams. That allows me to integrate the whole building procedure into a makefile, including the compiling of UMLs with PlantUML, and the final document with LaTeX.
The following is an example of a toy document project, where the structure and the makefile are listed.
├ src │ ├ bar.pu # source code of UML bar │ ├ foo.pu # source code of UML foo │ └ main.tex # source code of the document ├ uml │ ├ bar.png # builded UML bar │ └ foo.png # builded UML foo ├ main.pdf # builded document └ makefile
# makefile
pu=$(notdir $(wildcard src/*.pu))
png=$(patsubst %.pu,%.png,$(pu))
main.pdf: src/main.tex
pdflatex src/main.tex
uml/%.png: src/%.pu
plantuml -o uml $^
all: $(addprefix uml/, $(png)) main.pdf
clean:
rm -f *.toc *.aux *.log *.out
view:
open main.pdf
.PHONY: all clean view
The .pu
files are source code of the UML diagrams, which are compiled into .png
pictures. Vector graphic formats like EPS and PDF are also supported. Besides, .dot
files of Graphviz could be used for diagrams other than UML.
Created by Daniel Zhou on 21 Oct 2015, this work is licensed under the
Creative Commons Attribution 4.0 International License
.
近期评论