asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
439 stars 107 forks source link

Add support for Structurizr workspaces #386

Closed pepijnve closed 1 year ago

pepijnve commented 2 years ago

Add a means to add a rendered version of a single view of a Structurizr workspace. This can be implemented by using structurizr-cli to generate PlantUML-C4 and then pass that on to PlantUML.

Possible syntax:

structurizr::<workspace file>[view=<view>]

Block support is easy enough to add as well, but might not make much sense since there wouldn't be a way to share the workspace between multiple blocks easily. Maybe for simple, single view workspaces, but you probably wouldn't be using C4 then.

simonbrowndotje commented 2 years ago

If it helps, here's a very basic (and naive) starting point that I used as a proof of concept for a pre-processor -> https://gist.github.com/simonbrowndotje/4b6c000f42ff1607d8f9c4add3414f1f

pepijnve commented 2 years ago

Thanks @simonbrowndotje. I implemented that portion in the java support code for this extension (see https://github.com/asciidoctor/asciidoctor-diagram-java/blob/master/structurizr/src/main/java/org/asciidoctor/diagram/structurizr/Structurizr.java).

asciidoctor-diagram spins up a little helper daemon for all things Java to avoid the JVM startup cost for each diagram in a document. That's what this is. Needs a bit more tweaking, but it already gives a good idea of where this is heading.

On the Structurizr side of things it would be useful to have a method to get all views from a ViewSet and a way to export any View. I saw that you did this by converting the entire workspace and then finding the correct Diagram. That works too, but seemed a bit wasteful. The extension would end up converting the entire workspace for every single rendered view.

pepijnve commented 1 year ago

A first version of Structurizr DSL support has been added. For now the only support path is via PlantUML-C4. Extending this to support the other exporters (Mermaid, vanilla PlantUML, and GraphViz) should be pretty straightforward.

I wasn't comfortable repacking the set of Structurizr CLI jar files in a gem in the same way that PlantUML and Ditaa are repackaged, so for now people will have to download a Structurizr CLI release and point to it by setting the DIAGRAM_STRUCTURIZRCLI_HOME environment variable.