asciidoctor-diagram 1.4.0 → 1.5.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 +15 -0
- data/README.adoc +252 -95
- data/README_zh-CN.adoc +333 -0
- data/images/asciidoctor-diagram-classes.png +0 -0
- data/images/asciidoctor-diagram-process.png +0 -0
- data/lib/{asciidoctor-diagram-java-1.3.8.jar → asciidoctor-diagram-java-1.3.10.jar} +0 -0
- data/lib/asciidoctor-diagram.rb +9 -9
- data/lib/asciidoctor-diagram/blockdiag.rb +1 -2
- data/lib/asciidoctor-diagram/blockdiag/extension.rb +27 -12
- data/lib/asciidoctor-diagram/ditaa.rb +1 -2
- data/lib/asciidoctor-diagram/ditaa/extension.rb +33 -48
- data/lib/asciidoctor-diagram/extensions.rb +85 -18
- data/lib/asciidoctor-diagram/graphviz.rb +1 -2
- data/lib/asciidoctor-diagram/graphviz/extension.rb +14 -4
- data/lib/asciidoctor-diagram/meme.rb +1 -2
- data/lib/asciidoctor-diagram/meme/extension.rb +82 -79
- data/lib/asciidoctor-diagram/mermaid.rb +1 -2
- data/lib/asciidoctor-diagram/mermaid/extension.rb +33 -25
- data/lib/asciidoctor-diagram/plantuml.rb +1 -2
- data/lib/asciidoctor-diagram/plantuml/extension.rb +33 -22
- data/lib/asciidoctor-diagram/salt.rb +1 -2
- data/lib/asciidoctor-diagram/shaape.rb +1 -2
- data/lib/asciidoctor-diagram/shaape/extension.rb +10 -5
- data/lib/asciidoctor-diagram/util/cli_generator.rb +7 -5
- data/lib/asciidoctor-diagram/util/java.rb +1 -1
- data/lib/asciidoctor-diagram/util/platform.rb +12 -1
- data/lib/asciidoctor-diagram/util/which.rb +16 -7
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/lib/asciidoctor-diagram/wavedrom.rb +1 -2
- data/lib/asciidoctor-diagram/wavedrom/extension.rb +24 -20
- data/lib/plantuml.jar +0 -0
- data/spec/blockdiag_spec.rb +8 -8
- data/spec/ditaa_spec.rb +7 -7
- data/spec/graphviz_spec.rb +7 -7
- data/spec/meme_spec.rb +2 -2
- data/spec/mermaid_spec.rb +11 -11
- data/spec/plantuml_spec.rb +156 -34
- data/spec/shaape_spec.rb +8 -8
- data/spec/test_helper.rb +24 -5
- data/spec/wavedrom_spec.rb +11 -11
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae72b79905bac3a581f14f6ddc1023cb4063186e
|
4
|
+
data.tar.gz: 9ea96d64e9424ad728e094d3820e560c0e520f14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a3f7185995285e5d766c140d3a280f5628b819f8c976017a54a2df97fd908a08239566cc7c4aefd96934ad569d006f32ce2fea81533a4f612fdb46101d88c19
|
7
|
+
data.tar.gz: c43fafdb81683e2eb63cd5f41756f1d9fe7ece075cb7b4ef9d2a2616e51db19a180f132ffc5413c0bfcb9616ea0ef081c081755a0106e799da1175aba1705706
|
data/CHANGELOG.adoc
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
= Asciidoctor-diagram Changelog
|
2
2
|
|
3
|
+
== Development
|
4
|
+
|
5
|
+
== 1.5.0
|
6
|
+
|
7
|
+
Enhancements::
|
8
|
+
|
9
|
+
* Issue #98: Automatically detect Actdiag, Blockdiag, Nwdiag and Seqdiag executables from Python 3.x Debian packages.
|
10
|
+
* Issue #100: Support specifying the layout engine for `dot` (`-K<engine>`) using the `layout` attribute on `graphviz` blocks.
|
11
|
+
* Issue #102: Generate cache files in `asciidoctor/diagram` to avoid cluttering the output directory.
|
12
|
+
* Issue #105: Support substitutions in diagram blocks.
|
13
|
+
* Issue #107: Improve error reporting when Mermaid diagram generation fails.
|
14
|
+
* Issue #112: Update PlantUML to revision 8043 (19/06/2016)
|
15
|
+
* Issue #114: Asciidoctor Diagram now requires Asciidoctor if it hasn't been loaded already.
|
16
|
+
* Issue #116: Resolve relative paths in PlantUML !include directives
|
17
|
+
|
3
18
|
== 1.4.0
|
4
19
|
|
5
20
|
Enhancements::
|
data/README.adoc
CHANGED
@@ -1,101 +1,183 @@
|
|
1
1
|
= Asciidoctor Diagram
|
2
|
-
Pepijn Van_Eeckhoudt
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
-
|
11
|
-
-
|
12
|
-
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
+
ifdef::env-github[:toc: macro]
|
5
|
+
ifndef::env-site[:toc: preamble]
|
6
|
+
ifndef::imagesdir[:imagesdir: images]
|
7
|
+
:icons: font
|
8
|
+
:source-highlighter: coderay
|
9
|
+
:source-language: asciidoc
|
10
|
+
:table-caption!:
|
11
|
+
:example-caption!:
|
12
|
+
:figure-caption!:
|
13
|
+
:check: icon:check[]
|
14
|
+
ifdef::env-github[:check: :ballot_box_with_check:]
|
15
|
+
ifndef::env-site[:status:]
|
16
|
+
:uri-actdiag: http://blockdiag.com/en/actdiag/index.html
|
17
|
+
:uri-asciidoctor-api: http://asciidoctor.org/docs/user-manual/#api
|
18
|
+
:uri-asciidoctor-extensions: http://asciidoctor.org/docs/user-manual/#extension-points
|
19
|
+
:uri-blockdiag: http://blockdiag.com
|
20
|
+
:uri-ditaa: http://ditaa.sourceforge.net/
|
21
|
+
:uri-dot: http://www.graphviz.org/content/dot-language
|
22
|
+
:uri-graphviz: http://www.graphviz.org
|
23
|
+
:uri-imagemagick: http://www.imagemagick.org
|
24
|
+
:uri-java: http://java.sun.com
|
25
|
+
:uri-mermaid: http://knsv.github.io/mermaid/
|
26
|
+
:uri-nwdiag: http://blockdiag.com/en/nwdiag/index.html
|
27
|
+
:uri-packetdiag: http://blockdiag.com/en/nwdiag/index.html
|
28
|
+
:uri-phantomjs: http://phantomjs.org
|
29
|
+
:uri-plantuml: http://plantuml.sourceforge.net
|
30
|
+
:uri-py-plantuml: https://code.google.com/p/asciidoc-plantuml/
|
31
|
+
:uri-rackdiag: http://blockdiag.com/en/nwdiag/index.html
|
32
|
+
:uri-seqdiag: http://blockdiag.com/en/seqdiag/index.html
|
33
|
+
:uri-shaape: https://github.com/christiangoltz/shaape
|
34
|
+
:uri-wavedrom: http://wavedrom.com
|
35
|
+
:uri-wavedromeditor: https://github.com/wavedrom/wavedrom.github.io/releases
|
36
|
+
:uri-wavedromcli: https://github.com/wavedrom/cli
|
37
|
+
|
38
|
+
Asciidoctor Diagram is a set of Asciidoctor extensions that enable you to add diagrams, which you describe using plain text, to your AsciiDoc document.
|
39
|
+
|
40
|
+
The extensions support BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, GraphViz, Mermaid, PlantUML, Shaape and WaveDrom syntax.
|
41
|
+
|
42
|
+
Each extension runs the diagram processor to generate an SVG, PNG, or TXT file from the input text.
|
43
|
+
The generated file is then inserted into your converted document.
|
44
|
+
|
45
|
+
Asciidoctor Diagram was inspired by the {uri-py-plantuml}[AsciiDoc PlantUML filter].
|
46
|
+
|
47
|
+
Translations of the document are available in the following languages:
|
48
|
+
|
49
|
+
* link:README_zh-CN.adoc[汉语]
|
50
|
+
|
51
|
+
ifdef::status[]
|
52
|
+
[discrete]
|
21
53
|
== Status
|
22
54
|
|
23
55
|
image:https://travis-ci.org/asciidoctor/asciidoctor-diagram.svg?branch=master["Linux Build Status", link="https://travis-ci.org/asciidoctor/asciidoctor-diagram"]
|
24
|
-
|
25
56
|
image:https://ci.appveyor.com/api/projects/status/4r4gkk5gy3igs6nh/branch/master?svg=true["Windows Build Status", link="https://ci.appveyor.com/project/asciidoctor/asciidoctor-diagram"]
|
57
|
+
image:https://img.shields.io/gem/v/asciidoctor-diagram.svg?label=gem%20version[Gem Version, link=https://rubygems.org/gems/asciidoctor-diagram]
|
58
|
+
endif::status[]
|
26
59
|
|
27
|
-
==
|
28
|
-
|
29
|
-
|
60
|
+
ifeval::["{toc-placement}" == "macro"]
|
61
|
+
[discrete]
|
62
|
+
== Contents
|
30
63
|
|
31
|
-
|
32
|
-
|
33
|
-
```
|
64
|
+
toc::[title={blank}]
|
65
|
+
endif::[]
|
34
66
|
|
35
|
-
|
67
|
+
== Installation
|
36
68
|
|
37
|
-
|
69
|
+
Asciidoctor Diagram is a RubyGem, which can be installed using the `gem` or `bundle` commands.
|
38
70
|
|
39
|
-
|
71
|
+
You can install the Asciidoctor Diagram gem by typing `gem install` in the CLI.
|
40
72
|
|
41
73
|
$ gem install asciidoctor-diagram
|
42
74
|
|
43
|
-
|
75
|
+
by first adding the following entry to your project's [.path]_Gemfile_.
|
44
76
|
|
45
|
-
|
77
|
+
.Gemfile
|
78
|
+
[source,ruby]
|
79
|
+
----
|
80
|
+
gem 'asciidoctor-diagram', '~> 1.4.0'
|
81
|
+
----
|
46
82
|
|
47
|
-
|
48
|
-
- Graphviz: the http://www.graphviz.org[Graphviz] package
|
49
|
-
- Meme: http://www.imagemagick.org[ImageMagick]
|
50
|
-
- Mermaid: the http://knsv.github.io/mermaid[Mermaid] CLI and http://phantomjs.org[PhantomJS] 1.9.x
|
51
|
-
- PlantUML: http://www.graphviz.org[Graphviz] package for certain diagram types.
|
52
|
-
- Shaape: the Shaape Python package
|
53
|
-
- WaveDrom: the https://github.com/wavedrom/wavedrom.github.io/releases[WaveDrom editor] application
|
83
|
+
Then execute `bundle` in the CLI.
|
54
84
|
|
55
|
-
|
85
|
+
$ bundle
|
56
86
|
|
57
|
-
|
87
|
+
== Creating a Diagram
|
58
88
|
|
59
|
-
|
60
|
-
In order to use extensions you should need to invoke Asciidoctor via the http://asciidoctor.org/docs/user-manual/#api[Ruby API].
|
61
|
-
In your script you can then either require one or more of the following files:
|
89
|
+
A diagram is written inside a literal block, which can accept several attributes.
|
62
90
|
|
63
|
-
.
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
. `
|
91
|
+
.Anatomy of a diagram
|
92
|
+
----
|
93
|
+
[diagram-type, generated-file-name, generated-image-format] // <1> <2> <3>
|
94
|
+
.... // <4>
|
95
|
+
Diagram in appropriate syntax
|
96
|
+
....
|
97
|
+
----
|
98
|
+
<1> The first positional attribute in the attribute list specifies the diagram that is being used.
|
99
|
+
<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.
|
100
|
+
<3> The third, optional positional attribute specifies the image format to create, specified as a three character file extension.
|
101
|
+
<4> Place the attribute list directly on top of the delimited literal block (+....+). You can also use an open block as an alternative (`--`).
|
102
|
+
|
103
|
+
The following diagram types and output formats are available:
|
104
|
+
|
105
|
+
[cols=">,4*^",options="header"]
|
106
|
+
|===
|
107
|
+
|Diagram Type |gif |png |svg |txt
|
108
|
+
|{uri-actdiag}[actdiag] | |{check}|{check}|
|
109
|
+
|{uri-blockdiag}[blockdiag] | |{check}|{check}|
|
110
|
+
|{uri-ditaa}[ditaa] | |{check}| |
|
111
|
+
|{uri-dot}[graphviz] | |{check}|{check}|
|
112
|
+
|<<meme,meme>> |{check}|{check}| |
|
113
|
+
|{uri-mermaid}[mermaid] | |{check}|{check}|
|
114
|
+
|{uri-nwdiag}[nwdiag] | |{check}|{check}|
|
115
|
+
|{uri-packetdiag}[packetdiag]| |{check}|{check}|
|
116
|
+
|{uri-plantuml}[plantuml] | |{check}|{check}|{check}
|
117
|
+
|{uri-rackdiag}[rackdiag] | |{check}|{check}|
|
118
|
+
|{uri-seqdiag}[seqdiag] | |{check}|{check}|
|
119
|
+
|{uri-shaape}[shaape] | |{check}|{check}|
|
120
|
+
|{uri-wavedrom}[wavedrom] | |{check}|{check}|
|
121
|
+
|===
|
122
|
+
|
123
|
+
The example below illustrates the structure of a basic ditaa block written directly in an AsciiDoc document.
|
124
|
+
|
125
|
+
.Basic ditaa block
|
126
|
+
[source]
|
127
|
+
----
|
128
|
+
[ditaa]
|
129
|
+
....
|
130
|
+
+-------------+
|
131
|
+
| Asciidoctor |-------+
|
132
|
+
| diagram | |
|
133
|
+
+-------------+ | PNG out
|
134
|
+
^ |
|
135
|
+
| ditaa in |
|
136
|
+
| v
|
137
|
+
+--------+ +--------+----+ /---------------\
|
138
|
+
| | --+ Asciidoctor +--> | |
|
139
|
+
| Text | +-------------+ | Beautiful |
|
140
|
+
|Document| | !magic! | | Output |
|
141
|
+
| {d}| | | | |
|
142
|
+
+---+----+ +-------------+ \---------------/
|
143
|
+
: ^
|
144
|
+
| Lots of work |
|
145
|
+
+-----------------------------------+
|
146
|
+
....
|
147
|
+
----
|
72
148
|
|
73
|
-
|
74
|
-
If you need more fine grained control over when the extensions are enabled or not, `asciidoctor-diagram/ditaa/extension`, `asciidoctor-diagram/graphviz/extension` and `asciidoctor-diagram/plantuml/extension` can be used instead.
|
75
|
-
These load the extensions themselves but do not register them.
|
76
|
-
You should then register the extensions yourself at the appropriate time using the `Asciidoctor::Extensions` API.
|
149
|
+
The ditaa block above results in the following generated diagram.
|
77
150
|
|
78
|
-
|
151
|
+
.Rendered ditaa diagram
|
152
|
+
image::asciidoctor-diagram-process.png[Asciidoctor Diagram process diagram,650,319]
|
79
153
|
|
80
|
-
|
154
|
+
The rendered ditaa diagram above gets the file name `58372f7d2ceffae9e91fd0a7cbb080b6.png`.
|
155
|
+
That long number is the checksum of the source code calculated by asciidoctor-diagram.
|
156
|
+
If you want to give your generated files a more meaningful name, fill in the `target` attribute.
|
81
157
|
|
82
|
-
|
83
|
-
|
84
|
-
- `graphviz`
|
85
|
-
- `meme`
|
86
|
-
- `mermaid`
|
87
|
-
- `plantuml`
|
88
|
-
- `shaape`
|
89
|
-
- `wavedrom`
|
158
|
+
This can be done by either specifying it as the second positional attribute or as a named attribute.
|
159
|
+
Both examples below would result in a file called `ditaa-diagram.png`.
|
90
160
|
|
91
|
-
|
161
|
+
....
|
162
|
+
[ditaa, "ditaa-diagram"]
|
163
|
+
----
|
164
|
+
<snip>
|
165
|
+
----
|
92
166
|
|
93
|
-
|
94
|
-
|
167
|
+
[ditaa, target="ditaa-diagram"]
|
168
|
+
----
|
169
|
+
<snip>
|
170
|
+
----
|
171
|
+
....
|
172
|
+
|
173
|
+
|
174
|
+
The example below illustrates the structure of a basic PlantUML block written directly in an AsciiDoc document.
|
95
175
|
|
176
|
+
.PlantUML Diagram Syntax
|
177
|
+
[source]
|
96
178
|
----
|
97
|
-
[
|
98
|
-
|
179
|
+
[plantuml, diagram-classes, png] // <1> <2> <3>
|
180
|
+
....
|
99
181
|
class BlockProcessor
|
100
182
|
class DiagramBlock
|
101
183
|
class DitaaBlock
|
@@ -104,42 +186,125 @@ class PlantUmlBlock
|
|
104
186
|
BlockProcessor <|-- DiagramBlock
|
105
187
|
DiagramBlock <|-- DitaaBlock
|
106
188
|
DiagramBlock <|-- PlantUmlBlock
|
107
|
-
|
189
|
+
....
|
108
190
|
----
|
191
|
+
<1> The diagram is written in PlantUML so the first positional attribute is assigned the `plantuml` diagram type.
|
192
|
+
<2> The name of the generated diagram file (target) is written in the second positional attribute.
|
193
|
+
<3> The output format is entered in the third positional attribute.
|
194
|
+
|
195
|
+
.Rendered PlantUML diagram
|
196
|
+
image::asciidoctor-diagram-classes.png[Asciidoctor Diagram classes diagram]
|
197
|
+
|
198
|
+
== Generating a Diagram from a Terminal
|
199
|
+
|
200
|
+
You can load Asciidoctor diagram in a terminal using the `-r` flag.
|
201
|
+
|
202
|
+
$ asciidoctor -r asciidoctor-diagram sample.adoc
|
203
|
+
|
204
|
+
You can also use Asciidoctor diagram with other converters, such as Asciidoctor EPUB.
|
205
|
+
Asciidoctor-epub3 is also loaded with the `-r` flag.
|
206
|
+
|
207
|
+
$ asciidoctor -r asciidoctor-diagram -r asciidoctor-epub3 -b epub3 sample.adoc
|
208
|
+
|
209
|
+
Or, you can invoke Asciidoctor and the EPUB converter with the `asciidoctor-epub3` command.
|
210
|
+
The command implicitly sets the `-r` and `-b` flags for EPUB3 output.
|
211
|
+
|
212
|
+
$ asciidoctor-epub3 -r asciidoctor-diagram sample.adoc
|
109
213
|
|
110
|
-
|
214
|
+
== Advanced Usage
|
111
215
|
|
112
|
-
|
113
|
-
. `format` (2nd positional attribute): the output format. PlantUML blocks support `png`, `svg` and `txt`. Graphviz, Shaape and BlockDiag support `png` and `svg`. Ditaa only supports `png`.
|
216
|
+
=== Enabling Extensions
|
114
217
|
|
115
|
-
|
116
|
-
When executing Asciidoctor, you must reference the Adciidoctor Diagram library, otherwise your diagram blocks won't be recognized as such. When executing Asciidoctor from the command line, do it using the -r parameter to reference this external library:
|
218
|
+
In your program, you can either load and register the entire set of diagram extensions
|
117
219
|
|
220
|
+
[source,ruby]
|
118
221
|
----
|
119
|
-
|
222
|
+
require 'asciidoctor-diagram'
|
120
223
|
----
|
121
224
|
|
122
|
-
|
123
|
-
The target of diagram block macro should refer to the file containing the diagram source code.
|
124
|
-
The attributes for the block macros are the same as for the inline blocks.
|
125
|
-
The example above in block macro form becomes
|
225
|
+
or load and register each extension individually.
|
126
226
|
|
227
|
+
[source,ruby]
|
127
228
|
----
|
128
|
-
|
229
|
+
require 'asciidoctor-diagram/<extension_name>'
|
129
230
|
----
|
130
231
|
|
131
|
-
|
232
|
+
`<extension_name>` can be one of `blockdiag`, `ditaa`, `graphviz`, `meme`, `mermaid`, `plantuml`, `shaape`, or `wavedrom`.
|
132
233
|
|
133
|
-
|
234
|
+
Requiring one or more of these files will automatically register the extensions for all processed documents.
|
235
|
+
|
236
|
+
If you need more fine grained control over when the extensions are enabled, `asciidoctor-diagram/<extension_name>/extension` can be used instead.
|
237
|
+
This loads the extensions but does not register it in the Asciidoctor extension registry.
|
238
|
+
You can then manually register the extensions at the appropriate times using the `Asciidoctor::Extensions` API.
|
239
|
+
|
240
|
+
This document explains the various features of asciidoctor-diagram blocks using ditaa diagrams as an example.
|
241
|
+
|
242
|
+
=== Diagram Block Macro
|
243
|
+
|
244
|
+
The diagram extensions can also be used in in block macro form.
|
245
|
+
|
246
|
+
.Anatomy of a diagram block macro
|
247
|
+
----
|
248
|
+
block-name::source-file-name[generated-file-extension] // <1> <2> <3>
|
249
|
+
----
|
250
|
+
<1> The macro name is the same as the block name in the block form.
|
251
|
+
<2> The source file name specifies the external file that contains the diagram source code.
|
252
|
+
<3> The first, optional, positional attribute assigns the file extension (i.e. `format`) to the generated diagram.
|
253
|
+
|
254
|
+
When the source file name is a relative path it is resolved with respect to the location of the document being processed.
|
255
|
+
|
256
|
+
=== Image Output Location
|
257
|
+
|
258
|
+
When Asciidoctor Diagram writes images to disk it will go over the following options in order to determine where to write the files.
|
259
|
+
|
260
|
+
. `\{imagesoutdir\}` if the `imagesoutdir` attribute has been specified
|
261
|
+
. `\{outdir\}/\{imagesdir\}` if the `outdir` attribute has been specified
|
262
|
+
. `\{to_dir\}/\{imagesdir\}` if the `to_dir` attribute has been specified
|
263
|
+
. `\{base_dir\}/\{imagesdir\}`
|
264
|
+
|
265
|
+
=== Specifying Diagram Generator Paths
|
266
|
+
|
267
|
+
Asciidoctor Diagram depends on external tools to generates images.
|
268
|
+
In most cases it will locate these tools automatically for you by looking for specific executables in each directory in the `PATH` environment variable.
|
269
|
+
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.
|
270
|
+
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.
|
271
|
+
|
272
|
+
[cols=">,2*<",options="header"]
|
273
|
+
|===
|
274
|
+
|Diagram Type |Tool |Attribute
|
275
|
+
|actdiag |{uri-actdiag}[ActDiag] |`actdiag`
|
276
|
+
|blockdiag |{uri-blockdiag}[BlockDiag] |`blockdiag`
|
277
|
+
|ditaa |{uri-java}[Java] |`java`
|
278
|
+
|graphviz |{uri-graphviz}[GraphViz] |`dot` or `graphvizdot`
|
279
|
+
|meme |{uri-imagemagick}[ImageMagick] |`convert` and `identify`
|
280
|
+
|mermaid |{uri-mermaid}[Mermaid] |`mermaid`
|
281
|
+
|nwdiag |{uri-nwdiag}[NwDiag] |`nwdiag`
|
282
|
+
|packetdiag |{uri-nwdiag}[NwDiag] |`packetdiag`
|
283
|
+
|plantuml |{uri-java}[Java] |`java`
|
284
|
+
|rackdiag |{uri-nwdiag}[NwDiag] |`rackdiag`
|
285
|
+
|seqdiag |{uri-seqdiag}[SeqDiag] |`seqdiag`
|
286
|
+
|shaape |{uri-shaape}[Shaape] |`shaape`
|
287
|
+
.2+|wavedrom |{uri-wavedromeditor}[WaveDrom Editor] |`wavedrom`
|
288
|
+
|{uri-wavedromcli}[WaveDrom CLI] and {uri-phantomjs}[PhantomJS] |`wavedrom` and `phantomjs`
|
289
|
+
|===
|
290
|
+
|
291
|
+
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
|
292
|
+
|
293
|
+
$ asciidoctor -a actdiag=/home/me/actdiag/bin/actdiag -r asciidoctor-diagram sample.adoc
|
294
|
+
|
295
|
+
[[meme]]
|
296
|
+
=== The Meme Extension
|
297
|
+
|
298
|
+
The meme extension provides a basic '`Advice Animal`' style image generator.
|
134
299
|
It's usage is easiest to explain with an example.
|
135
300
|
|
136
301
|
----
|
137
|
-
meme::
|
302
|
+
meme::yunoguy.jpg[Doc writers,Y U NO \\ AsciiDoc]
|
138
303
|
----
|
139
304
|
|
140
305
|
The target of the block macro tells the extension which image to use as background.
|
141
306
|
The first two positional attributes are `top` and `bottom` and are used for the top and bottom label.
|
142
|
-
Occurrences of
|
307
|
+
Occurrences of `\\` surrounded by whitespace are interpreted as line breaks.
|
143
308
|
|
144
309
|
The block macro also supports the following named attributes:
|
145
310
|
|
@@ -150,11 +315,3 @@ The block macro also supports the following named attributes:
|
|
150
315
|
. `options`: a comma separate list of flags that modify the image rendering. Currently only `noupcase` is supported which disable upper casing the labels.
|
151
316
|
. `target` (3rd positional attribute): the basename of the file to generate. If not specified an auto-generated name will be used.
|
152
317
|
. `format` (4th positional attribute): the output image format. The meme extension supports `png` and `gif`.
|
153
|
-
|
154
|
-
== Contributing
|
155
|
-
|
156
|
-
. Fork it
|
157
|
-
. Create your feature branch (`git checkout -b my-new-feature`)
|
158
|
-
. Commit your changes (`git commit -am 'Add some feature'`)
|
159
|
-
. Push to the branch (`git push origin my-new-feature`)
|
160
|
-
. Create new Pull Request
|
data/README_zh-CN.adoc
ADDED
@@ -0,0 +1,333 @@
|
|
1
|
+
= Asciidoctor Diagram
|
2
|
+
Pepijn Van_Eeckhoudt <https://github.com/pepijnve[@pepijnve]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>
|
3
|
+
:translators: D瓜哥
|
4
|
+
ifdef::env-github[Translated by: {translators}]
|
5
|
+
:description: Asciidoctor 的 扩展 Asciidoctor Diagram 的说明文档。
|
6
|
+
ifdef::env-github[:toc: macro]
|
7
|
+
ifndef::env-site[:toc: preamble]
|
8
|
+
ifndef::imagesdir[:imagesdir: images]
|
9
|
+
:icons: font
|
10
|
+
:source-highlighter: coderay
|
11
|
+
:source-language: asciidoc
|
12
|
+
:table-caption!:
|
13
|
+
:example-caption!:
|
14
|
+
:figure-caption!:
|
15
|
+
:check: icon:check[]
|
16
|
+
ifdef::env-github[:check: :ballot_box_with_check:]
|
17
|
+
ifndef::env-site[:status:]
|
18
|
+
:uri-actdiag: http://blockdiag.com/en/actdiag/index.html
|
19
|
+
:uri-asciidoctor-api: http://asciidoctor.org/docs/user-manual/#api
|
20
|
+
:uri-asciidoctor-extensions: http://asciidoctor.org/docs/user-manual/#extension-points
|
21
|
+
:uri-blockdiag: http://blockdiag.com
|
22
|
+
:uri-ditaa: http://ditaa.sourceforge.net/
|
23
|
+
:uri-dot: http://www.graphviz.org/content/dot-language
|
24
|
+
:uri-graphviz: http://www.graphviz.org
|
25
|
+
:uri-imagemagick: http://www.imagemagick.org
|
26
|
+
:uri-java: http://java.sun.com
|
27
|
+
:uri-mermaid: http://knsv.github.io/mermaid/
|
28
|
+
:uri-nwdiag: http://blockdiag.com/en/nwdiag/index.html
|
29
|
+
:uri-packetdiag: http://blockdiag.com/en/nwdiag/index.html
|
30
|
+
:uri-phantomjs: http://phantomjs.org
|
31
|
+
:uri-plantuml: http://plantuml.sourceforge.net
|
32
|
+
:uri-py-plantuml: https://code.google.com/p/asciidoc-plantuml/
|
33
|
+
:uri-rackdiag: http://blockdiag.com/en/nwdiag/index.html
|
34
|
+
:uri-seqdiag: http://blockdiag.com/en/seqdiag/index.html
|
35
|
+
:uri-shaape: https://github.com/christiangoltz/shaape
|
36
|
+
:uri-wavedrom: http://wavedrom.com
|
37
|
+
:uri-wavedromeditor: https://github.com/wavedrom/wavedrom.github.io/releases
|
38
|
+
:uri-wavedromcli: https://github.com/wavedrom/cli
|
39
|
+
|
40
|
+
Asciidoctor Diagram 是一组 Asciidoctor 扩展,它可以让你向 AsciiDoc 文档中添加图表,而这些图表则是使用纯文本描述的。
|
41
|
+
|
42
|
+
扩展支持 BlockDiag (BlockDiag、SeqDiag、ActDiag、NwDiag), Ditaa、GraphViz、Mermaid、PlantUML、Shaape 和 WaveDrom 语法。
|
43
|
+
|
44
|
+
每个扩展都是运行图表处理器,然后根据输入文本来生成一个 SVG、PNG 或 TXT 文件。
|
45
|
+
生成的文件随后插入到你处理过的文档中。
|
46
|
+
|
47
|
+
Asciidoctor Diagram 是受 {uri-py-plantuml}[AsciiDoc PlantUML filter] 启发而产生的项目。
|
48
|
+
|
49
|
+
该文档有如下语言的翻译版:
|
50
|
+
|
51
|
+
* link:README.adoc[English]
|
52
|
+
|
53
|
+
TIP: 本文档是 link:README.adoc[README] 的翻译版。如果发现有什么不一致或者错误的地方,请以原文档为准。
|
54
|
+
|
55
|
+
ifdef::status[]
|
56
|
+
[discrete]
|
57
|
+
[[status]]
|
58
|
+
== 状态
|
59
|
+
|
60
|
+
image:https://travis-ci.org/asciidoctor/asciidoctor-diagram.svg?branch=master["Linux Build Status", link="https://travis-ci.org/asciidoctor/asciidoctor-diagram"]
|
61
|
+
image:https://ci.appveyor.com/api/projects/status/4r4gkk5gy3igs6nh/branch/master?svg=true["Windows Build Status", link="https://ci.appveyor.com/project/asciidoctor/asciidoctor-diagram"]
|
62
|
+
image:https://img.shields.io/gem/v/asciidoctor-diagram.svg?label=gem%20version[Gem Version, link=https://rubygems.org/gems/asciidoctor-diagram]
|
63
|
+
endif::status[]
|
64
|
+
|
65
|
+
ifeval::["{toc-placement}" == "macro"]
|
66
|
+
[discrete]
|
67
|
+
== Contents
|
68
|
+
|
69
|
+
toc::[title={blank}]
|
70
|
+
endif::[]
|
71
|
+
|
72
|
+
[[installation]]
|
73
|
+
== 安装
|
74
|
+
|
75
|
+
Asciidoctor Diagram 是一个 RubyGem ,它可以使用 `gem` 或 `bundle` 命令来安装。
|
76
|
+
|
77
|
+
你可以通过在命令行中输入 `gem install` 来安装 Asciidoctor Diagram。
|
78
|
+
|
79
|
+
$ gem install asciidoctor-diagram
|
80
|
+
|
81
|
+
或者,先在项目的 [.path]_Gemfile_ 文件中添加如下内容:
|
82
|
+
|
83
|
+
.Gemfile
|
84
|
+
[source,ruby]
|
85
|
+
----
|
86
|
+
gem 'asciidoctor-diagram', '~> 1.4.0'
|
87
|
+
----
|
88
|
+
|
89
|
+
然后在命令中执行 `bundle` 命令。
|
90
|
+
|
91
|
+
$ bundle
|
92
|
+
|
93
|
+
[[creating-a-diagram]]
|
94
|
+
== 创建图表
|
95
|
+
|
96
|
+
一个图表可以直接书写在文档内部的文本块中,这个文本块还可以接受几个属性。
|
97
|
+
|
98
|
+
.图表骨架
|
99
|
+
----
|
100
|
+
[diagram-type, generated-file-name, generated-image-format] // <1> <2> <3>
|
101
|
+
.... // <4>
|
102
|
+
符合相应语法的图表
|
103
|
+
....
|
104
|
+
----
|
105
|
+
<1> 属性列表中第一个位置的属性指明所使用的图表类型。
|
106
|
+
<2> 第二个位置的属性指明生成文件的文件名。如果没有指明,则默认使用原文件名来命名新生成的文件名。
|
107
|
+
<3> 第三个位置的属性指明生成图表的格式,类似三个字符的文件扩展名。
|
108
|
+
<4> 将属性列表直接放在文本块分隔符( +....+ )上面。你也可以使用开放块( `--` )作为另一个选择。
|
109
|
+
|
110
|
+
图表类型以及可用的输出格式如下:
|
111
|
+
|
112
|
+
[cols=">,4*^",options="header"]
|
113
|
+
|===
|
114
|
+
|图表类型 |gif |png |svg |txt
|
115
|
+
|{uri-actdiag}[actdiag] | |{check}|{check}|
|
116
|
+
|{uri-blockdiag}[blockdiag] | |{check}|{check}|
|
117
|
+
|{uri-ditaa}[ditaa] | |{check}| |
|
118
|
+
|{uri-dot}[graphviz] | |{check}|{check}|
|
119
|
+
|<<meme,meme>> |{check}|{check}| |
|
120
|
+
|{uri-mermaid}[mermaid] | |{check}|{check}|
|
121
|
+
|{uri-nwdiag}[nwdiag] | |{check}|{check}|
|
122
|
+
|{uri-packetdiag}[packetdiag]| |{check}|{check}|
|
123
|
+
|{uri-plantuml}[plantuml] | |{check}|{check}|{check}
|
124
|
+
|{uri-rackdiag}[rackdiag] | |{check}|{check}|
|
125
|
+
|{uri-seqdiag}[seqdiag] | |{check}|{check}|
|
126
|
+
|{uri-shaape}[shaape] | |{check}|{check}|
|
127
|
+
|{uri-wavedrom}[wavedrom] | |{check}|{check}|
|
128
|
+
|===
|
129
|
+
|
130
|
+
下面的例子演示一个直接书写在 AsciiDoc 文档中的基本 ditaa 块的结构。
|
131
|
+
|
132
|
+
.基本 ditaa 块
|
133
|
+
[source]
|
134
|
+
----
|
135
|
+
[ditaa]
|
136
|
+
....
|
137
|
+
+-------------+
|
138
|
+
| Asciidoctor |-------+
|
139
|
+
| diagram | |
|
140
|
+
+-------------+ | PNG out
|
141
|
+
^ |
|
142
|
+
| ditaa in |
|
143
|
+
| v
|
144
|
+
+--------+ +--------+----+ /---------------\
|
145
|
+
| | --+ Asciidoctor +--> | |
|
146
|
+
| Text | +-------------+ | Beautiful |
|
147
|
+
|Document| | !magic! | | Output |
|
148
|
+
| {d}| | | | |
|
149
|
+
+---+----+ +-------------+ \---------------/
|
150
|
+
: ^
|
151
|
+
| Lots of work |
|
152
|
+
+-----------------------------------+
|
153
|
+
....
|
154
|
+
----
|
155
|
+
|
156
|
+
上面的 ditaa 块生成的图表如下图所示:
|
157
|
+
|
158
|
+
.渲染 ditaa 图表
|
159
|
+
image::asciidoctor-diagram-process.png[Asciidoctor Diagram 处理图表,650,319]
|
160
|
+
|
161
|
+
上面渲染后的图表得到的文件名为 `58372f7d2ceffae9e91fd0a7cbb080b6.png`。
|
162
|
+
这串长数字是源码的校验和,由 asciidoctor-diagram 计算所得。
|
163
|
+
如果想给所生成的文件一个更具有意义的名字,请在 `target` 属性中填写。
|
164
|
+
|
165
|
+
这可以很容易通过指明第二个位置的属性或者一个命名属性来指明文件名。
|
166
|
+
下面的两个例子将生成文件名为 `ditaa-diagram.png` 的文件。
|
167
|
+
|
168
|
+
....
|
169
|
+
[ditaa, "ditaa-diagram"]
|
170
|
+
----
|
171
|
+
<snip>
|
172
|
+
----
|
173
|
+
|
174
|
+
[ditaa, target="ditaa-diagram"]
|
175
|
+
----
|
176
|
+
<snip>
|
177
|
+
----
|
178
|
+
....
|
179
|
+
|
180
|
+
下面的例子演示一个直接书写在 AsciiDoc 文档中的基本 PlantUML 块的结构。
|
181
|
+
|
182
|
+
.PlantUML 图表语法
|
183
|
+
[source]
|
184
|
+
----
|
185
|
+
[plantuml, diagram-classes, png] // <1> <2> <3>
|
186
|
+
....
|
187
|
+
class BlockProcessor
|
188
|
+
class DiagramBlock
|
189
|
+
class DitaaBlock
|
190
|
+
class PlantUmlBlock
|
191
|
+
|
192
|
+
BlockProcessor <|-- DiagramBlock
|
193
|
+
DiagramBlock <|-- DitaaBlock
|
194
|
+
DiagramBlock <|-- PlantUmlBlock
|
195
|
+
....
|
196
|
+
----
|
197
|
+
<1> 这个图表是使用 PlantUML 书写的,所以第一个位置的属性应该被指明为 `plantuml` 图表类型。
|
198
|
+
<2> 生成的图表文件的名字被书写在第二个位置的属性。
|
199
|
+
<3> 生成的文件格式放置在第三个属性位置。
|
200
|
+
|
201
|
+
.渲染后的 PlantUML 图表
|
202
|
+
image::asciidoctor-diagram-classes.png[Asciidoctor Diagram 类图]
|
203
|
+
|
204
|
+
[[generating-a-diagram-from-a-terminal]]
|
205
|
+
== 从终端中生成图表
|
206
|
+
|
207
|
+
你可以使用 `-r` 标识在终端中加载 Asciidoctor Diagram。
|
208
|
+
|
209
|
+
$ asciidoctor -r asciidoctor-diagram sample.adoc
|
210
|
+
|
211
|
+
你也可以在其他的转化器中使用 Asciidoctor Diagram,例如 Asciidoctor EPUB。
|
212
|
+
Asciidoctor-epub3 也是通过 `-r` 标识来加载。
|
213
|
+
|
214
|
+
$ asciidoctor -r asciidoctor-diagram -r asciidoctor-epub3 -b epub3 sample.adoc
|
215
|
+
|
216
|
+
或者,你也可以通过 `asciidoctor-epub3` 命令来调用 Asciidoctor 和 EPUB 转化器。
|
217
|
+
这个命令隐式地设置 `-r` 和 `-b` 标识用于 EPUB3 输出。
|
218
|
+
|
219
|
+
$ asciidoctor-epub3 -r asciidoctor-diagram sample.adoc
|
220
|
+
|
221
|
+
[[advanced-usage]]
|
222
|
+
== 高级用法
|
223
|
+
|
224
|
+
[[enabling-extensions]]
|
225
|
+
=== 启用扩展
|
226
|
+
|
227
|
+
在你的程序中,你可以加载并注册整个图表扩展集合。
|
228
|
+
|
229
|
+
[source,ruby]
|
230
|
+
----
|
231
|
+
require 'asciidoctor-diagram'
|
232
|
+
----
|
233
|
+
|
234
|
+
或者,加载并注册每一个单独的扩展。
|
235
|
+
|
236
|
+
[source,ruby]
|
237
|
+
----
|
238
|
+
require 'asciidoctor-diagram/<extension_name>'
|
239
|
+
----
|
240
|
+
|
241
|
+
`<extension_name>` 可以是 `blockdiag`、`ditaa`、`graphviz`、`meme`、`mermaid`、`plantuml`、`shaape` 或 `wavedrom`。
|
242
|
+
|
243
|
+
加载一个或多个这些文件将为所有需要处理的文档自动注册这些扩展。
|
244
|
+
|
245
|
+
如果你需要更细粒度控制扩展的可用性, 则可以使用 `asciidoctor-diagram/<extension_name>/extension`。
|
246
|
+
它将加载扩展但是不会向 Asciidoctor 扩展注册表中注册。
|
247
|
+
你可以在恰当的时机使用 `Asciidoctor::Extensions` API 来手动注册扩展。
|
248
|
+
|
249
|
+
本文档使用 ditaa 图表作为示例,演示了 asciidoctor-diagram 块的一系列特性。
|
250
|
+
|
251
|
+
[[diagram-block-macro]]
|
252
|
+
=== 图表块宏
|
253
|
+
|
254
|
+
图表扩展还可以以块宏的形式来使用。
|
255
|
+
|
256
|
+
.图表块宏的骨架
|
257
|
+
----
|
258
|
+
宏名::原文件名[生成的文件扩展名] // <1> <2> <3>
|
259
|
+
----
|
260
|
+
<1> 宏名和以块形式的块名相同。
|
261
|
+
<2> 原文件名指明包含图表源代码的外部文件。
|
262
|
+
<3> 第一个可选的属性指明用于生成图表的文件扩展名(也就是 `format` )
|
263
|
+
|
264
|
+
源文件的名字是相对正在处理的文件的位置的相对路径。
|
265
|
+
// When the source file name is a relative path it is resolved with respect to the location of the document being processed. 怎么翻译?
|
266
|
+
|
267
|
+
[[image-output-location]]
|
268
|
+
=== 图表输出位置
|
269
|
+
|
270
|
+
当 Asciidoctor Diagram 将图片写入磁盘时,它将根据如下选项依次来决定将文件写入到何处。
|
271
|
+
|
272
|
+
. `\{imagesoutdir\}` 如果 `imagesoutdir` 属性被指明
|
273
|
+
. `\{outdir\}/\{imagesdir\}` 如果 `outdir` 属性被指明
|
274
|
+
. `\{to_dir\}/\{imagesdir\}` 如果 `to_dir` 属性被指明
|
275
|
+
. `\{base_dir\}/\{imagesdir\}`
|
276
|
+
|
277
|
+
[[specifying-diagram-generator-paths]]
|
278
|
+
=== 指定图表输出路径
|
279
|
+
|
280
|
+
Asciidoctor Diagram 依赖外部工具来生成图片。
|
281
|
+
大多数情况下,它会自动从 `PATH` 环境变量指定的每一个路径中查找定位有特定可执行的工具。
|
282
|
+
// In most cases it will locate these tools automatically for you by looking for specific executables in each directory in the `PATH` environment variable.
|
283
|
+
如果你安装的工具不在 `PATH` 指明的路径中,你可以通过手动指明相关属性来覆盖工具的定位位置。
|
284
|
+
下面的表格指明每一个图表类型必须依赖的工具,工具被安装的位置和用于覆盖默认位置的文档属性。
|
285
|
+
|
286
|
+
[cols=">,2*<",options="header"]
|
287
|
+
|===
|
288
|
+
|Diagram Type |Tool |Attribute
|
289
|
+
|actdiag |{uri-actdiag}[ActDiag] |`actdiag`
|
290
|
+
|blockdiag |{uri-blockdiag}[BlockDiag] |`blockdiag`
|
291
|
+
|ditaa |{uri-java}[Java] |`java`
|
292
|
+
|graphviz |{uri-graphviz}[GraphViz] |`dot` 或 `graphvizdot`
|
293
|
+
|meme |{uri-imagemagick}[ImageMagick] |`convert` 和 `identify`
|
294
|
+
|mermaid |{uri-mermaid}[Mermaid] |`mermaid`
|
295
|
+
|nwdiag |{uri-nwdiag}[NwDiag] |`nwdiag`
|
296
|
+
|packetdiag |{uri-nwdiag}[NwDiag] |`packetdiag`
|
297
|
+
|plantuml |{uri-java}[Java] |`java`
|
298
|
+
|rackdiag |{uri-nwdiag}[NwDiag] |`rackdiag`
|
299
|
+
|seqdiag |{uri-seqdiag}[SeqDiag] |`seqdiag`
|
300
|
+
|shaape |{uri-shaape}[Shaape] |`shaape`
|
301
|
+
.2+|wavedrom |{uri-wavedromeditor}[WaveDrom Editor] |`wavedrom`
|
302
|
+
|{uri-wavedromcli}[WaveDrom CLI] 和 {uri-phantomjs}[PhantomJS] |`wavedrom` 和 `phantomjs`
|
303
|
+
|===
|
304
|
+
|
305
|
+
举例说明一下,假如你将 `actdiag` 安装在 `/home/me/actdiag/bin` 下,这路径不在 `PATH` 范围内,则你可以在命令行中指明它的位置:
|
306
|
+
|
307
|
+
$ asciidoctor -a actdiag=/home/me/actdiag/bin/actdiag -r asciidoctor-diagram sample.adoc
|
308
|
+
|
309
|
+
[[meme]]
|
310
|
+
=== Meme 扩展
|
311
|
+
|
312
|
+
meme 扩展提供了一个基本的 '`Advice Animal`' 风格的图片生成器。
|
313
|
+
使用一个例子就能非常方便地解释它的用法。
|
314
|
+
|
315
|
+
----
|
316
|
+
meme::yunoguy.jpg[Doc writers,Y U NO \\ AsciiDoc]
|
317
|
+
----
|
318
|
+
|
319
|
+
宏块的目的是告诉扩展使用哪些图像作为背景。
|
320
|
+
// The target of the block macro tells the extension which image to use as background.
|
321
|
+
头两个位置的属性是 `top` 和 `bottom`,用于标题的顶部和底部。
|
322
|
+
出现在 `\\` 周围的空白符将被解释为换行符。
|
323
|
+
|
324
|
+
块宏海支持如下的命名熟悉:
|
325
|
+
|
326
|
+
. `fillColor`:文字的填充颜色。默认为 `white`。
|
327
|
+
. `strokeColor`:文本的轮廓颜色。默认为 `black`。
|
328
|
+
. `strokeWidth`:文本轮廓的宽度。默认为 `2`。
|
329
|
+
. `font`: 文本的字体外观。默认为 `Impact`。
|
330
|
+
. `options`:逗号分隔的标识列表,用于修改图片的渲染。目前只支持 `noupcase`, 它可以禁用大写的标签。
|
331
|
+
// . `options`: a comma separate list of flags that modify the image rendering. Currently only `noupcase` is supported which disable upper casing the labels.
|
332
|
+
. `target` (第三位可选参数):生成文件的文件名。如果没有指定,则将会使用自动生成的文件名。
|
333
|
+
. `format` (第四位可选参数):生成图片的格式。meme 扩展支持 `png` 和 `gif`。、
|