asciidoctor-diagram 2.0.5 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +17 -2
- data/README.adoc +25 -516
- data/Rakefile +1 -1
- data/docs/antora.yml +3 -0
- data/{images → docs/modules/ROOT/images}/asciidoctor-diagram-classes.png +0 -0
- data/docs/modules/ROOT/images/asciidoctor-diagram-process.png +0 -0
- data/docs/modules/ROOT/pages/index.adoc +21 -0
- data/docs/modules/ROOT/partials/advanced.adoc +303 -0
- data/docs/modules/ROOT/partials/create_diagram.adoc +131 -0
- data/docs/modules/ROOT/partials/generate.adoc +15 -0
- data/docs/modules/ROOT/partials/installation.adoc +19 -0
- data/docs/modules/ROOT/partials/uris.adoc +38 -0
- data/examples/features.adoc +1 -1
- data/lib/asciidoctor-diagram/diagram_processor.rb +2 -1
- data/lib/asciidoctor-diagram/ditaa/converter.rb +14 -5
- data/lib/asciidoctor-diagram/ditaa/ditaa-1.3.17.jar +0 -0
- data/lib/asciidoctor-diagram/http/converter.rb +1 -7
- data/lib/asciidoctor-diagram/lilypond/converter.rb +11 -1
- data/lib/asciidoctor-diagram/meme/converter.rb +15 -9
- data/lib/asciidoctor-diagram/mermaid/converter.rb +27 -10
- data/lib/asciidoctor-diagram/pikchr/converter.rb +8 -1
- data/lib/asciidoctor-diagram/plantuml/converter.rb +15 -9
- data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.17.jar +0 -0
- data/lib/asciidoctor-diagram/svgbob/converter.rb +4 -0
- data/lib/asciidoctor-diagram/util/cli.rb +16 -1
- data/lib/asciidoctor-diagram/util/cli_generator.rb +4 -2
- data/lib/asciidoctor-diagram/util/gif.rb +1 -1
- data/lib/asciidoctor-diagram/util/java.rb +5 -3
- data/lib/asciidoctor-diagram/util/java_jruby.rb +4 -1
- data/lib/asciidoctor-diagram/util/java_socket.rb +10 -1
- data/lib/asciidoctor-diagram/util/pdf.rb +1 -1
- data/lib/asciidoctor-diagram/util/png.rb +1 -1
- data/lib/asciidoctor-diagram/util/server-1.3.17.jar +0 -0
- data/lib/asciidoctor-diagram/util/svg.rb +25 -4
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/spec/a2s_spec.rb +3 -3
- data/spec/blockdiag_spec.rb +3 -3
- data/spec/bytefield_spec.rb +3 -3
- data/spec/ditaa_spec.rb +1 -1
- data/spec/dpic_spec.rb +3 -3
- data/spec/erd_spec.rb +5 -5
- data/spec/lilypond_spec.rb +3 -3
- data/spec/mermaid_spec.rb +37 -0
- data/spec/pikchr_spec.rb +21 -3
- data/spec/shaape_spec.rb +3 -3
- data/spec/svgbob_spec.rb +3 -3
- data/spec/syntrax_spec.rb +3 -3
- data/spec/test_helper.rb +3 -7
- data/spec/tikz_spec.rb +3 -3
- metadata +57 -13
- data/README_zh-CN.adoc +0 -336
- data/images/asciidoctor-diagram-process.png +0 -0
- data/lib/batik-all-1.10.jar +0 -0
- data/lib/ditaa-1.3.15.jar +0 -0
- data/lib/ditaamini-0.12.jar +0 -0
- data/lib/jlatexmath-minimal-1.0.5.jar +0 -0
- data/lib/plantuml-1.3.15.jar +0 -0
- data/lib/plantuml.jar +0 -0
- data/lib/server-1.3.15.jar +0 -0
data/Rakefile
CHANGED
data/docs/antora.yml
ADDED
File without changes
|
Binary file
|
@@ -0,0 +1,21 @@
|
|
1
|
+
= Asciidoctor Diagram
|
2
|
+
Pepijn Van_Eeckhoudt <https://github.com/pepijnve[@pepijnve]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>
|
3
|
+
:description: README for the Asciidoctor Diagram extension for Asciidoctor.
|
4
|
+
include::partial$uris.adoc[]
|
5
|
+
|
6
|
+
Asciidoctor Diagram is a set of Asciidoctor extensions that enable you to add diagrams, which you describe using plain text, to your AsciiDoc document.
|
7
|
+
|
8
|
+
The extensions supports the {uri-a2s}[AsciiToSVG], BlockDiag ({uri-blockdiag}[BlockDiag], {uri-seqdiag}[SeqDiag], {uri-actdiag}[ActDiag], {uri-nwdiag}[NwDiag]), {uri-bytefield}[Bytefield-SVG], {uri-ditaa}[Ditaa], {uri-dpic}[dpic], {uri-erd}[Erd], {uri-gnuplot}[Gnuplot], {uri-dot}[GraphViz], {uri-mermaid}[Mermaid], {uri-mscgen}[Msc], {uri-nomnoml}[Nomnoml], {uri-pikchr}[Pikchr], {uri-plantuml}[PlantUML], {uri-shaape}[Shaape], {uri-smcat}[State Machine Cat], {uri-svgbob}[SvgBob], {uri-symbolator}[Symbolator], {uri-syntrax}[Syntrax], {uri-umlet}[UMLet], {uri-vega}[Vega], {uri-vegalite}[Vega-Lite] and {uri-wavedrom}[WaveDrom] syntax.
|
9
|
+
|
10
|
+
Each extension runs the diagram processor to generate an SVG, PNG, or TXT file from the input text.
|
11
|
+
The generated file is then inserted into your converted document.
|
12
|
+
|
13
|
+
Asciidoctor Diagram was inspired by the {uri-py-plantuml}[AsciiDoc PlantUML filter].
|
14
|
+
|
15
|
+
include::partial$installation.adoc[]
|
16
|
+
|
17
|
+
include::partial$create_diagram.adoc[]
|
18
|
+
|
19
|
+
include::partial$generate.adoc[]
|
20
|
+
|
21
|
+
include::partial$advanced.adoc[]
|
@@ -0,0 +1,303 @@
|
|
1
|
+
== Advanced Usage
|
2
|
+
|
3
|
+
=== Enabling Extensions
|
4
|
+
|
5
|
+
In your program, you can either load and register the entire set of diagram extensions
|
6
|
+
|
7
|
+
[source,ruby]
|
8
|
+
----
|
9
|
+
require 'asciidoctor-diagram'
|
10
|
+
----
|
11
|
+
|
12
|
+
or load and register each extension individually.
|
13
|
+
|
14
|
+
[source,ruby]
|
15
|
+
----
|
16
|
+
require 'asciidoctor-diagram/<extension_name>'
|
17
|
+
----
|
18
|
+
|
19
|
+
`<extension_name>` can be one of `a2s`, `blockdiag`, `bytefield`, `ditaa`, `dpic`, `erd`, `gnuplot`, `graphviz`, `meme`, `mermaid`, `msc`, `pikchr`, `plantuml`, `shaape`, `smcat`, `svgbob`, `syntrax`, `umlet`, `vega` or `wavedrom`.
|
20
|
+
|
21
|
+
Requiring one or more of these files will automatically register the extensions for all processed documents.
|
22
|
+
|
23
|
+
If you need more fine grained control over when the extensions are enabled, `asciidoctor-diagram/<extension_name>/extension` can be used instead.
|
24
|
+
This loads the extensions but does not register it in the Asciidoctor extension registry.
|
25
|
+
You can then manually register the extensions at the appropriate times using the `Asciidoctor::Extensions` API.
|
26
|
+
|
27
|
+
This document explains the various features of asciidoctor-diagram blocks using ditaa diagrams as an example.
|
28
|
+
|
29
|
+
=== Diagram Block Macro
|
30
|
+
|
31
|
+
The diagram extensions can also be used in in block macro form.
|
32
|
+
|
33
|
+
.Anatomy of a diagram block macro
|
34
|
+
----
|
35
|
+
block-name::source-file-name[generated-file-extension] // <1> <2> <3>
|
36
|
+
----
|
37
|
+
<1> The macro name is the same as the block name in the block form.
|
38
|
+
<2> The source file name specifies the external file that contains the diagram source code.
|
39
|
+
<3> The first, optional, positional attribute assigns the file extension (i.e. `format`) to the generated diagram.
|
40
|
+
|
41
|
+
When the source file name is a relative path it is resolved with respect to the location of the document being processed.
|
42
|
+
|
43
|
+
=== Image Output Location
|
44
|
+
|
45
|
+
When Asciidoctor Diagram writes images to disk it will go over the following options in order to determine where to write the files.
|
46
|
+
|
47
|
+
. `\{imagesoutdir\}` if the `imagesoutdir` attribute has been specified
|
48
|
+
. `\{outdir\}/\{imagesdir\}` if the `outdir` attribute has been specified
|
49
|
+
. `\{to_dir\}/\{imagesdir\}` if the `to_dir` attribute has been specified
|
50
|
+
. `\{base_dir\}/\{imagesdir\}`
|
51
|
+
|
52
|
+
=== Image Cache Location
|
53
|
+
|
54
|
+
The image generation also outputs metadata files that by default are located in `.asciidoctor/diagram`.
|
55
|
+
To place them in different location, Asciidoctor Diagram checks for (in this order).
|
56
|
+
|
57
|
+
. `\{cachedir\}` attribute is specified in the block header (ie. `[plantuml, png, cachedir=my-cache]`)
|
58
|
+
. `\{diagram-cachedir\}` if the `diagram-cachedir` attribute has been specified
|
59
|
+
. `\{outdir\}/\{imagesdir\}`
|
60
|
+
|
61
|
+
=== Specifying Diagram Generator Paths
|
62
|
+
|
63
|
+
Asciidoctor Diagram depends on external tools to generates images.
|
64
|
+
In most cases it will locate these tools automatically for you by looking for specific executables in each directory in the `PATH` environment variable.
|
65
|
+
In case you've installed a tool in a way where the executable is not in the `PATH`, you can override its location manually using document attributes.
|
66
|
+
The following table lists the tools that are required for each diagram type, the location where they can be downloaded and the document attribute you can use to override their locations.
|
67
|
+
|
68
|
+
[cols=">,2*<",options="header"]
|
69
|
+
|===
|
70
|
+
|Diagram Type |Tool |Attribute
|
71
|
+
|a2s |{uri-a2s}[AsciiToSvg] |`a2s`
|
72
|
+
|actdiag |{uri-actdiag}[ActDiag] |`actdiag`
|
73
|
+
|blockdiag |{uri-blockdiag}[BlockDiag] |`blockdiag`
|
74
|
+
|bpmn |{uri-bpmn}[bpmn-js-cmd] |`bpmn`
|
75
|
+
|bytefield |{uri-bytefield}[bytefield-svg] |`bytefield-svg`
|
76
|
+
|ditaa |{uri-java}[Java] |`java`
|
77
|
+
|dpic |{uri-dpic}[dpic] |`dpic`
|
78
|
+
|erd |{uri-erd}[Erd] |`erd`
|
79
|
+
|gnuplot |{uri-gnuplot}[Gnuplot] |`gnuplot`
|
80
|
+
|graphviz |{uri-graphviz}[GraphViz] |`dot` or `graphvizdot`
|
81
|
+
|meme |{uri-imagemagick}[ImageMagick] |`convert` and `identify`
|
82
|
+
|mermaid |{uri-mermaid}[Mermaid.cli] |`mmdc`
|
83
|
+
|msc |{uri-mscgen}[Mscgen] |`mscgen`
|
84
|
+
|nomnoml |{uri-nomnoml}[Nomnoml] |`nomnoml`
|
85
|
+
|nwdiag |{uri-nwdiag}[NwDiag] |`nwdiag`
|
86
|
+
|packetdiag |{uri-nwdiag}[NwDiag] |`packetdiag`
|
87
|
+
|pikchr |{uri-pikchr}[Pikchr] |`pikchr`
|
88
|
+
|plantuml |{uri-java}[Java] |`java`
|
89
|
+
|rackdiag |{uri-nwdiag}[NwDiag] |`rackdiag`
|
90
|
+
|seqdiag |{uri-seqdiag}[SeqDiag] |`seqdiag`
|
91
|
+
|shaape |{uri-shaape}[Shaape] |`shaape`
|
92
|
+
|smcat |{uri-smcat}[State Machine Cat] |`smcat`
|
93
|
+
|svgbob |{uri-svgbob}[SvgBob] |`svgbob`
|
94
|
+
|symbolator |{uri-symbolator}[Symbolator] |`symbolator`
|
95
|
+
|syntrax |{uri-syntrax}[Syntrax] |`syntrax`
|
96
|
+
|tikz |A TeX distribution that supports {uri-tikz}[TikZ] |`pdflatex` and `pdf2svg`
|
97
|
+
|umlet |{uri-umlet}[Umlet] |`umlet`
|
98
|
+
|vega |{uri-vega}[vg2png] and/or {uri-vega}[vg2png] |`vg2png` and `vg2svg`
|
99
|
+
|vegalite |{uri-vegalite}[vl2vg] and {uri-vega}[vg2png] and/or {uri-vega}[vg2svg]|`vl2vg`, `vg2png` and `vg2svg`
|
100
|
+
.2+|wavedrom |{uri-wavedromeditor}[WaveDrom Editor] |`wavedrom`
|
101
|
+
<|{uri-wavedromcli}[WaveDrom CLI] (and {uri-phantomjs}[PhantomJS] for WaveDrom CLI v1) |`wavedrom` (and `phantomjs`)
|
102
|
+
|===
|
103
|
+
|
104
|
+
If for instance you installed `actdiag` in `/home/me/actdiag/bin` and this path is not included in the `PATH` you can specify its location on the command line
|
105
|
+
|
106
|
+
$ asciidoctor -a actdiag=/home/me/actdiag/bin/actdiag -r asciidoctor-diagram sample.adoc
|
107
|
+
|
108
|
+
[[meme]]
|
109
|
+
=== The Meme Extension
|
110
|
+
|
111
|
+
The meme extension provides a basic '`Advice Animal`' style image generator.
|
112
|
+
It's usage is easiest to explain with an example.
|
113
|
+
|
114
|
+
----
|
115
|
+
meme::yunoguy.jpg[Doc writers,Y U NO // AsciiDoc]
|
116
|
+
----
|
117
|
+
|
118
|
+
The target of the block macro tells the extension which image to use as background.
|
119
|
+
The first two positional attributes are `top` and `bottom` and are used for the top and bottom label.
|
120
|
+
Occurrences of `//` surrounded by whitespace are interpreted as line breaks.
|
121
|
+
|
122
|
+
=== Diagram Attributes
|
123
|
+
|
124
|
+
Certain diagram types allow image generation to be customized using attributes.
|
125
|
+
Each attribute can be specified per individual diagram block or for all blocks of a given diagram type in a document level.
|
126
|
+
This is illustrated for the blockdiag `fontpath` attribute in the example below.
|
127
|
+
|
128
|
+
----
|
129
|
+
= Asciidoctor Diagram
|
130
|
+
:blockdiag-fontpath: /path/to/font.ttf <1>
|
131
|
+
|
132
|
+
[blockdiag] <2>
|
133
|
+
....
|
134
|
+
....
|
135
|
+
|
136
|
+
[blockdiag, fontpath="/path/to/otherfont.ttf"] <3>
|
137
|
+
....
|
138
|
+
....
|
139
|
+
----
|
140
|
+
<1> Attributes can be specified for all diagram of a certain type at the document level by prefixing them with `<blocktype>-`.
|
141
|
+
In this example, the `fontpath` attribute is specified for all diagrams of type `blockdiag`.
|
142
|
+
<2> The first diagram does not specify an explicit value for `fontpath` so the global `blockdiag-fontpath` value will be used
|
143
|
+
<3> The second diagram does specifie a `fontpath` value.
|
144
|
+
This overrides the global `blockdiag-fontpath` value.
|
145
|
+
|
146
|
+
Each attribute can either be specified at the block level or at the document level.
|
147
|
+
The attribute name at the block level should be prefixed with the name of the diagram type and a dash.
|
148
|
+
|
149
|
+
==== Shared Attributes
|
150
|
+
|
151
|
+
[cols=">,<,<",options="header"]
|
152
|
+
|===
|
153
|
+
|Name |Default value |Description
|
154
|
+
|svg-type |unspecified |One of `static`, `inline` or `interactive`. This determines the style of SVG embedding that's used in certain backends. The https://asciidoctor.org/docs/user-manual/#taming-svgs[asciidoctor user guide] describes this in more detail.
|
155
|
+
|===
|
156
|
+
|
157
|
+
==== AsciiToSVG
|
158
|
+
|
159
|
+
[cols=">,<,<",options="header"]
|
160
|
+
|===
|
161
|
+
|Name |Default value |Description
|
162
|
+
|fontfamily |unspecified |The font family to use in the generated SVG image
|
163
|
+
|noblur |unspecified |Disable drop-shadow blurring
|
164
|
+
|===
|
165
|
+
|
166
|
+
==== Blockdiag
|
167
|
+
|
168
|
+
[cols=">,<,<",options="header"]
|
169
|
+
|===
|
170
|
+
|Name |Default value |Description
|
171
|
+
|fontpath |unspecified |The path to the font that should be used by blockdiag
|
172
|
+
|===
|
173
|
+
|
174
|
+
==== BPMN
|
175
|
+
|
176
|
+
[cols=">,<,<",options="header"]
|
177
|
+
|===
|
178
|
+
|Name |Default value |Description
|
179
|
+
|height |786 |The target height of the diagram. Does not apply for output type `svg`.
|
180
|
+
|width |1024 |The target width of the diagram. Does not apply for output type `svg`.
|
181
|
+
|===
|
182
|
+
|
183
|
+
==== Ditaa
|
184
|
+
|
185
|
+
[cols=">,<,<",options="header"]
|
186
|
+
|===
|
187
|
+
|Name |Default value |Description
|
188
|
+
|scale |1 |A scale factor that is applied to the image.
|
189
|
+
|tabs |8 |An integer value that specifies the tab size as a number of spaces.
|
190
|
+
|background |FFFFFF |The background colour of the image. The format should be a six-digit hexadecimal number (as in HTML, FF0000 for red). Pass an eight-digit hex to define transparency.
|
191
|
+
|antialias |true |Enables or disables anti-aliasing.
|
192
|
+
|separation |true |Prevents the separation of common edges of shapes.
|
193
|
+
|round-corners|false |Causes all corners to be rendered as round corners.
|
194
|
+
|shadows |true |Enables or disable drop shadows.
|
195
|
+
|debug |false |Renders the debug grid over the resulting image.
|
196
|
+
|fixed-slope |false |Makes sides of parallelograms and trapezoids fixed slope instead of fixed width.
|
197
|
+
|transparent |false |Makes the background of the image transparent instead of using the background color.
|
198
|
+
|===
|
199
|
+
|
200
|
+
==== Gnuplot
|
201
|
+
|
202
|
+
[cols=">,<,<",options="header"]
|
203
|
+
|===
|
204
|
+
|Name |Default value |Description
|
205
|
+
|background |unspecified |Background color, e.g. `red`, `#FF0000`. Does not work with `txt`.
|
206
|
+
|height |unspecified |The height of the plot. Must be specified together with `width`.
|
207
|
+
|width |unspecified |The width of the plot. Must be specified together with `height`.
|
208
|
+
|crop |unspecified |Trims blank space from the edges of the completed plot (true/false). Does not work with `svg`, `pdf`.
|
209
|
+
|transparent |unspecified |Generate transparent background (true/false). Does not work with `svg`, `pdf`, `txt`.
|
210
|
+
|font |unspecified |The font face with optional font size to use for the text, e.g. `font="Arial"`, `font="Arial,11"`. Does not work with `txt`.
|
211
|
+
|fontscale |unspecified |Scales all label for given factor. Does not work with `txt`.
|
212
|
+
|===
|
213
|
+
|
214
|
+
==== GraphViz
|
215
|
+
|
216
|
+
[cols=">,<,<",options="header"]
|
217
|
+
|===
|
218
|
+
|Name |Default value |Description
|
219
|
+
|layout |unspecified |The graphviz layout engine to use (dot -K option).
|
220
|
+
|===
|
221
|
+
|
222
|
+
==== Meme
|
223
|
+
|
224
|
+
[cols=">,<,<",options="header"]
|
225
|
+
|===
|
226
|
+
|Name |Default value |Description
|
227
|
+
|fill-color |white |The fill color for the text.
|
228
|
+
|stroke-color |black |The outline color for the text
|
229
|
+
|stroke-width |2 |The width of the text outline.
|
230
|
+
|font |Impact |The font face to use for the text.
|
231
|
+
|options |unspecified |a comma separate list of flags that modify the image rendering. Currently only `noupcase` is supported which disable upper casing the labels.
|
232
|
+
|===
|
233
|
+
|
234
|
+
==== Mermaid
|
235
|
+
|
236
|
+
[cols=">,<,<",options="header"]
|
237
|
+
|===
|
238
|
+
|Name |Default value |Description
|
239
|
+
|background |FFFFFF |The background colour of the image. The format should be a six-digit hexadecimal number (as in HTML, FF0000 for red). Pass an eight-digit hex to define transparency.
|
240
|
+
|css |unspecified |Path to a CSS file to pass to mermaid.
|
241
|
+
|config |unspecified |Path to a JSON config file to pass to mermaid.
|
242
|
+
|gantt-config |unspecified |Path to a gantt config file to pass to mermaid.
|
243
|
+
|puppeteer-config|unspecified |Path to a puppeteer config file to pass to mermaid.
|
244
|
+
|sequence-config |unspecified |Path to a sequence config file to pass to mermaid.
|
245
|
+
|theme |unspecified |Theme of the chart, could be default, forest, dark or neutral.
|
246
|
+
|width |unspecified |Width of the page.
|
247
|
+
|height |unspecified |Height of the page.
|
248
|
+
|===
|
249
|
+
|
250
|
+
==== Msc
|
251
|
+
|
252
|
+
[cols=">,<,<",options="header"]
|
253
|
+
|===
|
254
|
+
|Name |Default value |Description
|
255
|
+
|font |unspecified |The name of the font that should be used by mscgen
|
256
|
+
|===
|
257
|
+
|
258
|
+
==== PlantUML
|
259
|
+
|
260
|
+
[cols=">,<,<",options="header"]
|
261
|
+
|===
|
262
|
+
|Name |Default value |Description
|
263
|
+
|config |unspecified |Path to a config file to pass to PlantUML.
|
264
|
+
|===
|
265
|
+
|
266
|
+
==== State Machine Cat
|
267
|
+
|
268
|
+
[cols=">,<,<",options="header"]
|
269
|
+
|===
|
270
|
+
|Name |Default value |Description
|
271
|
+
|direction |unspecifed |The direction of the state machine diagram. One of `top-down`, `bottom-top`, `left-right` or `right-left`.
|
272
|
+
|engine |unspecified |The layout engine to use. One of `dot`, `circo`, `fdp`, `neato`, `osage`, or `twopi`
|
273
|
+
|===
|
274
|
+
|
275
|
+
==== svgbob
|
276
|
+
|
277
|
+
[cols=">,<,<",options="header"]
|
278
|
+
|===
|
279
|
+
|Name |Default value |Description
|
280
|
+
|font-family |arial |text will be rendered with this font
|
281
|
+
|font-size |14 |text will be rendered with this font size
|
282
|
+
|scale |1 |scale the entire svg (dimensions, font size, stroke width) by this factor
|
283
|
+
|stroke-width |2 |stroke width for all lines
|
284
|
+
|===
|
285
|
+
|
286
|
+
==== Syntrax
|
287
|
+
|
288
|
+
[cols=">,<,<",options="header"]
|
289
|
+
|===
|
290
|
+
|Name |Default value |Description
|
291
|
+
|heading |unspecifed |Diagram title
|
292
|
+
|scale |1 |A scale factor that is applied to the image.
|
293
|
+
|style |unspecifed |Path to a style config file to pass to Syntrax.
|
294
|
+
|transparent |false |Makes the background of the image transparent instead of opaque white.
|
295
|
+
|===
|
296
|
+
|
297
|
+
==== TikZ
|
298
|
+
|
299
|
+
[cols=">,<,<",options="header"]
|
300
|
+
|===
|
301
|
+
|Name |Default value |Description
|
302
|
+
|preamble |unspecified |Code definitions to pass to TikZ.
|
303
|
+
|===
|
@@ -0,0 +1,131 @@
|
|
1
|
+
== Creating a Diagram
|
2
|
+
|
3
|
+
A diagram is written inside a literal block, which can accept several attributes.
|
4
|
+
|
5
|
+
.Anatomy of a diagram
|
6
|
+
----
|
7
|
+
[diagram-type, generated-file-name, generated-image-format] // <1> <2> <3>
|
8
|
+
.... // <4>
|
9
|
+
Diagram in appropriate syntax
|
10
|
+
....
|
11
|
+
----
|
12
|
+
<1> The first positional attribute in the attribute list specifies the diagram that is being used.
|
13
|
+
<2> The second, optional positional attribute assigns a file name (i.e. `target`) to the generated diagram. If a target is not specified an auto-generated name will be used.
|
14
|
+
<3> The third, optional positional attribute specifies the image format to create, specified as a three character file extension.
|
15
|
+
<4> Place the attribute list directly on top of the delimited literal block (+....+). You can also use an open block as an alternative (`--`).
|
16
|
+
|
17
|
+
The following diagram types and output formats are available:
|
18
|
+
|
19
|
+
:check: ✓
|
20
|
+
|
21
|
+
[cols=">,5*^",options="header"]
|
22
|
+
|===
|
23
|
+
|Diagram Type |gif |pdf |png |svg |txt
|
24
|
+
|{uri-a2s}[a2s] | | | |{check}|
|
25
|
+
|{uri-actdiag}[actdiag] | |{check}|{check}|{check}|
|
26
|
+
|{uri-blockdiag}[blockdiag] | |{check}|{check}|{check}|
|
27
|
+
|{uri-bpmn}[bpmn] | |{check}|{check}|{check}|
|
28
|
+
|{uri-bytefield}[bytefield] | | | |{check}|
|
29
|
+
|{uri-ditaa}[ditaa] | | |{check}|{check}|
|
30
|
+
|{uri-dpic}[dpic] | | | |{check}|
|
31
|
+
|{uri-erd}[erd] | | |{check}|{check}|
|
32
|
+
|{uri-gnuplot}[gnuplot] |{check}| |{check}|{check}|{check}
|
33
|
+
|{uri-dot}[graphviz] | |{check}|{check}|{check}|
|
34
|
+
|<<meme,meme>> |{check}| |{check}| |
|
35
|
+
|{uri-mermaid}[mermaid] | |{check}|{check}|{check}|
|
36
|
+
|{uri-mscgen}[msc] | | |{check}|{check}|
|
37
|
+
|{uri-nomnoml}[nomnoml] | | | |{check}|
|
38
|
+
|{uri-nwdiag}[nwdiag] | |{check}|{check}|{check}|
|
39
|
+
|{uri-packetdiag}[packetdiag]| |{check}|{check}|{check}|
|
40
|
+
|{uri-pikchr}[pikchr] | | | |{check}|
|
41
|
+
|{uri-plantuml}[plantuml] | | |{check}|{check}|{check}
|
42
|
+
|{uri-rackdiag}[rackdiag] | |{check}|{check}|{check}|
|
43
|
+
|{uri-seqdiag}[seqdiag] | |{check}|{check}|{check}|
|
44
|
+
|{uri-shaape}[shaape] | | |{check}|{check}|
|
45
|
+
|{uri-smcat}[smcat] | | | |{check}|
|
46
|
+
|{uri-svgbob}[svgbob] | | | |{check}|
|
47
|
+
|{uri-symbolator}[symbolator]| |{check}|{check}|{check}|
|
48
|
+
|{uri-syntrax}[syntrax] | |{check}|{check}|{check}|
|
49
|
+
|{uri-tikz}[tikz] | |{check}| |{check}|
|
50
|
+
|{uri-umlet}[umlet] |{check}|{check}|{check}|{check}|
|
51
|
+
|{uri-vega}[vega] | | |{check}|{check}|
|
52
|
+
|{uri-vegalite}[vegalite] | | |{check}|{check}|
|
53
|
+
|{uri-wavedrom}[wavedrom] | | |{check}|{check}|
|
54
|
+
|===
|
55
|
+
|
56
|
+
:!check:
|
57
|
+
|
58
|
+
The example below illustrates the structure of a basic ditaa block written directly in an AsciiDoc document.
|
59
|
+
|
60
|
+
.Basic ditaa block
|
61
|
+
[source]
|
62
|
+
----
|
63
|
+
[ditaa]
|
64
|
+
....
|
65
|
+
+-------------+
|
66
|
+
| Asciidoctor |-------+
|
67
|
+
| diagram | |
|
68
|
+
+-------------+ | PNG out
|
69
|
+
^ |
|
70
|
+
| ditaa in |
|
71
|
+
| v
|
72
|
+
+--------+ +--------+----+ /---------------\
|
73
|
+
| | --+ Asciidoctor +--> | |
|
74
|
+
| Text | +-------------+ | Beautiful |
|
75
|
+
|Document| | !magic! | | Output |
|
76
|
+
| {d}| | | | |
|
77
|
+
+---+----+ +-------------+ \---------------/
|
78
|
+
: ^
|
79
|
+
| Lots of work |
|
80
|
+
+-----------------------------------+
|
81
|
+
....
|
82
|
+
----
|
83
|
+
|
84
|
+
The ditaa block above results in the following generated diagram.
|
85
|
+
|
86
|
+
.Rendered ditaa diagram
|
87
|
+
image::asciidoctor-diagram-process.png[Asciidoctor Diagram process diagram,650,319]
|
88
|
+
|
89
|
+
The rendered ditaa diagram above gets the file name `58372f7d2ceffae9e91fd0a7cbb080b6.png`.
|
90
|
+
That long number is the checksum of the source code calculated by asciidoctor-diagram.
|
91
|
+
If you want to give your generated files a more meaningful name, fill in the `target` attribute.
|
92
|
+
|
93
|
+
This can be done by either specifying it as the second positional attribute or as a named attribute.
|
94
|
+
Both examples below would result in a file called `ditaa-diagram.png`.
|
95
|
+
|
96
|
+
....
|
97
|
+
[ditaa, "ditaa-diagram"]
|
98
|
+
----
|
99
|
+
<snip>
|
100
|
+
----
|
101
|
+
|
102
|
+
[ditaa, target="ditaa-diagram"]
|
103
|
+
----
|
104
|
+
<snip>
|
105
|
+
----
|
106
|
+
....
|
107
|
+
|
108
|
+
|
109
|
+
The example below illustrates the structure of a basic PlantUML block written directly in an AsciiDoc document.
|
110
|
+
|
111
|
+
.PlantUML Diagram Syntax
|
112
|
+
[source]
|
113
|
+
----
|
114
|
+
[plantuml, diagram-classes, png] // <1> <2> <3>
|
115
|
+
....
|
116
|
+
class BlockProcessor
|
117
|
+
class DiagramBlock
|
118
|
+
class DitaaBlock
|
119
|
+
class PlantUmlBlock
|
120
|
+
|
121
|
+
BlockProcessor <|-- DiagramBlock
|
122
|
+
DiagramBlock <|-- DitaaBlock
|
123
|
+
DiagramBlock <|-- PlantUmlBlock
|
124
|
+
....
|
125
|
+
----
|
126
|
+
<1> The diagram is written in PlantUML so the first positional attribute is assigned the `plantuml` diagram type.
|
127
|
+
<2> The name of the generated diagram file (target) is written in the second positional attribute.
|
128
|
+
<3> The output format is entered in the third positional attribute.
|
129
|
+
|
130
|
+
.Rendered PlantUML diagram
|
131
|
+
image::asciidoctor-diagram-classes.png[Asciidoctor Diagram classes diagram]
|