Drawing diagrams with PlantUML is fun and easy. We use text to describe the diagram and the we get a graphical representation. Especially in combination with Asciidoctor with PlantUML integration we have a winning combination to write technical documentation. Because our text is transformed into a graphical format like PNG we don’t have much influence on the layout. There are options to indicate positions of elements, but we can also use the length of lines to influence the position of elements.
In this small tutorial we can include a generated PlantUML diagram in typedoc (a way of documenting typescript packages). Note: Graphiz needs to be installed to run this diagram generation.
First install the typedoc plugin:
Now, create a typedoc.json in the root of your project. This file describes how typedoc should generate the documentation.
Next install node-plantuml http://ift.tt/1EOlnfx globally. We should install this globally so we can also use the CLI as a NPM script later.
Go ahead and put the following snippet in your package.json
Finally we are able to create typescript documentation with our generated PNG diagram. If we would include the image in our README as follows:
and run the following command from the command-line:
Our documentation at ./build/docs our index page shows the README with our generated diagram.