asciidoctor-diagram 2.0.2 → 2.0.4
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 +25 -0
- data/README.adoc +13 -4
- data/lib/asciidoctor-diagram.rb +3 -0
- data/lib/asciidoctor-diagram/a2s/converter.rb +10 -6
- data/lib/asciidoctor-diagram/blockdiag/converter.rb +1 -1
- data/lib/asciidoctor-diagram/bpmn/converter.rb +3 -3
- data/lib/asciidoctor-diagram/diagram_converter.rb +5 -1
- data/lib/asciidoctor-diagram/diagram_processor.rb +64 -38
- data/lib/asciidoctor-diagram/diagram_source.rb +64 -17
- data/lib/asciidoctor-diagram/ditaa/converter.rb +6 -2
- data/lib/asciidoctor-diagram/dpic.rb +7 -0
- data/lib/asciidoctor-diagram/dpic/converter.rb +30 -0
- data/lib/asciidoctor-diagram/dpic/extension.rb +14 -0
- data/lib/asciidoctor-diagram/gnuplot/converter.rb +8 -8
- data/lib/asciidoctor-diagram/graphviz/converter.rb +2 -2
- data/lib/asciidoctor-diagram/http/converter.rb +25 -5
- data/lib/asciidoctor-diagram/http/server.rb +10 -5
- data/lib/asciidoctor-diagram/lilypond/converter.rb +2 -2
- data/lib/asciidoctor-diagram/meme/converter.rb +7 -7
- data/lib/asciidoctor-diagram/mermaid/converter.rb +16 -15
- data/lib/asciidoctor-diagram/msc/converter.rb +2 -2
- data/lib/asciidoctor-diagram/pikchr.rb +7 -0
- data/lib/asciidoctor-diagram/pikchr/converter.rb +26 -0
- data/lib/asciidoctor-diagram/pikchr/extension.rb +14 -0
- data/lib/asciidoctor-diagram/plantuml/converter.rb +3 -3
- data/lib/asciidoctor-diagram/smcat/converter.rb +3 -3
- data/lib/asciidoctor-diagram/svgbob/converter.rb +2 -2
- data/lib/asciidoctor-diagram/symbolator.rb +7 -0
- data/lib/asciidoctor-diagram/symbolator/converter.rb +23 -0
- data/lib/asciidoctor-diagram/symbolator/extension.rb +14 -0
- data/lib/asciidoctor-diagram/syntrax/converter.rb +9 -6
- data/lib/asciidoctor-diagram/util/cli_generator.rb +18 -0
- data/lib/asciidoctor-diagram/util/gif.rb +2 -2
- data/lib/asciidoctor-diagram/util/pdf.rb +2 -2
- data/lib/asciidoctor-diagram/util/png.rb +2 -2
- data/lib/asciidoctor-diagram/util/svg.rb +46 -19
- data/lib/asciidoctor-diagram/vega/converter.rb +2 -2
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/spec/a2s_spec.rb +2 -140
- data/spec/blockdiag_spec.rb +2 -200
- data/spec/bpmn_spec.rb +52 -92
- data/spec/bytefield_spec.rb +2 -140
- data/spec/ditaa_spec.rb +5 -143
- data/spec/dpic_spec.rb +19 -0
- data/spec/erd_spec.rb +2 -199
- data/spec/gnuplot_spec.rb +2 -255
- data/spec/graphviz_spec.rb +6 -145
- data/spec/lilypond_spec.rb +2 -140
- data/spec/mermaid_spec.rb +2 -199
- data/spec/msc_spec.rb +2 -199
- data/spec/nomnoml_spec.rb +4 -142
- data/spec/pikchr_spec.rb +51 -0
- data/spec/plantuml_spec.rb +6 -578
- data/spec/shaape_spec.rb +9 -221
- data/spec/shared_examples.rb +552 -0
- data/spec/smcat_spec.rb +2 -140
- data/spec/svgbob_spec.rb +2 -140
- data/spec/symbolator_spec.rb +23 -0
- data/spec/syntrax_spec.rb +5 -215
- data/spec/test_helper.rb +1 -22
- data/spec/tikz_spec.rb +4 -24
- data/spec/umlet_spec.rb +2 -58
- data/spec/vega_spec.rb +4 -117
- data/spec/wavedrom_spec.rb +2 -199
- metadata +20 -6
- data/spec/bpmn-example.xml +0 -44
data/spec/msc_spec.rb
CHANGED
@@ -25,206 +25,9 @@ msc {
|
|
25
25
|
eos
|
26
26
|
|
27
27
|
describe Asciidoctor::Diagram::MscBlockMacroProcessor, :broken_on_windows do
|
28
|
-
|
29
|
-
File.write('msc.txt', code)
|
30
|
-
|
31
|
-
doc = <<-eos
|
32
|
-
= Hello, Msc!
|
33
|
-
Doc Writer <doc@example.com>
|
34
|
-
|
35
|
-
== First Section
|
36
|
-
|
37
|
-
msc::msc.txt[format="png"]
|
38
|
-
eos
|
39
|
-
|
40
|
-
d = load_asciidoc doc
|
41
|
-
expect(d).to_not be_nil
|
42
|
-
|
43
|
-
b = d.find { |bl| bl.context == :image }
|
44
|
-
expect(b).to_not be_nil
|
45
|
-
|
46
|
-
expect(b.content_model).to eq :empty
|
47
|
-
|
48
|
-
target = b.attributes['target']
|
49
|
-
expect(target).to_not be_nil
|
50
|
-
expect(target).to match(/\.png$/)
|
51
|
-
expect(File.exist?(target)).to be true
|
52
|
-
|
53
|
-
expect(b.attributes['width']).to_not be_nil
|
54
|
-
expect(b.attributes['height']).to_not be_nil
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should generate SVG images when format is set to 'svg'" do
|
58
|
-
File.write('msc.txt', code)
|
59
|
-
|
60
|
-
doc = <<-eos
|
61
|
-
= Hello, Msc!
|
62
|
-
Doc Writer <doc@example.com>
|
63
|
-
|
64
|
-
== First Section
|
65
|
-
|
66
|
-
msc::msc.txt[format="svg"]
|
67
|
-
eos
|
68
|
-
|
69
|
-
d = load_asciidoc doc
|
70
|
-
expect(d).to_not be_nil
|
71
|
-
|
72
|
-
b = d.find { |bl| bl.context == :image }
|
73
|
-
expect(b).to_not be_nil
|
74
|
-
|
75
|
-
expect(b.content_model).to eq :empty
|
76
|
-
|
77
|
-
target = b.attributes['target']
|
78
|
-
expect(target).to_not be_nil
|
79
|
-
expect(target).to match(/\.svg/)
|
80
|
-
expect(File.exist?(target)).to be true
|
81
|
-
|
82
|
-
expect(b.attributes['width']).to_not be_nil
|
83
|
-
expect(b.attributes['height']).to_not be_nil
|
84
|
-
end
|
28
|
+
include_examples "block_macro", :msc, code, [:png, :svg]
|
85
29
|
end
|
86
30
|
|
87
31
|
describe Asciidoctor::Diagram::MscBlockProcessor, :broken_on_windows do
|
88
|
-
|
89
|
-
doc = <<-eos
|
90
|
-
= Hello, Msc!
|
91
|
-
Doc Writer <doc@example.com>
|
92
|
-
|
93
|
-
== First Section
|
94
|
-
|
95
|
-
[msc, format="png"]
|
96
|
-
----
|
97
|
-
#{code}
|
98
|
-
----
|
99
|
-
eos
|
100
|
-
|
101
|
-
d = load_asciidoc doc
|
102
|
-
expect(d).to_not be_nil
|
103
|
-
|
104
|
-
b = d.find { |bl| bl.context == :image }
|
105
|
-
expect(b).to_not be_nil
|
106
|
-
|
107
|
-
expect(b.content_model).to eq :empty
|
108
|
-
|
109
|
-
target = b.attributes['target']
|
110
|
-
expect(target).to_not be_nil
|
111
|
-
expect(target).to match(/\.png$/)
|
112
|
-
expect(File.exist?(target)).to be true
|
113
|
-
|
114
|
-
expect(b.attributes['width']).to_not be_nil
|
115
|
-
expect(b.attributes['height']).to_not be_nil
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should generate SVG images when format is set to 'svg'" do
|
119
|
-
doc = <<-eos
|
120
|
-
= Hello, Msc!
|
121
|
-
Doc Writer <doc@example.com>
|
122
|
-
|
123
|
-
== First Section
|
124
|
-
|
125
|
-
[msc, format="svg"]
|
126
|
-
----
|
127
|
-
#{code}
|
128
|
-
----
|
129
|
-
eos
|
130
|
-
|
131
|
-
d = load_asciidoc doc
|
132
|
-
expect(d).to_not be_nil
|
133
|
-
|
134
|
-
b = d.find { |bl| bl.context == :image }
|
135
|
-
expect(b).to_not be_nil
|
136
|
-
|
137
|
-
expect(b.content_model).to eq :empty
|
138
|
-
|
139
|
-
target = b.attributes['target']
|
140
|
-
expect(target).to_not be_nil
|
141
|
-
expect(target).to match(/\.svg/)
|
142
|
-
expect(File.exist?(target)).to be true
|
143
|
-
|
144
|
-
expect(b.attributes['width']).to_not be_nil
|
145
|
-
expect(b.attributes['height']).to_not be_nil
|
146
|
-
end
|
147
|
-
|
148
|
-
it "should raise an error when when format is set to an invalid value" do
|
149
|
-
doc = <<-eos
|
150
|
-
= Hello, Msc!
|
151
|
-
Doc Writer <doc@example.com>
|
152
|
-
|
153
|
-
== First Section
|
154
|
-
|
155
|
-
[msc, format="foobar"]
|
156
|
-
----
|
157
|
-
----
|
158
|
-
eos
|
159
|
-
|
160
|
-
expect { load_asciidoc doc }.to raise_error(/support.*format/i)
|
161
|
-
end
|
162
|
-
|
163
|
-
it "should not regenerate images when source has not changed" do
|
164
|
-
File.write('msc.txt', code)
|
165
|
-
|
166
|
-
doc = <<-eos
|
167
|
-
= Hello, Msc!
|
168
|
-
Doc Writer <doc@example.com>
|
169
|
-
|
170
|
-
== First Section
|
171
|
-
|
172
|
-
msc::msc.txt
|
173
|
-
|
174
|
-
[msc, format="png"]
|
175
|
-
----
|
176
|
-
#{code}
|
177
|
-
----
|
178
|
-
eos
|
179
|
-
|
180
|
-
d = load_asciidoc doc
|
181
|
-
b = d.find { |bl| bl.context == :image }
|
182
|
-
expect(b).to_not be_nil
|
183
|
-
target = b.attributes['target']
|
184
|
-
mtime1 = File.mtime(target)
|
185
|
-
|
186
|
-
sleep 1
|
187
|
-
|
188
|
-
d = load_asciidoc doc
|
189
|
-
|
190
|
-
mtime2 = File.mtime(target)
|
191
|
-
|
192
|
-
expect(mtime2).to eq mtime1
|
193
|
-
end
|
194
|
-
|
195
|
-
it "should handle two block macros with the same source" do
|
196
|
-
File.write('msc.txt', code)
|
197
|
-
|
198
|
-
doc = <<-eos
|
199
|
-
= Hello, Msc!
|
200
|
-
Doc Writer <doc@example.com>
|
201
|
-
|
202
|
-
== First Section
|
203
|
-
|
204
|
-
msc::msc.txt[]
|
205
|
-
msc::msc.txt[]
|
206
|
-
eos
|
207
|
-
|
208
|
-
load_asciidoc doc
|
209
|
-
expect(File.exist?('msc.png')).to be true
|
210
|
-
end
|
211
|
-
|
212
|
-
it "should respect target attribute in block macros" do
|
213
|
-
File.write('msc.txt', code)
|
214
|
-
|
215
|
-
doc = <<-eos
|
216
|
-
= Hello, Msc!
|
217
|
-
Doc Writer <doc@example.com>
|
218
|
-
|
219
|
-
== First Section
|
220
|
-
|
221
|
-
msc::msc.txt["foobar"]
|
222
|
-
msc::msc.txt["foobaz"]
|
223
|
-
eos
|
224
|
-
|
225
|
-
load_asciidoc doc
|
226
|
-
expect(File.exist?('foobar.png')).to be true
|
227
|
-
expect(File.exist?('foobaz.png')).to be true
|
228
|
-
expect(File.exist?('msc.png')).to be false
|
229
|
-
end
|
32
|
+
include_examples "block", :msc, code, [:png, :svg]
|
230
33
|
end
|
data/spec/nomnoml_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
3
|
code = <<-eos
|
4
|
-
[Pirate
|
4
|
+
[Pirate
|
5
5
|
[beard]--[parrot]
|
6
6
|
[beard]-:>[foul mouth]
|
7
7
|
]
|
@@ -11,7 +11,7 @@ code = <<-eos
|
|
11
11
|
[jollyness]->[Pirate]
|
12
12
|
[jollyness]->[rum]
|
13
13
|
[jollyness]->[singing]
|
14
|
-
[Pirate]-> *[rum
|
14
|
+
[Pirate]-> *[rum]
|
15
15
|
[Pirate]->[singing]
|
16
16
|
[singing]<->[rum]
|
17
17
|
|
@@ -24,147 +24,9 @@ code = <<-eos
|
|
24
24
|
eos
|
25
25
|
|
26
26
|
describe Asciidoctor::Diagram::NomnomlBlockMacroProcessor do
|
27
|
-
|
28
|
-
File.write('nomnoml.txt', code)
|
29
|
-
|
30
|
-
doc = <<-eos
|
31
|
-
= Hello, Nomnoml!
|
32
|
-
Doc Writer <doc@example.com>
|
33
|
-
|
34
|
-
== First Section
|
35
|
-
|
36
|
-
nomnoml::nomnoml.txt[format="svg"]
|
37
|
-
eos
|
38
|
-
|
39
|
-
d = load_asciidoc doc
|
40
|
-
expect(d).to_not be_nil
|
41
|
-
|
42
|
-
b = d.find { |bl| bl.context == :image }
|
43
|
-
expect(b).to_not be_nil
|
44
|
-
|
45
|
-
expect(b.content_model).to eq :empty
|
46
|
-
|
47
|
-
target = b.attributes['target']
|
48
|
-
expect(target).to_not be_nil
|
49
|
-
expect(target).to match(/\.svg/)
|
50
|
-
expect(File.exist?(target)).to be true
|
51
|
-
|
52
|
-
expect(b.attributes['width']).to_not be_nil
|
53
|
-
expect(b.attributes['height']).to_not be_nil
|
54
|
-
end
|
27
|
+
include_examples "block_macro", :nomnoml, code, [:svg]
|
55
28
|
end
|
56
29
|
|
57
30
|
describe Asciidoctor::Diagram::NomnomlBlockProcessor, :broken_on_windows do
|
58
|
-
|
59
|
-
doc = <<-eos
|
60
|
-
= Hello, Nomnoml!
|
61
|
-
Doc Writer <doc@example.com>
|
62
|
-
|
63
|
-
== First Section
|
64
|
-
|
65
|
-
[nomnoml, format="svg"]
|
66
|
-
----
|
67
|
-
#{code}
|
68
|
-
----
|
69
|
-
eos
|
70
|
-
|
71
|
-
d = load_asciidoc doc
|
72
|
-
expect(d).to_not be_nil
|
73
|
-
|
74
|
-
b = d.find { |bl| bl.context == :image }
|
75
|
-
expect(b).to_not be_nil
|
76
|
-
|
77
|
-
expect(b.content_model).to eq :empty
|
78
|
-
|
79
|
-
target = b.attributes['target']
|
80
|
-
expect(target).to_not be_nil
|
81
|
-
expect(target).to match(/\.svg/)
|
82
|
-
expect(File.exist?(target)).to be true
|
83
|
-
|
84
|
-
expect(b.attributes['width']).to_not be_nil
|
85
|
-
expect(b.attributes['height']).to_not be_nil
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should raise an error when when format is set to an invalid value" do
|
89
|
-
doc = <<-eos
|
90
|
-
= Hello, Nomnoml!
|
91
|
-
Doc Writer <doc@example.com>
|
92
|
-
|
93
|
-
== First Section
|
94
|
-
|
95
|
-
[nomnoml, format="foobar"]
|
96
|
-
----
|
97
|
-
----
|
98
|
-
eos
|
99
|
-
|
100
|
-
expect { load_asciidoc doc }.to raise_error(/support.*format/i)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should not regenerate images when source has not changed" do
|
104
|
-
File.write('nomnoml.txt', code)
|
105
|
-
|
106
|
-
doc = <<-eos
|
107
|
-
= Hello, Nomnoml!
|
108
|
-
Doc Writer <doc@example.com>
|
109
|
-
|
110
|
-
== First Section
|
111
|
-
|
112
|
-
nomnoml::nomnoml.txt
|
113
|
-
|
114
|
-
[nomnoml, format="svg"]
|
115
|
-
----
|
116
|
-
#{code}
|
117
|
-
----
|
118
|
-
eos
|
119
|
-
|
120
|
-
d = load_asciidoc doc
|
121
|
-
b = d.find { |bl| bl.context == :image }
|
122
|
-
expect(b).to_not be_nil
|
123
|
-
target = b.attributes['target']
|
124
|
-
mtime1 = File.mtime(target)
|
125
|
-
|
126
|
-
sleep 1
|
127
|
-
|
128
|
-
d = load_asciidoc doc
|
129
|
-
|
130
|
-
mtime2 = File.mtime(target)
|
131
|
-
|
132
|
-
expect(mtime2).to eq mtime1
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should handle two block macros with the same source" do
|
136
|
-
File.write('nomnoml.txt', code)
|
137
|
-
|
138
|
-
doc = <<-eos
|
139
|
-
= Hello, Nomnoml!
|
140
|
-
Doc Writer <doc@example.com>
|
141
|
-
|
142
|
-
== First Section
|
143
|
-
|
144
|
-
nomnoml::nomnoml.txt[]
|
145
|
-
nomnoml::nomnoml.txt[]
|
146
|
-
eos
|
147
|
-
|
148
|
-
load_asciidoc doc
|
149
|
-
expect(File.exist?('nomnoml.svg')).to be true
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should respect target attribute in block macros" do
|
153
|
-
File.write('nomnoml.txt', code)
|
154
|
-
|
155
|
-
doc = <<-eos
|
156
|
-
= Hello, Nomnoml!
|
157
|
-
Doc Writer <doc@example.com>
|
158
|
-
|
159
|
-
== First Section
|
160
|
-
|
161
|
-
nomnoml::nomnoml.txt["foobar"]
|
162
|
-
nomnoml::nomnoml.txt["foobaz"]
|
163
|
-
eos
|
164
|
-
|
165
|
-
load_asciidoc doc
|
166
|
-
expect(File.exist?('foobar.svg')).to be true
|
167
|
-
expect(File.exist?('foobaz.svg')).to be true
|
168
|
-
expect(File.exist?('nomnoml.svg')).to be false
|
169
|
-
end
|
31
|
+
include_examples "block", :nomnoml, code, [:svg]
|
170
32
|
end
|
data/spec/pikchr_spec.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
code = <<-eos
|
4
|
+
# Change from the original:
|
5
|
+
# * Expand the macro by hand, as Pikchr does not support
|
6
|
+
# macros
|
7
|
+
#
|
8
|
+
#define ndblock {
|
9
|
+
# box wid boxwid/2 ht boxht/2
|
10
|
+
# down; box same with .t at bottom of last box; box same
|
11
|
+
#}
|
12
|
+
boxht = .2; boxwid = .3; circlerad = .3; dx = 0.05
|
13
|
+
down; box; box; box; box ht 3*boxht "." "." "."
|
14
|
+
L: box; box; box invis wid 2*boxwid "hashtab:" with .e at 1st box .w
|
15
|
+
right
|
16
|
+
Start: box wid .5 with .sw at 1st box.ne + (.4,.2) "..."
|
17
|
+
N1: box wid .2 "n1"; D1: box wid .3 "d1"
|
18
|
+
N3: box wid .4 "n3"; D3: box wid .3 "d3"
|
19
|
+
box wid .4 "..."
|
20
|
+
N2: box wid .5 "n2"; D2: box wid .2 "d2"
|
21
|
+
arrow right from 2nd box
|
22
|
+
#ndblock
|
23
|
+
box wid boxwid/2 ht boxht/2
|
24
|
+
down; box same with .t at bottom of last box; box same
|
25
|
+
spline -> right .2 from 3rd last box then to N1.sw + (dx,0)
|
26
|
+
spline -> right .3 from 2nd last box then to D1.sw + (dx,0)
|
27
|
+
arrow right from last box
|
28
|
+
#ndblock
|
29
|
+
box wid boxwid/2 ht boxht/2
|
30
|
+
down; box same with .t at bottom of last box; box same
|
31
|
+
spline -> right .2 from 3rd last box to N2.sw-(dx,.2) to N2.sw+(dx,0)
|
32
|
+
spline -> right .3 from 2nd last box to D2.sw-(dx,.2) to D2.sw+(dx,0)
|
33
|
+
arrow right 2*linewid from L
|
34
|
+
#ndblock
|
35
|
+
box wid boxwid/2 ht boxht/2
|
36
|
+
down; box same with .t at bottom of last box; box same
|
37
|
+
spline -> right .2 from 3rd last box to N3.sw + (dx,0)
|
38
|
+
spline -> right .3 from 2nd last box to D3.sw + (dx,0)
|
39
|
+
circlerad = .3
|
40
|
+
circle invis "ndblock" at last box.e + (1.2,.2)
|
41
|
+
arrow dashed from last circle.w to 5/8<last circle.w,2nd last box> chop
|
42
|
+
box invis wid 2*boxwid "ndtable:" with .e at Start.w
|
43
|
+
eos
|
44
|
+
|
45
|
+
describe Asciidoctor::Diagram::PikchrBlockMacroProcessor, :broken_on_travis, :broken_on_windows do
|
46
|
+
include_examples "block_macro", :pikchr, code, [:svg]
|
47
|
+
end
|
48
|
+
|
49
|
+
describe Asciidoctor::Diagram::ErdBlockProcessor, :broken_on_travis, :broken_on_windows do
|
50
|
+
include_examples "block", :pikchr, code, [:svg]
|
51
|
+
end
|
data/spec/plantuml_spec.rb
CHANGED
@@ -1,77 +1,14 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
it "should generate PNG images when format is set to 'png'" do
|
5
|
-
code = <<-eos
|
6
|
-
User -> (Start)
|
7
|
-
User --> (Use the application) : Label
|
8
|
-
|
9
|
-
:Main Admin: ---> (Use the application) : Another label
|
10
|
-
eos
|
11
|
-
|
12
|
-
File.write('plantuml.txt', code)
|
13
|
-
|
14
|
-
doc = <<-eos
|
15
|
-
= Hello, PlantUML!
|
16
|
-
Doc Writer <doc@example.com>
|
17
|
-
|
18
|
-
== First Section
|
19
|
-
|
20
|
-
plantuml::plantuml.txt[format="png"]
|
21
|
-
eos
|
22
|
-
|
23
|
-
d = load_asciidoc doc
|
24
|
-
expect(d).to_not be_nil
|
25
|
-
|
26
|
-
b = d.find { |bl| bl.context == :image }
|
27
|
-
expect(b).to_not be_nil
|
28
|
-
|
29
|
-
expect(b.content_model).to eq :empty
|
30
|
-
|
31
|
-
target = b.attributes['target']
|
32
|
-
expect(target).to_not be_nil
|
33
|
-
expect(target).to match(/\.png$/)
|
34
|
-
expect(File.exist?(target)).to be true
|
35
|
-
|
36
|
-
expect(b.attributes['width']).to_not be_nil
|
37
|
-
expect(b.attributes['height']).to_not be_nil
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should generate PNG images when format is set to 'png'" do
|
41
|
-
code = <<-eos
|
3
|
+
code = <<-eos
|
42
4
|
User -> (Start)
|
43
5
|
User --> (Use the application) : Label
|
44
6
|
|
45
7
|
:Main Admin: ---> (Use the application) : Another label
|
46
|
-
|
47
|
-
|
48
|
-
File.write('plantuml.txt', code)
|
49
|
-
|
50
|
-
doc = <<-eos
|
51
|
-
= Hello, PlantUML!
|
52
|
-
Doc Writer <doc@example.com>
|
53
|
-
|
54
|
-
== First Section
|
55
|
-
|
56
|
-
plantuml::plantuml.txt[format="png"]
|
57
|
-
eos
|
8
|
+
eos
|
58
9
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
b = d.find { |bl| bl.context == :image }
|
63
|
-
expect(b).to_not be_nil
|
64
|
-
|
65
|
-
expect(b.content_model).to eq :empty
|
66
|
-
|
67
|
-
target = b.attributes['target']
|
68
|
-
expect(target).to_not be_nil
|
69
|
-
expect(target).to match(/\.png$/)
|
70
|
-
expect(File.exist?(target)).to be true
|
71
|
-
|
72
|
-
expect(b.attributes['width']).to_not be_nil
|
73
|
-
expect(b.attributes['height']).to_not be_nil
|
74
|
-
end
|
10
|
+
describe Asciidoctor::Diagram::PlantUmlBlockMacroProcessor do
|
11
|
+
include_examples "block_macro", :plantuml, code, [:png, :svg, :txt]
|
75
12
|
|
76
13
|
it 'should support substitutions in diagram code' do
|
77
14
|
code = <<-eos
|
@@ -216,216 +153,10 @@ plantuml::dir/plantuml.txt[format="svg", subs=attributes+]
|
|
216
153
|
content = File.read(target, :encoding => Encoding::UTF_8)
|
217
154
|
expect(content).to_not include('!include')
|
218
155
|
end
|
219
|
-
|
220
|
-
it 'should generate blocks with figure captions' do
|
221
|
-
code = <<-eos
|
222
|
-
User -> (Start)
|
223
|
-
User --> (Use the application) : Label
|
224
|
-
|
225
|
-
:Main Admin: ---> (Use the application) : Another label
|
226
|
-
eos
|
227
|
-
|
228
|
-
File.write('plantuml.txt', code)
|
229
|
-
|
230
|
-
doc = <<-eos
|
231
|
-
= Hello, PlantUML!
|
232
|
-
Doc Writer <doc@example.com>
|
233
|
-
|
234
|
-
== First Section
|
235
|
-
|
236
|
-
.This is a UML diagram
|
237
|
-
plantuml::plantuml.txt[format="png"]
|
238
|
-
eos
|
239
|
-
|
240
|
-
d = load_asciidoc doc
|
241
|
-
expect(d).to_not be_nil
|
242
|
-
|
243
|
-
b = d.find { |bl| bl.context == :image }
|
244
|
-
expect(b).to_not be_nil
|
245
|
-
|
246
|
-
expect(b.caption).to match(/Figure \d+/)
|
247
|
-
end
|
248
156
|
end
|
249
157
|
|
250
158
|
describe Asciidoctor::Diagram::PlantUmlBlockProcessor do
|
251
|
-
|
252
|
-
doc = <<-eos
|
253
|
-
= Hello, PlantUML!
|
254
|
-
Doc Writer <doc@example.com>
|
255
|
-
|
256
|
-
== First Section
|
257
|
-
|
258
|
-
[plantuml, format="png"]
|
259
|
-
----
|
260
|
-
User -> (Start)
|
261
|
-
User --> (Use the application) : Label
|
262
|
-
|
263
|
-
:Main Admin: ---> (Use the application) : Another label
|
264
|
-
----
|
265
|
-
eos
|
266
|
-
|
267
|
-
d = load_asciidoc doc
|
268
|
-
expect(d).to_not be_nil
|
269
|
-
|
270
|
-
b = d.find { |bl| bl.context == :image }
|
271
|
-
expect(b).to_not be_nil
|
272
|
-
|
273
|
-
expect(b.content_model).to eq :empty
|
274
|
-
|
275
|
-
target = b.attributes['target']
|
276
|
-
expect(target).to_not be_nil
|
277
|
-
expect(target).to match(/\.png$/)
|
278
|
-
expect(File.exist?(target)).to be true
|
279
|
-
|
280
|
-
expect(b.attributes['width']).to_not be_nil
|
281
|
-
expect(b.attributes['height']).to_not be_nil
|
282
|
-
end
|
283
|
-
|
284
|
-
it "should generate SVG images when format is set to 'svg'" do
|
285
|
-
doc = <<-eos
|
286
|
-
= Hello, PlantUML!
|
287
|
-
Doc Writer <doc@example.com>
|
288
|
-
|
289
|
-
== First Section
|
290
|
-
|
291
|
-
[plantuml, format="svg"]
|
292
|
-
----
|
293
|
-
User -> (Start)
|
294
|
-
User --> (Use the application) : Label
|
295
|
-
|
296
|
-
:Main Admin: ---> (Use the application) : Another label
|
297
|
-
----
|
298
|
-
eos
|
299
|
-
|
300
|
-
d = load_asciidoc doc
|
301
|
-
expect(d).to_not be_nil
|
302
|
-
|
303
|
-
b = d.find { |bl| bl.context == :image }
|
304
|
-
expect(b).to_not be_nil
|
305
|
-
|
306
|
-
expect(b.content_model).to eq :empty
|
307
|
-
|
308
|
-
target = b.attributes['target']
|
309
|
-
expect(target).to_not be_nil
|
310
|
-
expect(target).to match(/\.svg/)
|
311
|
-
expect(File.exist?(target)).to be true
|
312
|
-
|
313
|
-
expect(b.attributes['width']).to_not be_nil
|
314
|
-
expect(b.attributes['height']).to_not be_nil
|
315
|
-
end
|
316
|
-
|
317
|
-
it "should respect the svg-type attribute when format is set to 'svg'" do
|
318
|
-
doc = <<-eos
|
319
|
-
= Hello, PlantUML!
|
320
|
-
Doc Writer <doc@example.com>
|
321
|
-
|
322
|
-
== First Section
|
323
|
-
|
324
|
-
[plantuml, format="svg", svg-type="inline"]
|
325
|
-
----
|
326
|
-
User -> (Start)
|
327
|
-
User --> (Use the application) : Label
|
328
|
-
|
329
|
-
:Main Admin: ---> (Use the application) : Another label
|
330
|
-
----
|
331
|
-
eos
|
332
|
-
|
333
|
-
d = load_asciidoc doc
|
334
|
-
expect(d).to_not be_nil
|
335
|
-
|
336
|
-
b = d.find { |bl| bl.context == :image }
|
337
|
-
expect(b).to_not be_nil
|
338
|
-
|
339
|
-
expect(b.content_model).to eq :empty
|
340
|
-
|
341
|
-
target = b.attributes['target']
|
342
|
-
expect(target).to_not be_nil
|
343
|
-
expect(target).to match(/\.svg/)
|
344
|
-
expect(File.exist?(target)).to be true
|
345
|
-
|
346
|
-
expect(b.attributes['opts']).to eq('inline')
|
347
|
-
|
348
|
-
expect(b.attributes['width']).to_not be_nil
|
349
|
-
expect(b.attributes['height']).to_not be_nil
|
350
|
-
end
|
351
|
-
|
352
|
-
it "should respect the diagram-svg-type attribute when format is set to 'svg'" do
|
353
|
-
doc = <<-eos
|
354
|
-
= Hello, PlantUML!
|
355
|
-
:diagram-svg-type: inline
|
356
|
-
Doc Writer <doc@example.com>
|
357
|
-
|
358
|
-
== First Section
|
359
|
-
|
360
|
-
[plantuml, format="svg"]
|
361
|
-
----
|
362
|
-
User -> (Start)
|
363
|
-
User --> (Use the application) : Label
|
364
|
-
|
365
|
-
:Main Admin: ---> (Use the application) : Another label
|
366
|
-
----
|
367
|
-
eos
|
368
|
-
|
369
|
-
d = load_asciidoc doc
|
370
|
-
expect(d).to_not be_nil
|
371
|
-
|
372
|
-
b = d.find { |bl| bl.context == :image }
|
373
|
-
expect(b).to_not be_nil
|
374
|
-
|
375
|
-
expect(b.content_model).to eq :empty
|
376
|
-
|
377
|
-
target = b.attributes['target']
|
378
|
-
expect(target).to_not be_nil
|
379
|
-
expect(target).to match(/\.svg/)
|
380
|
-
expect(File.exist?(target)).to be true
|
381
|
-
|
382
|
-
expect(b.attributes['opts']).to eq('inline')
|
383
|
-
|
384
|
-
expect(b.attributes['width']).to_not be_nil
|
385
|
-
expect(b.attributes['height']).to_not be_nil
|
386
|
-
end
|
387
|
-
|
388
|
-
it "should generate literal blocks when format is set to 'txt'" do
|
389
|
-
doc = <<-eos
|
390
|
-
= Hello, PlantUML!
|
391
|
-
Doc Writer <doc@example.com>
|
392
|
-
|
393
|
-
== First Section
|
394
|
-
|
395
|
-
[plantuml, format="txt"]
|
396
|
-
----
|
397
|
-
User -> (Start)
|
398
|
-
User --> (Use the application) : Label
|
399
|
-
|
400
|
-
:Main Admin: ---> (Use the application) : Another label
|
401
|
-
----
|
402
|
-
eos
|
403
|
-
|
404
|
-
d = load_asciidoc doc
|
405
|
-
expect(d).to_not be_nil
|
406
|
-
|
407
|
-
b = d.find { |bl| bl.context == :literal }
|
408
|
-
expect(b).to_not be_nil
|
409
|
-
|
410
|
-
expect(b.content_model).to eq :verbatim
|
411
|
-
|
412
|
-
expect(b.attributes['target']).to be_nil
|
413
|
-
end
|
414
|
-
|
415
|
-
it 'should raise an error when when format is set to an invalid value' do
|
416
|
-
doc = <<-eos
|
417
|
-
= Hello, PlantUML!
|
418
|
-
Doc Writer <doc@example.com>
|
419
|
-
|
420
|
-
== First Section
|
421
|
-
|
422
|
-
[plantuml, format="foobar"]
|
423
|
-
----
|
424
|
-
----
|
425
|
-
eos
|
426
|
-
|
427
|
-
expect { load_asciidoc doc }.to raise_error(/support.*format/i)
|
428
|
-
end
|
159
|
+
include_examples "block", :plantuml, code, [:png, :svg, :txt]
|
429
160
|
|
430
161
|
it 'should use plantuml configuration when specified as a document attribute' do
|
431
162
|
doc = <<-eos
|
@@ -460,275 +191,7 @@ skinparam ArrowColor #DEADBE
|
|
460
191
|
expect(File.exist?(target)).to be true
|
461
192
|
|
462
193
|
svg = File.read(target, :encoding => Encoding::UTF_8)
|
463
|
-
expect(svg).to match(/<
|
464
|
-
end
|
465
|
-
|
466
|
-
it 'should not regenerate images when source has not changed' do
|
467
|
-
code = <<-eos
|
468
|
-
User -> (Start)
|
469
|
-
User --> (Use the application) : Label
|
470
|
-
|
471
|
-
:Main Admin: ---> (Use the application) : Another label
|
472
|
-
eos
|
473
|
-
|
474
|
-
File.write('plantuml.txt', code)
|
475
|
-
|
476
|
-
doc = <<-eos
|
477
|
-
= Hello, PlantUML!
|
478
|
-
Doc Writer <doc@example.com>
|
479
|
-
|
480
|
-
== First Section
|
481
|
-
|
482
|
-
plantuml::plantuml.txt
|
483
|
-
|
484
|
-
[plantuml, format="png"]
|
485
|
-
----
|
486
|
-
actor Foo1
|
487
|
-
boundary Foo2
|
488
|
-
Foo1 -> Foo2 : To boundary
|
489
|
-
----
|
490
|
-
eos
|
491
|
-
|
492
|
-
d = load_asciidoc doc
|
493
|
-
b = d.find { |bl| bl.context == :image }
|
494
|
-
target = b.attributes['target']
|
495
|
-
mtime1 = File.mtime(target)
|
496
|
-
|
497
|
-
sleep 1
|
498
|
-
|
499
|
-
d = load_asciidoc doc
|
500
|
-
|
501
|
-
mtime2 = File.mtime(target)
|
502
|
-
|
503
|
-
expect(mtime2).to eq mtime1
|
504
|
-
end
|
505
|
-
|
506
|
-
it 'should handle two block macros with the same source' do
|
507
|
-
code = <<-eos
|
508
|
-
User -> (Start)
|
509
|
-
User --> (Use the application) : Label
|
510
|
-
|
511
|
-
:Main Admin: ---> (Use the application) : Another label
|
512
|
-
eos
|
513
|
-
|
514
|
-
File.write('plantuml.txt', code)
|
515
|
-
|
516
|
-
doc = <<-eos
|
517
|
-
= Hello, PlantUML!
|
518
|
-
Doc Writer <doc@example.com>
|
519
|
-
|
520
|
-
== First Section
|
521
|
-
|
522
|
-
plantuml::plantuml.txt[]
|
523
|
-
plantuml::plantuml.txt[]
|
524
|
-
eos
|
525
|
-
|
526
|
-
load_asciidoc doc
|
527
|
-
expect(File.exist?('plantuml.png')).to be true
|
528
|
-
end
|
529
|
-
|
530
|
-
it 'should respect target attribute in block macros' do
|
531
|
-
code = <<-eos
|
532
|
-
User -> (Start)
|
533
|
-
User --> (Use the application) : Label
|
534
|
-
|
535
|
-
:Main Admin: ---> (Use the application) : Another label
|
536
|
-
eos
|
537
|
-
|
538
|
-
File.write('plantuml.txt', code)
|
539
|
-
|
540
|
-
doc = <<-eos
|
541
|
-
= Hello, PlantUML!
|
542
|
-
Doc Writer <doc@example.com>
|
543
|
-
|
544
|
-
== First Section
|
545
|
-
|
546
|
-
plantuml::plantuml.txt["foobar"]
|
547
|
-
plantuml::plantuml.txt["foobaz"]
|
548
|
-
eos
|
549
|
-
|
550
|
-
load_asciidoc doc
|
551
|
-
expect(File.exist?('foobar.png')).to be true
|
552
|
-
expect(File.exist?('foobaz.png')).to be true
|
553
|
-
expect(File.exist?('plantuml.png')).to be false
|
554
|
-
end
|
555
|
-
|
556
|
-
it 'should respect target attribute values with relative paths in block macros' do
|
557
|
-
code = <<-eos
|
558
|
-
User -> (Start)
|
559
|
-
User --> (Use the application) : Label
|
560
|
-
|
561
|
-
:Main Admin: ---> (Use the application) : Another label
|
562
|
-
eos
|
563
|
-
|
564
|
-
File.write('plantuml.txt', code)
|
565
|
-
|
566
|
-
doc = <<-eos
|
567
|
-
= Hello, PlantUML!
|
568
|
-
Doc Writer <doc@example.com>
|
569
|
-
|
570
|
-
== First Section
|
571
|
-
|
572
|
-
plantuml::plantuml.txt["test/foobar"]
|
573
|
-
plantuml::plantuml.txt["test2/foobaz"]
|
574
|
-
eos
|
575
|
-
|
576
|
-
load_asciidoc doc
|
577
|
-
expect(File.exist?('test/foobar.png')).to be true
|
578
|
-
expect(File.exist?('test2/foobaz.png')).to be true
|
579
|
-
expect(File.exist?('plantuml.png')).to be false
|
580
|
-
end
|
581
|
-
|
582
|
-
it 'should write files to outdir if set' do
|
583
|
-
doc = <<-eos
|
584
|
-
= Hello, PlantUML!
|
585
|
-
Doc Writer <doc@example.com>
|
586
|
-
|
587
|
-
== First Section
|
588
|
-
|
589
|
-
[plantuml, format="svg"]
|
590
|
-
----
|
591
|
-
actor Foo1
|
592
|
-
boundary Foo2
|
593
|
-
Foo1 -> Foo2 : To boundary
|
594
|
-
----
|
595
|
-
eos
|
596
|
-
|
597
|
-
d = load_asciidoc doc, {:attributes => {'outdir' => 'foo'}}
|
598
|
-
b = d.find { |bl| bl.context == :image }
|
599
|
-
|
600
|
-
target = b.attributes['target']
|
601
|
-
expect(target).to_not be_nil
|
602
|
-
expect(File.exist?(target)).to be false
|
603
|
-
expect(File.exist?(File.expand_path(target, 'foo'))).to be true
|
604
|
-
end
|
605
|
-
|
606
|
-
it 'should write files to to_dir if set' do
|
607
|
-
doc = <<-eos
|
608
|
-
= Hello, PlantUML!
|
609
|
-
Doc Writer <doc@example.com>
|
610
|
-
|
611
|
-
== First Section
|
612
|
-
|
613
|
-
[plantuml, format="svg"]
|
614
|
-
----
|
615
|
-
actor Foo1
|
616
|
-
boundary Foo2
|
617
|
-
Foo1 -> Foo2 : To boundary
|
618
|
-
----
|
619
|
-
eos
|
620
|
-
|
621
|
-
d = load_asciidoc doc, {:to_dir => 'foo'}
|
622
|
-
b = d.find { |bl| bl.context == :image }
|
623
|
-
|
624
|
-
target = b.attributes['target']
|
625
|
-
expect(target).to_not be_nil
|
626
|
-
expect(File.exist?(target)).to be false
|
627
|
-
expect(File.exist?(File.expand_path(target, 'foo'))).to be true
|
628
|
-
end
|
629
|
-
|
630
|
-
it 'should write files to to_dir if set when embedded in table' do
|
631
|
-
doc = <<-eos
|
632
|
-
= Hello, PlantUML!
|
633
|
-
Doc Writer <doc@example.com>
|
634
|
-
|
635
|
-
== First Section
|
636
|
-
|
637
|
-
|===
|
638
|
-
|Type | Example
|
639
|
-
|
640
|
-
|graphviz
|
641
|
-
a|
|
642
|
-
[plantuml, format="svg"]
|
643
|
-
----
|
644
|
-
actor Foo1
|
645
|
-
boundary Foo2
|
646
|
-
Foo1 -> Foo2 : To boundary
|
647
|
-
----
|
648
|
-
|===
|
649
|
-
eos
|
650
|
-
|
651
|
-
d = load_asciidoc doc, {:to_dir => 'foo'}
|
652
|
-
b = d.find { |bl| bl.context == :image }
|
653
|
-
|
654
|
-
target = b.attributes['target']
|
655
|
-
expect(target).to_not be_nil
|
656
|
-
expect(File.exist?(target)).to be false
|
657
|
-
expect(File.exist?(File.expand_path(target, 'foo'))).to be true
|
658
|
-
end
|
659
|
-
|
660
|
-
it 'should write files to imagesoutdir if set' do
|
661
|
-
doc = <<-eos
|
662
|
-
= Hello, PlantUML!
|
663
|
-
Doc Writer <doc@example.com>
|
664
|
-
|
665
|
-
== First Section
|
666
|
-
|
667
|
-
[plantuml, format="svg"]
|
668
|
-
----
|
669
|
-
actor Foo1
|
670
|
-
boundary Foo2
|
671
|
-
Foo1 -> Foo2 : To boundary
|
672
|
-
----
|
673
|
-
eos
|
674
|
-
|
675
|
-
d = load_asciidoc doc, {:attributes => {'imagesoutdir' => 'bar', 'outdir' => 'foo'}}
|
676
|
-
b = d.find { |bl| bl.context == :image }
|
677
|
-
|
678
|
-
target = b.attributes['target']
|
679
|
-
expect(target).to_not be_nil
|
680
|
-
expect(File.exist?(target)).to be false
|
681
|
-
expect(File.exist?(File.expand_path(target, 'bar'))).to be true
|
682
|
-
expect(File.exist?(File.expand_path(target, 'foo'))).to be false
|
683
|
-
end
|
684
|
-
|
685
|
-
it 'should omit width/height attributes when generating docbook' do
|
686
|
-
doc = <<-eos
|
687
|
-
= Hello, PlantUML!
|
688
|
-
Doc Writer <doc@example.com>
|
689
|
-
|
690
|
-
== First Section
|
691
|
-
|
692
|
-
[plantuml, format="png"]
|
693
|
-
----
|
694
|
-
User -> (Start)
|
695
|
-
----
|
696
|
-
eos
|
697
|
-
|
698
|
-
d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
|
699
|
-
expect(d).to_not be_nil
|
700
|
-
|
701
|
-
b = d.find { |bl| bl.context == :image }
|
702
|
-
expect(b).to_not be_nil
|
703
|
-
|
704
|
-
target = b.attributes['target']
|
705
|
-
expect(File.exist?(target)).to be true
|
706
|
-
|
707
|
-
expect(b.attributes['width']).to be_nil
|
708
|
-
expect(b.attributes['height']).to be_nil
|
709
|
-
end
|
710
|
-
|
711
|
-
it 'should generate blocks with figure captions' do
|
712
|
-
doc = <<-eos
|
713
|
-
= Hello, PlantUML!
|
714
|
-
Doc Writer <doc@example.com>
|
715
|
-
|
716
|
-
== First Section
|
717
|
-
|
718
|
-
.Caption for my UML diagram
|
719
|
-
[plantuml, format="png"]
|
720
|
-
----
|
721
|
-
User -> (Start)
|
722
|
-
----
|
723
|
-
eos
|
724
|
-
|
725
|
-
d = load_asciidoc doc
|
726
|
-
expect(d).to_not be_nil
|
727
|
-
|
728
|
-
b = d.find { |bl| bl.context == :image }
|
729
|
-
expect(b).to_not be_nil
|
730
|
-
|
731
|
-
expect(b.caption).to match(/Figure \d+/)
|
194
|
+
expect(svg).to match(/<[^<]+ fill=["']#DEADBE["']/)
|
732
195
|
end
|
733
196
|
|
734
197
|
it 'should support salt diagrams using salt block type' do
|
@@ -834,41 +297,6 @@ salt
|
|
834
297
|
expect(b.attributes['height']).to be_nil
|
835
298
|
end
|
836
299
|
|
837
|
-
it 'should support scaling diagrams' do
|
838
|
-
doc = <<-eos
|
839
|
-
= Hello, PlantUML!
|
840
|
-
Doc Writer <doc@example.com>
|
841
|
-
|
842
|
-
== First Section
|
843
|
-
|
844
|
-
[plantuml, format="png"]
|
845
|
-
----
|
846
|
-
A -> B
|
847
|
-
----
|
848
|
-
eos
|
849
|
-
|
850
|
-
scaled_doc = <<-eos
|
851
|
-
= Hello, PlantUML!
|
852
|
-
Doc Writer <doc@example.com>
|
853
|
-
|
854
|
-
== First Section
|
855
|
-
|
856
|
-
[plantuml, format="png", scale="1.5"]
|
857
|
-
----
|
858
|
-
A -> B
|
859
|
-
----
|
860
|
-
eos
|
861
|
-
|
862
|
-
d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
|
863
|
-
unscaled_image = d.find { |bl| bl.context == :image }
|
864
|
-
|
865
|
-
d = load_asciidoc scaled_doc, :attributes => {'backend' => 'html5'}
|
866
|
-
scaled_image = d.find { |bl| bl.context == :image }
|
867
|
-
|
868
|
-
expect(scaled_image.attributes['width']).to be_within(1).of(unscaled_image.attributes['width'] * 1.5)
|
869
|
-
expect(scaled_image.attributes['height']).to be_within(1).of(unscaled_image.attributes['height'] * 1.5)
|
870
|
-
end
|
871
|
-
|
872
300
|
it 'should handle embedded creole images correctly' do
|
873
301
|
creole_doc = <<-eos
|
874
302
|
= Hello, PlantUML!
|