asciidoctor-diagram 2.2.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +159 -0
- data/README.adoc +17 -13
- data/lib/asciidoctor-diagram/a2s/converter.rb +7 -2
- data/lib/asciidoctor-diagram/barcode/converter.rb +83 -78
- data/lib/asciidoctor-diagram/blockdiag/converter.rb +12 -2
- data/lib/asciidoctor-diagram/bpmn/converter.rb +4 -1
- data/lib/asciidoctor-diagram/bytefield/converter.rb +4 -1
- data/lib/asciidoctor-diagram/d2/converter.rb +57 -0
- data/lib/asciidoctor-diagram/d2/extension.rb +18 -0
- data/lib/asciidoctor-diagram/d2.rb +8 -0
- data/lib/asciidoctor-diagram/dbml/converter.rb +27 -0
- data/lib/asciidoctor-diagram/dbml/extension.rb +18 -0
- data/lib/asciidoctor-diagram/dbml.rb +8 -0
- data/lib/asciidoctor-diagram/diagram_processor.rb +49 -9
- data/lib/asciidoctor-diagram/diagram_source.rb +35 -33
- data/lib/asciidoctor-diagram/diagrams/converter.rb +4 -1
- data/lib/asciidoctor-diagram/ditaa/converter.rb +15 -7
- data/lib/asciidoctor-diagram/ditaa/ditaa-2.2.0.jar +0 -0
- data/lib/asciidoctor-diagram/dpic/converter.rb +4 -1
- data/lib/asciidoctor-diagram/erd/converter.rb +5 -2
- data/lib/asciidoctor-diagram/gnuplot/converter.rb +7 -1
- data/lib/asciidoctor-diagram/graphviz/converter.rb +4 -1
- data/lib/asciidoctor-diagram/graphviz_py/converter.rb +4 -1
- data/lib/asciidoctor-diagram/http/converter.rb +16 -7
- data/lib/asciidoctor-diagram/http/server.rb +2 -2
- data/lib/asciidoctor-diagram/lilypond/converter.rb +3 -2
- data/lib/asciidoctor-diagram/meme/converter.rb +29 -3
- data/lib/asciidoctor-diagram/mermaid/converter.rb +4 -2
- data/lib/asciidoctor-diagram/msc/converter.rb +6 -2
- data/lib/asciidoctor-diagram/nomnoml/converter.rb +4 -1
- data/lib/asciidoctor-diagram/penrose/converter.rb +53 -0
- data/lib/asciidoctor-diagram/penrose/extension.rb +18 -0
- data/lib/asciidoctor-diagram/penrose.rb +8 -0
- data/lib/asciidoctor-diagram/pikchr/converter.rb +4 -1
- data/lib/asciidoctor-diagram/pintora/converter.rb +60 -0
- data/lib/asciidoctor-diagram/pintora/extension.rb +18 -0
- data/lib/asciidoctor-diagram/pintora.rb +8 -0
- data/lib/asciidoctor-diagram/plantuml/converter.rb +256 -43
- data/lib/asciidoctor-diagram/plantuml/plantuml-2.2.4.jar +0 -0
- data/lib/asciidoctor-diagram/shaape/converter.rb +4 -1
- data/lib/asciidoctor-diagram/smcat/converter.rb +5 -1
- data/lib/asciidoctor-diagram/structurizr/converter.rb +69 -0
- data/lib/asciidoctor-diagram/structurizr/extension.rb +52 -0
- data/lib/asciidoctor-diagram/structurizr/renderers.rb +63 -0
- data/lib/asciidoctor-diagram/structurizr/structurizr-2.2.2.jar +0 -0
- data/lib/asciidoctor-diagram/structurizr.rb +7 -0
- data/lib/asciidoctor-diagram/svgbob/converter.rb +6 -2
- data/lib/asciidoctor-diagram/symbolator/converter.rb +4 -1
- data/lib/asciidoctor-diagram/syntrax/converter.rb +72 -17
- data/lib/asciidoctor-diagram/syntrax/syntrax-2.2.0.jar +0 -0
- data/lib/asciidoctor-diagram/tikz/converter.rb +5 -2
- data/lib/asciidoctor-diagram/umlet/converter.rb +4 -1
- data/lib/asciidoctor-diagram/util/base64.rb +25 -0
- data/lib/asciidoctor-diagram/util/cli.rb +11 -3
- data/lib/asciidoctor-diagram/util/cli_generator.rb +1 -0
- data/lib/asciidoctor-diagram/util/java.rb +15 -7
- data/lib/asciidoctor-diagram/util/java_jruby.rb +14 -0
- data/lib/asciidoctor-diagram/util/java_socket.rb +4 -0
- data/lib/asciidoctor-diagram/util/server-2.2.3.jar +0 -0
- data/lib/asciidoctor-diagram/util/svg.rb +5 -3
- data/lib/asciidoctor-diagram/vega/converter.rb +5 -3
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/lib/asciidoctor-diagram/wavedrom/converter.rb +38 -24
- data/lib/asciidoctor-diagram.rb +5 -0
- metadata +32 -115
- data/Rakefile +0 -9
- data/docs/antora.yml +0 -3
- data/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 +0 -21
- data/docs/modules/ROOT/partials/advanced.adoc +0 -365
- data/docs/modules/ROOT/partials/create_diagram.adoc +0 -134
- data/docs/modules/ROOT/partials/generate.adoc +0 -15
- data/docs/modules/ROOT/partials/installation.adoc +0 -19
- data/docs/modules/ROOT/partials/uris.adoc +0 -41
- data/examples/Gemfile +0 -3
- data/examples/README.adoc +0 -18
- data/examples/design.adoc +0 -78
- data/examples/features.adoc +0 -189
- data/lib/asciidoctor-diagram/ditaa/ditaa-1.3.21.jar +0 -0
- data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.21.jar +0 -0
- data/lib/asciidoctor-diagram/util/server-1.3.21.jar +0 -0
- data/spec/a2s_spec.rb +0 -33
- data/spec/barcode_spec.rb +0 -176
- data/spec/blockdiag_spec.rb +0 -20
- data/spec/bpmn_spec.rb +0 -60
- data/spec/bytefield_spec.rb +0 -96
- data/spec/diagrams_spec.rb +0 -27
- data/spec/ditaa_spec.rb +0 -191
- data/spec/dpic_spec.rb +0 -23
- data/spec/erd_spec.rb +0 -96
- data/spec/gnuplot_spec.rb +0 -229
- data/spec/graphviz_py_spec.rb +0 -33
- data/spec/graphviz_spec.rb +0 -24
- data/spec/lilypond_spec.rb +0 -17
- data/spec/man.jpg +0 -0
- data/spec/meme_spec.rb +0 -67
- data/spec/mermaid_spec.rb +0 -198
- data/spec/msc_spec.rb +0 -37
- data/spec/nomnoml_spec.rb +0 -36
- data/spec/pikchr_spec.rb +0 -73
- data/spec/plantuml_spec.rb +0 -772
- data/spec/shaape_spec.rb +0 -20
- data/spec/shared_examples.rb +0 -764
- data/spec/smcat_spec.rb +0 -30
- data/spec/svgbob_spec.rb +0 -33
- data/spec/symbolator_spec.rb +0 -27
- data/spec/syntrax_spec.rb +0 -22
- data/spec/test_helper.rb +0 -113
- data/spec/tikz_spec.rb +0 -181
- data/spec/umlet_spec.rb +0 -32
- data/spec/vega_spec.rb +0 -133
- data/spec/wavedrom_spec.rb +0 -21
@@ -1,134 +0,0 @@
|
|
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, target=output-file-name, format=output-format] // <1> <2> <3>
|
8
|
-
.... // <4>
|
9
|
-
Diagram in appropriate syntax
|
10
|
-
....
|
11
|
-
----
|
12
|
-
<1> The first value in the attribute list specifies the diagram syntax that is being used.
|
13
|
-
<2> The `target` attribute specifies the basename of the image file that will be generated. If this attribute is omitted an auto-generated name will be used instead.
|
14
|
-
<3> The `format` attribute determines the output image format to use. If a format is not specified, the default output format for the chosen diagram type will be used.
|
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
|
-
|<<barcode,barcode>> | | |{check}| |{check}
|
27
|
-
|{uri-blockdiag}[blockdiag] | |{check}|{check}|{check}|
|
28
|
-
|{uri-bpmn}[bpmn] | |{check}|{check}|{check}|
|
29
|
-
|{uri-bytefield}[bytefield] | | | |{check}|
|
30
|
-
|{uri-diagrams}[diagrams] | |{check}|{check}|{check}|
|
31
|
-
|{uri-ditaa}[ditaa] | | |{check}|{check}|
|
32
|
-
|{uri-dpic}[dpic] | | | |{check}|
|
33
|
-
|{uri-erd}[erd] | | |{check}|{check}|
|
34
|
-
|{uri-gnuplot}[gnuplot] |{check}| |{check}|{check}|{check}
|
35
|
-
|{uri-dot}[graphviz] | |{check}|{check}|{check}|
|
36
|
-
|<<meme,meme>> |{check}| |{check}| |
|
37
|
-
|{uri-mermaid}[mermaid] | |{check}|{check}|{check}|
|
38
|
-
|{uri-mscgen}[msc] | | |{check}|{check}|
|
39
|
-
|{uri-nomnoml}[nomnoml] | | | |{check}|
|
40
|
-
|{uri-nwdiag}[nwdiag] | |{check}|{check}|{check}|
|
41
|
-
|{uri-packetdiag}[packetdiag] | |{check}|{check}|{check}|
|
42
|
-
|{uri-pikchr}[pikchr] | | | |{check}|
|
43
|
-
|{uri-plantuml}[plantuml] | | |{check}|{check}|{check}
|
44
|
-
|{uri-rackdiag}[rackdiag] | |{check}|{check}|{check}|
|
45
|
-
|{uri-seqdiag}[seqdiag] | |{check}|{check}|{check}|
|
46
|
-
|{uri-shaape}[shaape] | | |{check}|{check}|
|
47
|
-
|{uri-smcat}[smcat] | | | |{check}|
|
48
|
-
|{uri-svgbob}[svgbob] | | | |{check}|
|
49
|
-
|{uri-symbolator}[symbolator] | |{check}|{check}|{check}|
|
50
|
-
|{uri-syntrax}[syntrax] (Syntrax) | |{check}|{check}|{check}|
|
51
|
-
|{uri-jsyntrax}[syntrax] (JSyntrax)| | |{check}|{check}|
|
52
|
-
|{uri-tikz}[tikz] | |{check}| |{check}|
|
53
|
-
|{uri-umlet}[umlet] |{check}|{check}|{check}|{check}|
|
54
|
-
|{uri-vega}[vega] | | |{check}|{check}|
|
55
|
-
|{uri-vegalite}[vegalite] | | |{check}|{check}|
|
56
|
-
|{uri-wavedrom}[wavedrom] | | |{check}|{check}|
|
57
|
-
|===
|
58
|
-
|
59
|
-
:!check:
|
60
|
-
|
61
|
-
The example below illustrates the structure of a basic ditaa block written directly in an AsciiDoc document.
|
62
|
-
|
63
|
-
.Basic ditaa block
|
64
|
-
[source]
|
65
|
-
----
|
66
|
-
[ditaa]
|
67
|
-
....
|
68
|
-
+-------------+
|
69
|
-
| Asciidoctor |-------+
|
70
|
-
| diagram | |
|
71
|
-
+-------------+ | PNG out
|
72
|
-
^ |
|
73
|
-
| ditaa in |
|
74
|
-
| v
|
75
|
-
+--------+ +--------+----+ /---------------\
|
76
|
-
| | --+ Asciidoctor +--> | |
|
77
|
-
| Text | +-------------+ | Beautiful |
|
78
|
-
|Document| | !magic! | | Output |
|
79
|
-
| {d}| | | | |
|
80
|
-
+---+----+ +-------------+ \---------------/
|
81
|
-
: ^
|
82
|
-
| Lots of work |
|
83
|
-
+-----------------------------------+
|
84
|
-
....
|
85
|
-
----
|
86
|
-
|
87
|
-
The ditaa block above results in the following diagram.
|
88
|
-
|
89
|
-
.Rendered ditaa diagram
|
90
|
-
image::asciidoctor-diagram-process.png[Asciidoctor Diagram process diagram,650,319]
|
91
|
-
|
92
|
-
The rendered ditaa diagram above gets the file name `58372f7d2ceffae9e91fd0a7cbb080b6.png`.
|
93
|
-
That long number is the checksum of the source code calculated by asciidoctor-diagram.
|
94
|
-
If you want to give your image files a more meaningful name, fill in the `target` attribute.
|
95
|
-
|
96
|
-
This can be done by either specifying it as the second positional attribute or as a named attribute.
|
97
|
-
Both examples below would result in a file called `ditaa-diagram.png`.
|
98
|
-
|
99
|
-
....
|
100
|
-
[ditaa, target="ditaa-diagram"]
|
101
|
-
----
|
102
|
-
<snip>
|
103
|
-
----
|
104
|
-
|
105
|
-
[ditaa, "ditaa-diagram"]
|
106
|
-
----
|
107
|
-
<snip>
|
108
|
-
----
|
109
|
-
....
|
110
|
-
|
111
|
-
|
112
|
-
The example below illustrates the structure of a basic PlantUML block written directly in an AsciiDoc document.
|
113
|
-
|
114
|
-
.PlantUML Diagram Syntax
|
115
|
-
[source]
|
116
|
-
----
|
117
|
-
[plantuml, target=diagram-classes, format=png] // <1> <2> <3>
|
118
|
-
....
|
119
|
-
class BlockProcessor
|
120
|
-
class DiagramBlock
|
121
|
-
class DitaaBlock
|
122
|
-
class PlantUmlBlock
|
123
|
-
|
124
|
-
BlockProcessor <|-- DiagramBlock
|
125
|
-
DiagramBlock <|-- DitaaBlock
|
126
|
-
DiagramBlock <|-- PlantUmlBlock
|
127
|
-
....
|
128
|
-
----
|
129
|
-
<1> The diagram is written in PlantUML so the first positional attribute is assigned the `plantuml` diagram type.
|
130
|
-
<2> The name of the diagram file is given by the `target` attribute.
|
131
|
-
<3> The output format is specified using the `format` attribute
|
132
|
-
|
133
|
-
.Rendered PlantUML diagram
|
134
|
-
image::asciidoctor-diagram-classes.png[Asciidoctor Diagram classes diagram]
|
@@ -1,15 +0,0 @@
|
|
1
|
-
== Generating a Diagram from a Terminal
|
2
|
-
|
3
|
-
You can load Asciidoctor diagram in a terminal using the `-r` flag.
|
4
|
-
|
5
|
-
$ asciidoctor -r asciidoctor-diagram sample.adoc
|
6
|
-
|
7
|
-
You can also use Asciidoctor diagram with other converters, such as Asciidoctor EPUB.
|
8
|
-
Asciidoctor-epub3 is also loaded with the `-r` flag.
|
9
|
-
|
10
|
-
$ asciidoctor -r asciidoctor-diagram -r asciidoctor-epub3 -b epub3 sample.adoc
|
11
|
-
|
12
|
-
Or, you can invoke Asciidoctor and the EPUB converter with the `asciidoctor-epub3` command.
|
13
|
-
The command implicitly sets the `-r` and `-b` flags for EPUB3 output.
|
14
|
-
|
15
|
-
$ asciidoctor-epub3 -r asciidoctor-diagram sample.adoc
|
@@ -1,19 +0,0 @@
|
|
1
|
-
== Installation
|
2
|
-
|
3
|
-
Asciidoctor Diagram is a RubyGem, which can be installed using the `gem` or `bundle` commands.
|
4
|
-
|
5
|
-
You can install the Asciidoctor Diagram gem by typing `gem install` in the CLI.
|
6
|
-
|
7
|
-
$ gem install asciidoctor-diagram
|
8
|
-
|
9
|
-
by first adding the following entry to your project's [.path]_Gemfile_.
|
10
|
-
|
11
|
-
.Gemfile
|
12
|
-
[source,ruby]
|
13
|
-
----
|
14
|
-
gem 'asciidoctor-diagram'
|
15
|
-
----
|
16
|
-
|
17
|
-
Then execute `bundle` in the CLI.
|
18
|
-
|
19
|
-
$ bundle
|
@@ -1,41 +0,0 @@
|
|
1
|
-
:uri-a2s: https://github.com/asciitosvg/asciitosvg
|
2
|
-
:uri-actdiag: http://blockdiag.com/en/actdiag/index.html
|
3
|
-
:uri-asciidoctor-api: http://asciidoctor.org/docs/user-manual/#api
|
4
|
-
:uri-asciidoctor-extensions: http://asciidoctor.org/docs/user-manual/#extension-points
|
5
|
-
:uri-blockdiag: http://blockdiag.com
|
6
|
-
:uri-bpmn: https://github.com/gtudan/bpmn-js-cmd
|
7
|
-
:uri-bytefield: https://github.com/Deep-Symmetry/bytefield-svg
|
8
|
-
:uri-diagrams: https://diagrams.mingrammer.com
|
9
|
-
:uri-ditaa: http://ditaa.sourceforge.net/
|
10
|
-
:uri-dpic: https://gitlab.com/aplevich/dpic
|
11
|
-
:uri-dot: https://graphviz.gitlab.io/_pages/doc/info/lang.html
|
12
|
-
:uri-erd: https://github.com/BurntSushi/erd
|
13
|
-
:uri-gnuplot: http://gnuplot.info
|
14
|
-
:uri-graphviz: https://graphviz.gitlab.io
|
15
|
-
:uri-imagemagick: http://www.imagemagick.org
|
16
|
-
:uri-java: http://java.sun.com
|
17
|
-
:uri-mermaid: https://github.com/mermaid-js/mermaid-cli
|
18
|
-
:uri-mscgen: http://www.mcternan.me.uk/mscgen/
|
19
|
-
:uri-nomnoml: http://nomnoml.com
|
20
|
-
:uri-nwdiag: http://blockdiag.com/en/nwdiag/index.html
|
21
|
-
:uri-packetdiag: http://blockdiag.com/en/nwdiag/index.html
|
22
|
-
:uri-phantomjs: http://phantomjs.org
|
23
|
-
:uri-pikchr: https://pikchr.org
|
24
|
-
:uri-plantuml: http://plantuml.sourceforge.net
|
25
|
-
:uri-py-plantuml: https://code.google.com/p/asciidoc-plantuml/
|
26
|
-
:uri-python: https://www.python.org
|
27
|
-
:uri-rackdiag: http://blockdiag.com/en/nwdiag/index.html
|
28
|
-
:uri-seqdiag: http://blockdiag.com/en/seqdiag/index.html
|
29
|
-
:uri-shaape: https://github.com/christiangoltz/shaape
|
30
|
-
:uri-smcat: https://github.com/sverweij/state-machine-cat
|
31
|
-
:uri-svgbob: https://github.com/ivanceras/svgbobrus
|
32
|
-
:uri-symbolator: https://github.com/kevinpt/symbolator
|
33
|
-
:uri-syntrax: https://kevinpt.github.io/syntrax/
|
34
|
-
:uri-jsyntrax: https://atp-mipt.github.io/jsyntrax/
|
35
|
-
:uri-tikz: https://github.com/pgf-tikz/pgf
|
36
|
-
:uri-umlet: http://www.umlet.com/
|
37
|
-
:uri-vega: https://vega.github.io/vega/
|
38
|
-
:uri-vegalite: https://vega.github.io/vega-lite/
|
39
|
-
:uri-wavedrom: http://wavedrom.com
|
40
|
-
:uri-wavedromeditor: https://github.com/wavedrom/wavedrom.github.io/releases
|
41
|
-
:uri-wavedromcli: https://github.com/wavedrom/cli
|
data/examples/Gemfile
DELETED
data/examples/README.adoc
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
= Asciidoctor-diagram Examples
|
2
|
-
|
3
|
-
This directory contains a number of example files that illustrate how to use the asciidoctor-diagram extension.
|
4
|
-
|
5
|
-
In order to build the examples correctly the asciidoctor-diagram extension should be loaded.
|
6
|
-
This can be done using bundler by running
|
7
|
-
|
8
|
-
----
|
9
|
-
bundle exec asciidoctor -r asciidoctor-diagram <asciidoc file>
|
10
|
-
----
|
11
|
-
|
12
|
-
If you do not want to use bundler you can alternatively run
|
13
|
-
|
14
|
-
----
|
15
|
-
asciidoctor -r asciidoctor-diagram -I ../lib <asciidoc file>
|
16
|
-
----
|
17
|
-
|
18
|
-
This variant requires you to explicitly specify the load path from which asciidoctor-diagram can be loaded.
|
data/examples/design.adoc
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
= The design of Asciidoctor-diagram
|
2
|
-
|
3
|
-
This document explains the design of Asciidoctor-diagram using PlantUML syntax.
|
4
|
-
A detailed explanation of the PlantUML syntax is out scope for this document.
|
5
|
-
This can be found on the http://www.plantuml.com[PlantUML web site].
|
6
|
-
|
7
|
-
Asciidoctor-diagram is a simple Asciidoctor extension that enables embedding of diagrams inside asciidoc documents using various plain text diagram syntaxes.
|
8
|
-
The current version of Asciidoctor-diagram support the Ditaa, Graphviz DOT and PlantUML syntax.
|
9
|
-
|
10
|
-
Asciidoctor-diagram enables a number of new block types using the Asciidoctor `BlockProcessor` extension API.
|
11
|
-
|
12
|
-
The main logic of the diagram generation is provided by the `DiagramBlock` module.
|
13
|
-
This includes the shared options for the various blocks, checksum calculation of the diagram source code, cache validation and attribute generation for the generated output blocks.
|
14
|
-
The DiagramBlock module also provides a means to register diagram output formats.
|
15
|
-
|
16
|
-
When registering an output format, the registering code must specify a number of control parameters.
|
17
|
-
The first parameter is the format name which controls when the generator is activated.
|
18
|
-
The generator that is registered first determines the default format for the block.
|
19
|
-
The second parameter is the output type of the generator.
|
20
|
-
This is either `:image` or `:literal`.
|
21
|
-
This parameter controls what type of block the `DiagramBlock` code will generate.
|
22
|
-
Finally, a block should be provided that generates the diagram and returns it as a String.
|
23
|
-
When called these blocks will receive the diagram source code and the parent Block as arguments.
|
24
|
-
|
25
|
-
The actual `BlockProcessor` implementations include the `DiagramBlock` module and the appropriate generator module.
|
26
|
-
The remainder of the implementation consists of registering format.
|
27
|
-
|
28
|
-
The diagram below illustrates the relationship between the various classes and modules.
|
29
|
-
|
30
|
-
.Asciidoctor-diagram class diagram
|
31
|
-
[plantuml, "classes", align="center"]
|
32
|
-
----
|
33
|
-
namespace asciidoctor.extensions {
|
34
|
-
class BlockProcessor
|
35
|
-
}
|
36
|
-
|
37
|
-
namespace asciidoctor.diagram {
|
38
|
-
asciidoctor.extensions.BlockProcessor <|-- DitaaBlock
|
39
|
-
class DitaaGenerator << (M,#FF7700) >>
|
40
|
-
|
41
|
-
asciidoctor.extensions.BlockProcessor <|-- GraphvizBlock
|
42
|
-
asciidoctor.extensions.BlockProcessor <|-- PlantUmlBlock
|
43
|
-
class PlantUmlGenerator << (M,#FF7700) >>
|
44
|
-
|
45
|
-
class DiagramBlock << (M,#FF7700) >>
|
46
|
-
|
47
|
-
DitaaBlock --|> DitaaGenerator
|
48
|
-
DitaaBlock --|> DiagramBlock
|
49
|
-
GraphvizBlock --|> PlantUmlGenerator
|
50
|
-
GraphvizBlock --|> DiagramBlock
|
51
|
-
PlantUmlBlock --|> PlantUmlGenerator
|
52
|
-
PlantUmlBlock --|> DiagramBlock
|
53
|
-
}
|
54
|
-
----
|
55
|
-
|
56
|
-
When Asciidoctor process a document it will invoke the block processors at the appropriate moment.
|
57
|
-
The sequence of method calls for a Ditaa block is shown below.
|
58
|
-
|
59
|
-
.Processing a Ditaa block
|
60
|
-
[plantuml, "processing", align="center"]
|
61
|
-
----
|
62
|
-
Lexer->DiagramBlock : process
|
63
|
-
activate DiagramBlock #FFBBBB
|
64
|
-
|
65
|
-
DiagramBlock -> DiagramBlock: create_image_block
|
66
|
-
activate DiagramBlock #DarkSalmon
|
67
|
-
|
68
|
-
DiagramBlock -> DiagramBlock: code_checksum
|
69
|
-
|
70
|
-
DiagramBlock -> DitaaGenerator: ditaa
|
71
|
-
activate DitaaGenerator
|
72
|
-
DiagramBlock <-- DitaaGenerator: image as String
|
73
|
-
deactivate DitaaGenerator
|
74
|
-
deactivate DiagramBlock
|
75
|
-
|
76
|
-
Lexer <-- DiagramBlock: generated Block
|
77
|
-
deactivate DiagramBlock
|
78
|
-
----
|
data/examples/features.adoc
DELETED
@@ -1,189 +0,0 @@
|
|
1
|
-
= Asciidoctor-diagram features
|
2
|
-
|
3
|
-
This document explains the various features of asciidoctor-diagram blocks using ditaa diagrams as an example.
|
4
|
-
|
5
|
-
== Simple diagrams
|
6
|
-
|
7
|
-
To mark a block as a diagram the appropriate style should be applied. This can be either `ditaa`, `graphviz` or `plantuml`.
|
8
|
-
These styles can be applied to literal, listing or open blocks.
|
9
|
-
|
10
|
-
A basic ditaa listing can be written as follows:
|
11
|
-
|
12
|
-
---------
|
13
|
-
[ditaa]
|
14
|
-
----
|
15
|
-
+-------------+
|
16
|
-
| asciidoctor |-------+
|
17
|
-
| diagram | |
|
18
|
-
+-------------+ | png out
|
19
|
-
^ |
|
20
|
-
| ditaa in |
|
21
|
-
| v
|
22
|
-
+--------+ +--------+----+ /---------------\
|
23
|
-
| | --+ asciidoctor +--> | |
|
24
|
-
| Text | +-------------+ |Beatiful output|
|
25
|
-
|Document| | !magic! | | |
|
26
|
-
| {d}| | | | |
|
27
|
-
+---+----+ +-------------+ \---------------/
|
28
|
-
: ^
|
29
|
-
| Lots of work |
|
30
|
-
+-----------------------------------+
|
31
|
-
----
|
32
|
-
---------
|
33
|
-
|
34
|
-
results in the following image.
|
35
|
-
|
36
|
-
[ditaa]
|
37
|
-
----
|
38
|
-
+-------------+
|
39
|
-
| asciidoctor |-------+
|
40
|
-
| diagram | |
|
41
|
-
+-------------+ | png out
|
42
|
-
^ |
|
43
|
-
| ditaa in |
|
44
|
-
| v
|
45
|
-
+--------+ +--------+----+ /---------------\
|
46
|
-
| | --+ asciidoctor +--> | |
|
47
|
-
| Text | +-------------+ |Beatiful output|
|
48
|
-
|Document| | !magic! | | |
|
49
|
-
| {d}| | | | |
|
50
|
-
+---+----+ +-------------+ \---------------/
|
51
|
-
: ^
|
52
|
-
| Lots of work |
|
53
|
-
+-----------------------------------+
|
54
|
-
----
|
55
|
-
|
56
|
-
== Controlling the file name
|
57
|
-
|
58
|
-
The image above gets the file name `58372f7d2ceffae9e91fd0a7cbb080b6.png`.
|
59
|
-
That long number is the checksum of the source code that was calculated by asciidoctor-diagram.
|
60
|
-
If you want to give your generated files a more meaningful name, simply fill in the `target` attribute.
|
61
|
-
|
62
|
-
This can be done by either specifying it as the first positional attribute or as a named attribute.
|
63
|
-
Both examples below would result in a file called `ditaa-diagram.png`.
|
64
|
-
|
65
|
-
---------
|
66
|
-
[ditaa, "ditaa-diagram"]
|
67
|
-
----
|
68
|
-
<snip>
|
69
|
-
----
|
70
|
-
|
71
|
-
[ditaa, target="ditaa-diagram"]
|
72
|
-
----
|
73
|
-
<snip>
|
74
|
-
----
|
75
|
-
---------
|
76
|
-
|
77
|
-
== Choosing an output format
|
78
|
-
|
79
|
-
By default images are generated in `PNG` format.
|
80
|
-
This can be overridden by defining the `format` (or 2nd positional) attribute.
|
81
|
-
The set of supported formats is diagram type dependent.
|
82
|
-
`ditaa` only supports the `png` format.
|
83
|
-
`graphviz` supports `png` and `svg`.
|
84
|
-
`plantuml` supports `png`, `svg` and `txt`.
|
85
|
-
|
86
|
-
The `txt` format is perhaps a bit non-obvious.
|
87
|
-
This generates an ascii art version of the UML diagrams.
|
88
|
-
|
89
|
-
The following Graphviz DOT script
|
90
|
-
|
91
|
-
---------
|
92
|
-
[graphviz, "dot_example", "svg"]
|
93
|
-
----
|
94
|
-
graph ethane {
|
95
|
-
C_0 -- H_0 [type=s];
|
96
|
-
C_0 -- H_1 [type=s];
|
97
|
-
C_0 -- H_2 [type=s];
|
98
|
-
C_0 -- C_1 [type=s];
|
99
|
-
C_1 -- H_3 [type=s];
|
100
|
-
C_1 -- H_4 [type=s];
|
101
|
-
C_1 -- H_5 [type=s];
|
102
|
-
}
|
103
|
-
----
|
104
|
-
---------
|
105
|
-
|
106
|
-
generates an SVG representation of an ethane molecule footnote:[From http://en.wikipedia.org/wiki/DOT_(graph_description_language)#A_simple_example]
|
107
|
-
|
108
|
-
[graphviz, "dot_example", "svg"]
|
109
|
-
----
|
110
|
-
graph ethane {
|
111
|
-
C_0 -- H_0 [type=s];
|
112
|
-
C_0 -- H_1 [type=s];
|
113
|
-
C_0 -- H_2 [type=s];
|
114
|
-
C_0 -- C_1 [type=s];
|
115
|
-
C_1 -- H_3 [type=s];
|
116
|
-
C_1 -- H_4 [type=s];
|
117
|
-
C_1 -- H_5 [type=s];
|
118
|
-
}
|
119
|
-
----
|
120
|
-
|
121
|
-
With https://github.com/Alwinator/graphviz-py[graphviz_py] you can also use variables and Python code to do calculations:
|
122
|
-
|
123
|
-
[graphviz_py, "graphviz_py_example", "svg"]
|
124
|
-
----
|
125
|
-
graph python_graph {
|
126
|
-
{{
|
127
|
-
import math
|
128
|
-
|
129
|
-
value = 0.5
|
130
|
-
sin = math.sin(value)
|
131
|
-
cos = math.cos(value)
|
132
|
-
}}
|
133
|
-
|
134
|
-
A [label="{{= value }}"];
|
135
|
-
B [label="{{= sin }}"];
|
136
|
-
C [label="{{= cos }}"];
|
137
|
-
|
138
|
-
A -- B [headlabel="sin"];
|
139
|
-
A -- C [headlabel="cos"];
|
140
|
-
|
141
|
-
}
|
142
|
-
----
|
143
|
-
|
144
|
-
Don't forget to install graphviz-py as described https://github.com/Alwinator/graphviz-py#installation[here].
|
145
|
-
|
146
|
-
== Using standard asciidoc features
|
147
|
-
|
148
|
-
Any remaining other attributes that are specified on a diagram block are copied over to the generated block.
|
149
|
-
This means you can use the regular http://asciidoctor.org/docs/user-manual/#put-images-in-their-place[asciidoc positioning attributes] to place the diagrams where you want to.
|
150
|
-
|
151
|
-
Block titles and block ids can also be applied in the same way to diagram blocks.
|
152
|
-
|
153
|
-
As an example, the following block
|
154
|
-
|
155
|
-
--------
|
156
|
-
[[plan]]
|
157
|
-
.My plan to conquer the world
|
158
|
-
[plantuml, align="center"]
|
159
|
-
--------
|
160
|
-
|
161
|
-
results in a block with the correct caption and id applied to it.
|
162
|
-
|
163
|
-
[[plan]]
|
164
|
-
.My plan to conquer the world
|
165
|
-
[plantuml, "activity_diagram", "svg", align="center"]
|
166
|
-
----
|
167
|
-
(*) --> "Create an Asciidoctor extension"
|
168
|
-
"Create an Asciidoctor extension" --> " ? "
|
169
|
-
" ? " --> "Profits!"
|
170
|
-
"Profits!" --> (*)
|
171
|
-
----
|
172
|
-
|
173
|
-
== Loading diagrams from external files
|
174
|
-
|
175
|
-
Asciidoctor-diagram also supports the various diagram block in block macro form.
|
176
|
-
These are macros of the form `<name>::<target>[<attrlist>]`.
|
177
|
-
|
178
|
-
In asciidoctor-diagram the macro names are identical to the block styles: `ditaa`, `graphviz` and `plantuml`
|
179
|
-
The target is the path to the file containing the diagram source code.
|
180
|
-
When the target is a relative path it is resolved with respect to the location of the document being processed.
|
181
|
-
The attribute list behaves mostly the same as with the block styles.
|
182
|
-
The only difference is that the `target` attribute is not supported.
|
183
|
-
Instead the name of the generated image is derived from the target propery of the macro.
|
184
|
-
|
185
|
-
The previous example in block macro form would look something like this with the text from the block located in a file called `activity_diagram.txt` instead of inline in the document.
|
186
|
-
|
187
|
-
----
|
188
|
-
plantuml::activity_diagram.txt[format="svg", align="center"]
|
189
|
-
----
|
Binary file
|
Binary file
|
Binary file
|
data/spec/a2s_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
A2S_CODE = <<-eos
|
4
|
-
.--. .---. .---. .---. .---. .---. .---.
|
5
|
-
| | OS API '---' '---' '---' '---' '---' '---'
|
6
|
-
v | | | | | | |
|
7
|
-
.-. .-. .-. | v v | v | v
|
8
|
-
.-->'-' '-' '-' | .------------. | .-----------. | .-----.
|
9
|
-
| \\ | / | | Filesystem | | | Scheduler | | | MMU |
|
10
|
-
| v . v | '------------' | '-----------' | '-----'
|
11
|
-
'_______/ \\_____| | | | |
|
12
|
-
\\ / v | | v
|
13
|
-
| ____ .----. | | .---------.
|
14
|
-
'--> /___/ | IO |<----' | | Network |
|
15
|
-
'----' | '---------'
|
16
|
-
| | |
|
17
|
-
v v v
|
18
|
-
.---------------------------------------.
|
19
|
-
| HAL |
|
20
|
-
'---------------------------------------'
|
21
|
-
eos
|
22
|
-
|
23
|
-
describe Asciidoctor::Diagram::AsciiToSvgInlineMacroProcessor do
|
24
|
-
include_examples "inline_macro", :a2s, A2S_CODE, [:svg]
|
25
|
-
end
|
26
|
-
|
27
|
-
describe Asciidoctor::Diagram::AsciiToSvgBlockMacroProcessor do
|
28
|
-
include_examples "block_macro", :a2s, A2S_CODE, [:svg]
|
29
|
-
end
|
30
|
-
|
31
|
-
describe Asciidoctor::Diagram::AsciiToSvgBlockProcessor do
|
32
|
-
include_examples "block", :svgbob, A2S_CODE, [:svg]
|
33
|
-
end
|