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

Call ditaa with command line arguments #69

Closed saschazelzer closed 9 years ago

saschazelzer commented 9 years ago

Hi,

is it possible to specify command line arguments or something equivalent in the asciidoc file when running ditaa? I would like to control effects like box shadows and box separations which is possible via ditaa command line arguments --no-separation and --no-shadows.

Thanks.

pepijnve commented 9 years ago

No that's not yet possible, but shouldn't be too hard to add. I propose adding support for passing ditaa command line arguments as block attributes. For instance:

[ditaa,no-shadows, round-corners]
...
pepijnve commented 9 years ago

Resolved by 887a5771aba1b90ba2fa17c4b7470c0ac298293b I ended up adding support for an options attribute that takes the ditaa command line arguments as value. You can write, for instance,

[ditaa, options="--no-shadows --scale 2.5 --round-corner"]
saschazelzer commented 9 years ago

Awesome, thanks!

However, the image caching mechanism seems to be too aggressive now. Changing the options without changing the ascii image does not regenerate it. Is there some work-around?

pepijnve commented 9 years ago

Thanks for catching that one. The options are indeed not taken into account for the cache validation. Oversight on my part. I'll try to fix that this evening.

pepijnve commented 9 years ago

5149ac682d3517155c9868ddacbf1c5a11d4b46f makes the ditaa processor take the options attribute into account when deciding if the image needs to be regenerated or not.

mojavelinux commented 9 years ago

I'm definitely in support of this approach, but I wonder if we should also have the option of making these customizations globally using document attributes. wdyt? Something like:

:ditaa-options: no-shadows,round-corners

or even

:ditaa-option-no-shadows:
:ditaa-option-round-corners:
pepijnve commented 9 years ago

Sounds like a good idea. My first implementation actually had the options in the form you're using above; without the double-dashes. That looked more asciidoc-like in my eyes than raw command line arguments. I backed away from that approach thinking that it might be easier for users (and less documentation work) if you could just use the command line arguments of the tool in question as is. That idea doesn't work 100% though since only a subset of the options are supported so I probably still have to document this anyway.

If we go ahead with the above syntax then the same syntax should be supported on the blocks themselves imo. So you could either do

:ditaa-options: no-shadows, round-corners, scale=2.5

globally or

[ditaa, options="no-shadows,round-corners,scale=2.5"]

at the block level.

@saschazelzer any preference from your side? Make it look asciidoc-ish or stick with the raw command line options?

mojavelinux commented 9 years ago

I like what you've suggested, esp the document level attribute.

saschazelzer commented 9 years ago

I would definitely use document attributes if they were available. As a consequence, the syntax should be the same at the block level, as you already said. Your example above looks good to me. I am not an expert asciidoc user (yet) though.

pepijnve commented 9 years ago

Reopening for syntax change and document attribute support

pepijnve commented 9 years ago

I ended up implementing the following:

The semantics of the options are

mojavelinux commented 9 years ago

Huge :+1: !

saschazelzer commented 9 years ago

This is great, thanks!