Snippet: Adding Legends to PlantUML Diagrams

The following hack allows us to draw a diagram in a diagram in a table in a legend :D example-diagram.puml @startuml skinparam legendBackgroundColor transparent skinparam legendBorderColor transparent actor Editor as editor queue Queue as "Message\nQueue" editor -> [Component] : call [Component] --> Queue : publish legend right {{ scale 0.7 skinparam defaultFontSize 14 skinparam BackGroundColor transparent skinparam defaultBackgroundColor white !procedure $entry($type, $label, $scale=1) {{\nscale $scale \nskinparam backgroundcolor transparent\nlabel " " as A\nlabel " " as B\n $type \n}} => $label !endprocedure map "<b>Legend</b>" as legend #white { $entry(":Editor:","\nEditor for Data xyz", 0.6) $entry("[Component]","\nSome Component", 0.8) $entry("queue Queue","\nKafka-Topic", 1) $entry("A -> B","Data-Flow") } }} endlegend @enduml ...

October 21, 2022 · 1 min · 128 words · Micha Kops

Generating PlantUML Class Diagrams from a Java Project

As technical documentation for my Java software projects often makes use of technologies like AsciiDoctor and PlantUML, having a tool to analyze existing structures and generating class diagrams from it, is a nice thing. Luckily, the Maven plugin from the Living Documentation Project does all the work for me here. Setup We just need to add the following Maven plugin to our project’s pom.xml: <plugin> <groupId>ch.ifocusit.livingdoc</groupId> <artifactId>livingdoc-maven-plugin</artifactId> <version>1.2</version> <executions> <execution> <id>class-diagram</id> <phase>package</phase> <goals> <goal>diagram</goal> <goal>glossary</goal> </goals> </execution> </executions> <configuration> <packageRoot>com.hascode</packageRoot> <interactive>true</interactive> </configuration> </plugin> ...

January 7, 2022 · 1 min · 117 words · Micha Kops