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
435 stars 106 forks source link

Support mini grammar's diagrams? #341

Closed sindre-nistad closed 3 years ago

sindre-nistad commented 3 years ago

Hi, Would it be possible to add support for (the python package) Diagrams?

pepijnve commented 3 years ago

Sure. Is something like this what you would expect to be able to write in your document?

[diagrams]
----
from diagrams import Diagram
from diagrams.aws.compute import EC2
from diagrams.aws.database import RDS
from diagrams.aws.network import ELB

with Diagram("Web Service", show=False):
    ELB("lb") >> EC2("web") >> RDS("userdb")
----
pepijnve commented 3 years ago

In other words, you just embed (or reference) the python file you would otherwise write and the extension takes care of invoking python for you.

sindre-nistad commented 3 years ago

Yes

pepijnve commented 3 years ago

Quick update: this is a bit trickier than I had anticipated. Controlling the output destination, which is rather essential for the diagram extension, is tricky with this python package. If the python code is embedded verbatim, then it needs to be parsed to find the Diagram constructor so I can add the filename and outformat parameters. Feasible, but a bit more work than a simple CLI tool integration.

pepijnve commented 3 years ago

A first version of support for Mingrammar Diagrams has been released in 2.1.1