asciidoctor-diagram 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.adoc +262 -7
- data/README.adoc +463 -40
- data/README_zh-CN.adoc +336 -0
- data/Rakefile +3 -7
- data/examples/features.adoc +2 -2
- data/images/asciidoctor-diagram-classes.png +0 -0
- data/images/asciidoctor-diagram-process.png +0 -0
- data/lib/asciidoctor-diagram/a2s/converter.rb +55 -0
- data/lib/asciidoctor-diagram/a2s/extension.rb +14 -0
- data/lib/asciidoctor-diagram/a2s.rb +7 -0
- data/lib/asciidoctor-diagram/blockdiag/converter.rb +37 -0
- data/lib/asciidoctor-diagram/blockdiag/extension.rb +11 -11
- data/lib/asciidoctor-diagram/blockdiag.rb +5 -4
- data/lib/asciidoctor-diagram/bpmn/converter.rb +62 -0
- data/lib/asciidoctor-diagram/bpmn/extension.rb +14 -0
- data/lib/asciidoctor-diagram/bpmn.rb +7 -0
- data/lib/asciidoctor-diagram/diagram_converter.rb +19 -0
- data/lib/asciidoctor-diagram/diagram_processor.rb +320 -0
- data/lib/asciidoctor-diagram/diagram_source.rb +275 -0
- data/lib/asciidoctor-diagram/ditaa/converter.rb +86 -0
- data/lib/asciidoctor-diagram/ditaa/extension.rb +6 -28
- data/lib/asciidoctor-diagram/ditaa.rb +3 -4
- data/lib/asciidoctor-diagram/erd/converter.rb +31 -0
- data/lib/asciidoctor-diagram/erd/extension.rb +14 -0
- data/lib/asciidoctor-diagram/erd.rb +7 -0
- data/lib/asciidoctor-diagram/gnuplot/converter.rb +63 -0
- data/lib/asciidoctor-diagram/gnuplot/extension.rb +14 -0
- data/lib/asciidoctor-diagram/gnuplot.rb +7 -0
- data/lib/asciidoctor-diagram/graphviz/converter.rb +32 -0
- data/lib/asciidoctor-diagram/graphviz/extension.rb +8 -10
- data/lib/asciidoctor-diagram/graphviz.rb +3 -4
- data/lib/asciidoctor-diagram/http/server.rb +127 -0
- data/lib/asciidoctor-diagram/lilypond/converter.rb +54 -0
- data/lib/asciidoctor-diagram/lilypond/extension.rb +14 -0
- data/lib/asciidoctor-diagram/lilypond.rb +7 -0
- data/lib/asciidoctor-diagram/meme/converter.rb +122 -0
- data/lib/asciidoctor-diagram/meme/extension.rb +28 -0
- data/lib/asciidoctor-diagram/meme.rb +6 -0
- data/lib/asciidoctor-diagram/mermaid/converter.rb +178 -0
- data/lib/asciidoctor-diagram/mermaid/extension.rb +14 -0
- data/lib/asciidoctor-diagram/mermaid.rb +7 -0
- data/lib/asciidoctor-diagram/msc/converter.rb +35 -0
- data/lib/asciidoctor-diagram/msc/extension.rb +14 -0
- data/lib/asciidoctor-diagram/msc.rb +7 -0
- data/lib/asciidoctor-diagram/nomnoml/converter.rb +25 -0
- data/lib/asciidoctor-diagram/nomnoml/extension.rb +14 -0
- data/lib/asciidoctor-diagram/nomnoml.rb +7 -0
- data/lib/asciidoctor-diagram/plantuml/converter.rb +115 -0
- data/lib/asciidoctor-diagram/plantuml/extension.rb +14 -20
- data/lib/asciidoctor-diagram/plantuml.rb +3 -5
- data/lib/asciidoctor-diagram/salt.rb +7 -0
- data/lib/asciidoctor-diagram/shaape/converter.rb +25 -0
- data/lib/asciidoctor-diagram/shaape/extension.rb +9 -11
- data/lib/asciidoctor-diagram/shaape.rb +3 -5
- data/lib/asciidoctor-diagram/smcat/converter.rb +44 -0
- data/lib/asciidoctor-diagram/smcat/extension.rb +14 -0
- data/lib/asciidoctor-diagram/smcat.rb +7 -0
- data/lib/asciidoctor-diagram/svgbob/converter.rb +25 -0
- data/lib/asciidoctor-diagram/svgbob/extension.rb +14 -0
- data/lib/asciidoctor-diagram/svgbob.rb +7 -0
- data/lib/asciidoctor-diagram/syntrax/converter.rb +55 -0
- data/lib/asciidoctor-diagram/syntrax/extension.rb +14 -0
- data/lib/asciidoctor-diagram/syntrax.rb +7 -0
- data/lib/asciidoctor-diagram/tikz/converter.rb +56 -0
- data/lib/asciidoctor-diagram/tikz/extension.rb +14 -0
- data/lib/asciidoctor-diagram/tikz.rb +7 -0
- data/lib/asciidoctor-diagram/umlet/converter.rb +24 -0
- data/lib/asciidoctor-diagram/umlet/extension.rb +14 -0
- data/lib/asciidoctor-diagram/umlet.rb +7 -0
- data/lib/asciidoctor-diagram/util/binaryio.rb +20 -0
- data/lib/asciidoctor-diagram/util/cli.rb +81 -0
- data/lib/asciidoctor-diagram/util/cli_generator.rb +73 -22
- data/lib/asciidoctor-diagram/util/gif.rb +21 -0
- data/lib/asciidoctor-diagram/util/java.rb +95 -1
- data/lib/asciidoctor-diagram/util/java_jruby.rb +14 -20
- data/lib/asciidoctor-diagram/util/java_socket.rb +175 -0
- data/lib/asciidoctor-diagram/util/pdf.rb +10 -0
- data/lib/asciidoctor-diagram/util/platform.rb +97 -0
- data/lib/asciidoctor-diagram/util/png.rb +1 -0
- data/lib/asciidoctor-diagram/util/svg.rb +4 -3
- data/lib/asciidoctor-diagram/util/which.rb +15 -9
- data/lib/asciidoctor-diagram/vega/converter.rb +47 -0
- data/lib/asciidoctor-diagram/vega/extension.rb +14 -0
- data/lib/asciidoctor-diagram/vega.rb +10 -0
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/lib/asciidoctor-diagram/wavedrom/converter.rb +50 -0
- data/lib/asciidoctor-diagram/wavedrom/extension.rb +14 -0
- data/lib/asciidoctor-diagram/wavedrom.rb +7 -0
- data/lib/asciidoctor-diagram.rb +22 -5
- data/lib/batik-all-1.10.jar +0 -0
- data/lib/ditaa-1.3.14.jar +0 -0
- data/lib/ditaamini-0.12.jar +0 -0
- data/lib/jlatexmath-minimal-1.0.5.jar +0 -0
- data/lib/plantuml-1.3.14.jar +0 -0
- data/lib/plantuml.jar +0 -0
- data/lib/server-1.3.14.jar +0 -0
- data/spec/a2s_spec.rb +167 -0
- data/spec/blockdiag_spec.rb +55 -24
- data/spec/bpmn-example.xml +44 -0
- data/spec/bpmn_spec.rb +96 -0
- data/spec/ditaa_spec.rb +150 -15
- data/spec/erd_spec.rb +289 -0
- data/spec/gnuplot_spec.rb +478 -0
- data/spec/graphviz_spec.rb +20 -20
- data/spec/lilypond_spec.rb +151 -0
- data/spec/man.jpg +0 -0
- data/spec/meme_spec.rb +67 -0
- data/spec/mermaid_spec.rb +336 -0
- data/spec/msc_spec.rb +230 -0
- data/spec/nomnoml_spec.rb +170 -0
- data/spec/plantuml_spec.rb +895 -54
- data/spec/shaape_spec.rb +25 -24
- data/spec/smcat_spec.rb +164 -0
- data/spec/svgbob_spec.rb +167 -0
- data/spec/syntrax_spec.rb +228 -0
- data/spec/test_helper.rb +88 -9
- data/spec/tikz_spec.rb +127 -0
- data/spec/umlet_spec.rb +85 -0
- data/spec/vega_spec.rb +241 -0
- data/spec/wavedrom_spec.rb +214 -0
- metadata +130 -35
- data/lib/asciidoctor-diagram/plantuml/generator.rb +0 -46
- data/lib/asciidoctor-diagram/util/diagram.rb +0 -220
- data/lib/asciidoctor-diagram/util/java_rjb.rb +0 -90
- data/lib/ditaamini0_9.jar +0 -0
data/spec/plantuml_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
|
-
describe Asciidoctor::Diagram::
|
3
|
+
describe Asciidoctor::Diagram::PlantUmlBlockMacroProcessor do
|
4
4
|
it "should generate PNG images when format is set to 'png'" do
|
5
5
|
code = <<-eos
|
6
6
|
User -> (Start)
|
@@ -20,25 +20,234 @@ Doc Writer <doc@example.com>
|
|
20
20
|
plantuml::plantuml.txt[format="png"]
|
21
21
|
eos
|
22
22
|
|
23
|
-
d =
|
23
|
+
d = load_asciidoc doc
|
24
24
|
expect(d).to_not be_nil
|
25
25
|
|
26
|
-
b = d.find { |
|
26
|
+
b = d.find { |bl| bl.context == :image }
|
27
27
|
expect(b).to_not be_nil
|
28
28
|
|
29
29
|
expect(b.content_model).to eq :empty
|
30
30
|
|
31
31
|
target = b.attributes['target']
|
32
32
|
expect(target).to_not be_nil
|
33
|
-
expect(target).to match
|
34
|
-
expect(File.
|
33
|
+
expect(target).to match(/\.png$/)
|
34
|
+
expect(File.exist?(target)).to be true
|
35
35
|
|
36
36
|
expect(b.attributes['width']).to_not be_nil
|
37
37
|
expect(b.attributes['height']).to_not be_nil
|
38
38
|
end
|
39
|
+
|
40
|
+
it "should generate PNG images when format is set to 'png'" do
|
41
|
+
code = <<-eos
|
42
|
+
User -> (Start)
|
43
|
+
User --> (Use the application) : Label
|
44
|
+
|
45
|
+
:Main Admin: ---> (Use the application) : Another label
|
46
|
+
eos
|
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
|
58
|
+
|
59
|
+
d = load_asciidoc doc
|
60
|
+
expect(d).to_not be_nil
|
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
|
75
|
+
|
76
|
+
it 'should support substitutions in diagram code' do
|
77
|
+
code = <<-eos
|
78
|
+
class {parent-class}
|
79
|
+
class {child-class}
|
80
|
+
{parent-class} <|-- {child-class}
|
81
|
+
eos
|
82
|
+
|
83
|
+
File.write('plantuml.txt', code)
|
84
|
+
|
85
|
+
doc = <<-eos
|
86
|
+
= Hello, PlantUML!
|
87
|
+
Doc Writer <doc@example.com>
|
88
|
+
:parent-class: ParentClass
|
89
|
+
:child-class: ChildClass
|
90
|
+
|
91
|
+
== First Section
|
92
|
+
|
93
|
+
plantuml::plantuml.txt[format="svg", subs=attributes+]
|
94
|
+
eos
|
95
|
+
|
96
|
+
d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
|
97
|
+
expect(d).to_not be_nil
|
98
|
+
|
99
|
+
b = d.find { |bl| bl.context == :image }
|
100
|
+
expect(b).to_not be_nil
|
101
|
+
|
102
|
+
target = b.attributes['target']
|
103
|
+
expect(File.exist?(target)).to be true
|
104
|
+
|
105
|
+
content = File.read(target, :encoding => Encoding::UTF_8)
|
106
|
+
expect(content).to include('ParentClass')
|
107
|
+
expect(content).to include('ChildClass')
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should support substitutions in the target attribute' do
|
111
|
+
code = <<-eos
|
112
|
+
class {parent-class}
|
113
|
+
class {child-class}
|
114
|
+
{parent-class} <|-- {child-class}
|
115
|
+
eos
|
116
|
+
|
117
|
+
File.write('plantuml.txt', code)
|
118
|
+
|
119
|
+
doc = <<-eos
|
120
|
+
= Hello, PlantUML!
|
121
|
+
Doc Writer <doc@example.com>
|
122
|
+
:file: plantuml
|
123
|
+
:parent-class: ParentClass
|
124
|
+
:child-class: ChildClass
|
125
|
+
|
126
|
+
== First Section
|
127
|
+
|
128
|
+
plantuml::{file}.txt[format="svg", subs=attributes+]
|
129
|
+
eos
|
130
|
+
|
131
|
+
d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
|
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
|
+
target = b.attributes['target']
|
138
|
+
expect(File.exist?(target)).to be true
|
139
|
+
|
140
|
+
content = File.read(target, :encoding => Encoding::UTF_8)
|
141
|
+
expect(content).to include('ParentClass')
|
142
|
+
expect(content).to include('ChildClass')
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'should support substitutions in the format attribute' do
|
146
|
+
code = <<-eos
|
147
|
+
class Parent
|
148
|
+
class Child
|
149
|
+
Parent <|-- Child
|
150
|
+
eos
|
151
|
+
|
152
|
+
File.write('plantuml.txt', code)
|
153
|
+
|
154
|
+
doc = <<-eos
|
155
|
+
= Hello, PlantUML!
|
156
|
+
Doc Writer <doc@example.com>
|
157
|
+
:file: plantuml
|
158
|
+
:plantumlformat: png
|
159
|
+
|
160
|
+
== First Section
|
161
|
+
|
162
|
+
plantuml::{file}.txt[format="{plantumlformat}", subs=attributes+]
|
163
|
+
eos
|
164
|
+
|
165
|
+
d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
|
166
|
+
expect(d).to_not be_nil
|
167
|
+
|
168
|
+
b = d.find { |bl| bl.context == :image }
|
169
|
+
expect(b).to_not be_nil
|
170
|
+
|
171
|
+
target = b.attributes['target']
|
172
|
+
expect(target).to match(/\.png$/)
|
173
|
+
expect(File.exist?(target)).to be true
|
174
|
+
|
175
|
+
expect(b.attributes['width']).to_not be_nil
|
176
|
+
expect(b.attributes['height']).to_not be_nil
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'should resolve !include directives with relative paths' do
|
180
|
+
included = <<-eos
|
181
|
+
interface List
|
182
|
+
List : int size()
|
183
|
+
List : void clear()
|
184
|
+
eos
|
185
|
+
|
186
|
+
code = <<-eos
|
187
|
+
!include list.iuml
|
188
|
+
List <|.. ArrayList
|
189
|
+
eos
|
190
|
+
|
191
|
+
Dir.mkdir('dir')
|
192
|
+
File.write('dir/list.iuml', included)
|
193
|
+
File.write('dir/plantuml.txt', code)
|
194
|
+
|
195
|
+
doc = <<-eos
|
196
|
+
= Hello, PlantUML!
|
197
|
+
Doc Writer <doc@example.com>
|
198
|
+
:parent-class: ParentClass
|
199
|
+
:child-class: ChildClass
|
200
|
+
|
201
|
+
== First Section
|
202
|
+
|
203
|
+
plantuml::dir/plantuml.txt[format="svg", subs=attributes+]
|
204
|
+
eos
|
205
|
+
|
206
|
+
d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
|
207
|
+
|
208
|
+
expect(d).to_not be_nil
|
209
|
+
|
210
|
+
b = d.find { |bl| bl.context == :image }
|
211
|
+
expect(b).to_not be_nil
|
212
|
+
|
213
|
+
target = b.attributes['target']
|
214
|
+
expect(File.exist?(target)).to be true
|
215
|
+
|
216
|
+
content = File.read(target, :encoding => Encoding::UTF_8)
|
217
|
+
expect(content).to_not include('!include')
|
218
|
+
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
|
39
248
|
end
|
40
249
|
|
41
|
-
describe Asciidoctor::Diagram::
|
250
|
+
describe Asciidoctor::Diagram::PlantUmlBlockProcessor do
|
42
251
|
it "should generate PNG images when format is set to 'png'" do
|
43
252
|
doc = <<-eos
|
44
253
|
= Hello, PlantUML!
|
@@ -55,18 +264,18 @@ User --> (Use the application) : Label
|
|
55
264
|
----
|
56
265
|
eos
|
57
266
|
|
58
|
-
d =
|
267
|
+
d = load_asciidoc doc
|
59
268
|
expect(d).to_not be_nil
|
60
269
|
|
61
|
-
b = d.find { |
|
270
|
+
b = d.find { |bl| bl.context == :image }
|
62
271
|
expect(b).to_not be_nil
|
63
272
|
|
64
273
|
expect(b.content_model).to eq :empty
|
65
274
|
|
66
275
|
target = b.attributes['target']
|
67
276
|
expect(target).to_not be_nil
|
68
|
-
expect(target).to match
|
69
|
-
expect(File.
|
277
|
+
expect(target).to match(/\.png$/)
|
278
|
+
expect(File.exist?(target)).to be true
|
70
279
|
|
71
280
|
expect(b.attributes['width']).to_not be_nil
|
72
281
|
expect(b.attributes['height']).to_not be_nil
|
@@ -88,18 +297,89 @@ User --> (Use the application) : Label
|
|
88
297
|
----
|
89
298
|
eos
|
90
299
|
|
91
|
-
d =
|
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
|
92
370
|
expect(d).to_not be_nil
|
93
371
|
|
94
|
-
b = d.find { |
|
372
|
+
b = d.find { |bl| bl.context == :image }
|
95
373
|
expect(b).to_not be_nil
|
96
374
|
|
97
375
|
expect(b.content_model).to eq :empty
|
98
376
|
|
99
377
|
target = b.attributes['target']
|
100
378
|
expect(target).to_not be_nil
|
101
|
-
expect(target).to match
|
102
|
-
expect(File.
|
379
|
+
expect(target).to match(/\.svg/)
|
380
|
+
expect(File.exist?(target)).to be true
|
381
|
+
|
382
|
+
expect(b.attributes['opts']).to eq('inline')
|
103
383
|
|
104
384
|
expect(b.attributes['width']).to_not be_nil
|
105
385
|
expect(b.attributes['height']).to_not be_nil
|
@@ -121,10 +401,10 @@ User --> (Use the application) : Label
|
|
121
401
|
----
|
122
402
|
eos
|
123
403
|
|
124
|
-
d =
|
404
|
+
d = load_asciidoc doc
|
125
405
|
expect(d).to_not be_nil
|
126
406
|
|
127
|
-
b = d.find { |
|
407
|
+
b = d.find { |bl| bl.context == :literal }
|
128
408
|
expect(b).to_not be_nil
|
129
409
|
|
130
410
|
expect(b.content_model).to eq :verbatim
|
@@ -132,7 +412,7 @@ User --> (Use the application) : Label
|
|
132
412
|
expect(b.attributes['target']).to be_nil
|
133
413
|
end
|
134
414
|
|
135
|
-
it
|
415
|
+
it 'should raise an error when when format is set to an invalid value' do
|
136
416
|
doc = <<-eos
|
137
417
|
= Hello, PlantUML!
|
138
418
|
Doc Writer <doc@example.com>
|
@@ -144,18 +424,19 @@ Doc Writer <doc@example.com>
|
|
144
424
|
----
|
145
425
|
eos
|
146
426
|
|
147
|
-
expect {
|
427
|
+
expect { load_asciidoc doc }.to raise_error(/support.*format/i)
|
148
428
|
end
|
149
429
|
|
150
|
-
it
|
430
|
+
it 'should use plantuml configuration when specified as a document attribute' do
|
151
431
|
doc = <<-eos
|
152
432
|
= Hello, PlantUML!
|
153
433
|
Doc Writer <doc@example.com>
|
154
|
-
:
|
434
|
+
:plantuml-config: test.config
|
435
|
+
:plantuml-format: svg
|
155
436
|
|
156
437
|
== First Section
|
157
438
|
|
158
|
-
[plantuml
|
439
|
+
[plantuml]
|
159
440
|
----
|
160
441
|
actor Foo1
|
161
442
|
boundary Foo2
|
@@ -164,25 +445,25 @@ Foo1 -> Foo2 : To boundary
|
|
164
445
|
eos
|
165
446
|
|
166
447
|
config = <<-eos
|
167
|
-
ArrowColor #DEADBE
|
448
|
+
skinparam ArrowColor #DEADBE
|
168
449
|
eos
|
169
450
|
|
170
451
|
File.open('test.config', 'w') do |f|
|
171
452
|
f.write config
|
172
453
|
end
|
173
454
|
|
174
|
-
d =
|
175
|
-
b = d.find { |
|
455
|
+
d = load_asciidoc doc
|
456
|
+
b = d.find { |bl| bl.context == :image }
|
176
457
|
|
177
458
|
target = b.attributes['target']
|
178
459
|
expect(target).to_not be_nil
|
179
|
-
expect(File.
|
460
|
+
expect(File.exist?(target)).to be true
|
180
461
|
|
181
|
-
svg = File.read(target)
|
182
|
-
expect(svg).to match
|
462
|
+
svg = File.read(target, :encoding => Encoding::UTF_8)
|
463
|
+
expect(svg).to match(/<path.*fill="#DEADBE"/)
|
183
464
|
end
|
184
465
|
|
185
|
-
it
|
466
|
+
it 'should not regenerate images when source has not changed' do
|
186
467
|
code = <<-eos
|
187
468
|
User -> (Start)
|
188
469
|
User --> (Use the application) : Label
|
@@ -208,21 +489,21 @@ Foo1 -> Foo2 : To boundary
|
|
208
489
|
----
|
209
490
|
eos
|
210
491
|
|
211
|
-
d =
|
212
|
-
b = d.find { |
|
492
|
+
d = load_asciidoc doc
|
493
|
+
b = d.find { |bl| bl.context == :image }
|
213
494
|
target = b.attributes['target']
|
214
495
|
mtime1 = File.mtime(target)
|
215
496
|
|
216
497
|
sleep 1
|
217
498
|
|
218
|
-
d =
|
499
|
+
d = load_asciidoc doc
|
219
500
|
|
220
501
|
mtime2 = File.mtime(target)
|
221
502
|
|
222
503
|
expect(mtime2).to eq mtime1
|
223
504
|
end
|
224
505
|
|
225
|
-
it
|
506
|
+
it 'should handle two block macros with the same source' do
|
226
507
|
code = <<-eos
|
227
508
|
User -> (Start)
|
228
509
|
User --> (Use the application) : Label
|
@@ -242,11 +523,11 @@ plantuml::plantuml.txt[]
|
|
242
523
|
plantuml::plantuml.txt[]
|
243
524
|
eos
|
244
525
|
|
245
|
-
|
246
|
-
expect(File.
|
526
|
+
load_asciidoc doc
|
527
|
+
expect(File.exist?('plantuml.png')).to be true
|
247
528
|
end
|
248
529
|
|
249
|
-
it
|
530
|
+
it 'should respect target attribute in block macros' do
|
250
531
|
code = <<-eos
|
251
532
|
User -> (Start)
|
252
533
|
User --> (Use the application) : Label
|
@@ -266,14 +547,39 @@ plantuml::plantuml.txt["foobar"]
|
|
266
547
|
plantuml::plantuml.txt["foobaz"]
|
267
548
|
eos
|
268
549
|
|
269
|
-
|
270
|
-
expect(File.
|
271
|
-
expect(File.
|
272
|
-
expect(File.
|
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
|
273
554
|
end
|
274
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
|
275
581
|
|
276
|
-
it
|
582
|
+
it 'should write files to outdir if set' do
|
277
583
|
doc = <<-eos
|
278
584
|
= Hello, PlantUML!
|
279
585
|
Doc Writer <doc@example.com>
|
@@ -288,38 +594,573 @@ Foo1 -> Foo2 : To boundary
|
|
288
594
|
----
|
289
595
|
eos
|
290
596
|
|
291
|
-
d =
|
292
|
-
b = d.find { |
|
597
|
+
d = load_asciidoc doc, {:attributes => {'outdir' => 'foo'}}
|
598
|
+
b = d.find { |bl| bl.context == :image }
|
293
599
|
|
294
600
|
target = b.attributes['target']
|
295
601
|
expect(target).to_not be_nil
|
296
|
-
expect(File.
|
297
|
-
expect(File.
|
602
|
+
expect(File.exist?(target)).to be false
|
603
|
+
expect(File.exist?(File.expand_path(target, 'foo'))).to be true
|
298
604
|
end
|
299
605
|
|
300
|
-
it
|
606
|
+
it 'should write files to to_dir if set' do
|
301
607
|
doc = <<-eos
|
302
608
|
= Hello, PlantUML!
|
303
609
|
Doc Writer <doc@example.com>
|
304
610
|
|
305
611
|
== First Section
|
306
612
|
|
307
|
-
[plantuml, format="
|
613
|
+
[plantuml, format="svg"]
|
308
614
|
----
|
309
|
-
|
615
|
+
actor Foo1
|
616
|
+
boundary Foo2
|
617
|
+
Foo1 -> Foo2 : To boundary
|
310
618
|
----
|
311
619
|
eos
|
312
620
|
|
313
|
-
d =
|
314
|
-
|
621
|
+
d = load_asciidoc doc, {:to_dir => 'foo'}
|
622
|
+
b = d.find { |bl| bl.context == :image }
|
315
623
|
|
316
|
-
|
317
|
-
expect(
|
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 }
|
318
653
|
|
319
654
|
target = b.attributes['target']
|
320
|
-
expect(
|
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
|
321
659
|
|
322
|
-
|
323
|
-
|
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+/)
|
732
|
+
end
|
733
|
+
|
734
|
+
it 'should support salt diagrams using salt block type' do
|
735
|
+
doc = <<-eos
|
736
|
+
= Hello, PlantUML!
|
737
|
+
Doc Writer <doc@example.com>
|
738
|
+
|
739
|
+
== First Section
|
740
|
+
|
741
|
+
[salt, format="png"]
|
742
|
+
----
|
743
|
+
{
|
744
|
+
Just plain text
|
745
|
+
[This is my button]
|
746
|
+
() Unchecked radio
|
747
|
+
(X) Checked radio
|
748
|
+
[] Unchecked box
|
749
|
+
[X] Checked box
|
750
|
+
"Enter text here "
|
751
|
+
^This is a droplist^
|
752
|
+
}
|
753
|
+
----
|
754
|
+
eos
|
755
|
+
|
756
|
+
d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
|
757
|
+
expect(d).to_not be_nil
|
758
|
+
|
759
|
+
b = d.find { |bl| bl.context == :image }
|
760
|
+
expect(b).to_not be_nil
|
761
|
+
|
762
|
+
target = b.attributes['target']
|
763
|
+
expect(File.exist?(target)).to be true
|
764
|
+
|
765
|
+
expect(b.attributes['width']).to be_nil
|
766
|
+
expect(b.attributes['height']).to be_nil
|
767
|
+
end
|
768
|
+
|
769
|
+
it 'should support salt diagrams using plantuml block type' do
|
770
|
+
doc = <<-eos
|
771
|
+
= Hello, PlantUML!
|
772
|
+
Doc Writer <doc@example.com>
|
773
|
+
|
774
|
+
== First Section
|
775
|
+
|
776
|
+
[plantuml, format="png"]
|
777
|
+
----
|
778
|
+
salt
|
779
|
+
{
|
780
|
+
Just plain text
|
781
|
+
[This is my button]
|
782
|
+
() Unchecked radio
|
783
|
+
(X) Checked radio
|
784
|
+
[] Unchecked box
|
785
|
+
[X] Checked box
|
786
|
+
"Enter text here "
|
787
|
+
^This is a droplist^
|
788
|
+
}
|
789
|
+
----
|
790
|
+
eos
|
791
|
+
|
792
|
+
d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
|
793
|
+
expect(d).to_not be_nil
|
794
|
+
|
795
|
+
b = d.find { |bl| bl.context == :image }
|
796
|
+
expect(b).to_not be_nil
|
797
|
+
|
798
|
+
target = b.attributes['target']
|
799
|
+
expect(File.exist?(target)).to be true
|
800
|
+
|
801
|
+
expect(b.attributes['width']).to be_nil
|
802
|
+
expect(b.attributes['height']).to be_nil
|
803
|
+
end
|
804
|
+
|
805
|
+
it 'should support salt diagrams containing tree widgets' do
|
806
|
+
doc = <<-eos
|
807
|
+
= Hello, PlantUML!
|
808
|
+
Doc Writer <doc@example.com>
|
809
|
+
|
810
|
+
== First Section
|
811
|
+
|
812
|
+
[plantuml, format="png"]
|
813
|
+
----
|
814
|
+
salt
|
815
|
+
{
|
816
|
+
{T
|
817
|
+
+A
|
818
|
+
++a
|
819
|
+
}
|
820
|
+
}
|
821
|
+
----
|
822
|
+
eos
|
823
|
+
|
824
|
+
d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
|
825
|
+
expect(d).to_not be_nil
|
826
|
+
|
827
|
+
b = d.find { |bl| bl.context == :image }
|
828
|
+
expect(b).to_not be_nil
|
829
|
+
|
830
|
+
target = b.attributes['target']
|
831
|
+
expect(File.exist?(target)).to be true
|
832
|
+
|
833
|
+
expect(b.attributes['width']).to be_nil
|
834
|
+
expect(b.attributes['height']).to be_nil
|
835
|
+
end
|
836
|
+
|
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
|
+
it 'should handle embedded creole images correctly' do
|
873
|
+
creole_doc = <<-eos
|
874
|
+
= Hello, PlantUML!
|
875
|
+
Doc Writer <doc@example.com>
|
876
|
+
|
877
|
+
== First Section
|
878
|
+
|
879
|
+
[plantuml, format="png"]
|
880
|
+
----
|
881
|
+
:* You can change <color:red>text color</color>
|
882
|
+
* You can change <back:cadetblue>background color</back>
|
883
|
+
* You can change <size:18>size</size>
|
884
|
+
* You use <u>legacy</u> <b>HTML <i>tag</i></b>
|
885
|
+
* You use <u:red>color</u> <s:green>in HTML</s> <w:#0000FF>tag</w>
|
886
|
+
* Use image : <img:sourceforge.jpg>
|
887
|
+
* Use image : <img:http://www.foo.bar/sourceforge.jpg>
|
888
|
+
* Use image : <img:file:///sourceforge.jpg>
|
889
|
+
|
890
|
+
;
|
891
|
+
----
|
892
|
+
eos
|
893
|
+
|
894
|
+
load_asciidoc creole_doc, :attributes => {'backend' => 'html5'}
|
895
|
+
|
896
|
+
# No real way to assert this since PlantUML doesn't produce an error on file not found
|
897
|
+
end
|
898
|
+
|
899
|
+
it 'should resolve !include directives with relative paths' do
|
900
|
+
included = <<-eos
|
901
|
+
interface List
|
902
|
+
List : int size()
|
903
|
+
List : void clear()
|
904
|
+
eos
|
905
|
+
|
906
|
+
sub = <<-eos
|
907
|
+
@startuml
|
908
|
+
A -> A : stuff1
|
909
|
+
!startsub BASIC
|
910
|
+
B -> B : stuff2
|
911
|
+
!endsub
|
912
|
+
C -> C : stuff3
|
913
|
+
!startsub BASIC
|
914
|
+
D -> D : stuff4
|
915
|
+
!endsub
|
916
|
+
@enduml
|
917
|
+
eos
|
918
|
+
|
919
|
+
Dir.mkdir('dir')
|
920
|
+
File.write('dir/List.iuml', included)
|
921
|
+
File.write('dir/Sub.iuml', sub)
|
922
|
+
|
923
|
+
creole_doc = <<-eos
|
924
|
+
= Hello, PlantUML!
|
925
|
+
Doc Writer <doc@example.com>
|
926
|
+
|
927
|
+
== First Section
|
928
|
+
|
929
|
+
[plantuml, format="svg"]
|
930
|
+
----
|
931
|
+
!include dir/List.iuml
|
932
|
+
!includesub dir/Sub.iuml!BASIC
|
933
|
+
List <|.. ArrayList
|
934
|
+
----
|
935
|
+
eos
|
936
|
+
|
937
|
+
d = load_asciidoc creole_doc, :attributes => {'backend' => 'html5'}
|
938
|
+
|
939
|
+
expect(d).to_not be_nil
|
940
|
+
|
941
|
+
b = d.find { |bl| bl.context == :image }
|
942
|
+
expect(b).to_not be_nil
|
943
|
+
|
944
|
+
target = b.attributes['target']
|
945
|
+
expect(File.exist?(target)).to be true
|
946
|
+
|
947
|
+
content = File.read(target, :encoding => Encoding::UTF_8)
|
948
|
+
expect(content).to_not include('!include')
|
949
|
+
expect(content).to_not include('!includesub')
|
950
|
+
end
|
951
|
+
|
952
|
+
it 'should not resolve stdlib !include directives' do
|
953
|
+
doc = <<-eos
|
954
|
+
= Hello, PlantUML!
|
955
|
+
Doc Writer <doc@example.com>
|
956
|
+
|
957
|
+
== First Section
|
958
|
+
|
959
|
+
[plantuml, format="svg"]
|
960
|
+
----
|
961
|
+
@startuml
|
962
|
+
!include <tupadr3/common>
|
963
|
+
!include <tupadr3/font-awesome/server>
|
964
|
+
!include <tupadr3/font-awesome/database>
|
965
|
+
|
966
|
+
title Styling example
|
967
|
+
|
968
|
+
FA_SERVER(web1,web1) #Green
|
969
|
+
FA_SERVER(web2,web2) #Yellow
|
970
|
+
FA_SERVER(web3,web3) #Blue
|
971
|
+
FA_SERVER(web4,web4) #YellowGreen
|
972
|
+
|
973
|
+
FA_DATABASE(db1,LIVE,database,white) #RoyalBlue
|
974
|
+
FA_DATABASE(db2,SPARE,database) #Red
|
975
|
+
|
976
|
+
db1 <--> db2
|
977
|
+
|
978
|
+
web1 <--> db1
|
979
|
+
web2 <--> db1
|
980
|
+
web3 <--> db1
|
981
|
+
web4 <--> db1
|
982
|
+
@enduml
|
983
|
+
----
|
984
|
+
eos
|
985
|
+
|
986
|
+
d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
|
987
|
+
|
988
|
+
expect(d).to_not be_nil
|
989
|
+
|
990
|
+
b = d.find { |bl| bl.context == :image }
|
991
|
+
expect(b).to_not be_nil
|
992
|
+
|
993
|
+
target = b.attributes['target']
|
994
|
+
expect(File.exist?(target)).to be true
|
995
|
+
|
996
|
+
content = File.read(target, :encoding => Encoding::UTF_8)
|
997
|
+
expect(content).to_not include('!include')
|
998
|
+
end
|
999
|
+
|
1000
|
+
it 'should support substitutions' do
|
1001
|
+
doc = <<-eos
|
1002
|
+
= Hello, PlantUML!
|
1003
|
+
:parent-class: ParentClass
|
1004
|
+
:child-class: ChildClass
|
1005
|
+
|
1006
|
+
[plantuml,class-inheritence,svg,subs=attributes+]
|
1007
|
+
....
|
1008
|
+
class {parent-class}
|
1009
|
+
class {child-class}
|
1010
|
+
{parent-class} <|-- {child-class}
|
1011
|
+
....
|
1012
|
+
eos
|
1013
|
+
|
1014
|
+
d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
|
1015
|
+
expect(d).to_not be_nil
|
1016
|
+
|
1017
|
+
b = d.find { |bl| bl.context == :image }
|
1018
|
+
expect(b).to_not be_nil
|
1019
|
+
|
1020
|
+
target = b.attributes['target']
|
1021
|
+
expect(File.exist?(target)).to be true
|
1022
|
+
|
1023
|
+
content = File.read(target, :encoding => Encoding::UTF_8)
|
1024
|
+
expect(content).to include('ParentClass')
|
1025
|
+
expect(content).to include('ChildClass')
|
1026
|
+
end
|
1027
|
+
|
1028
|
+
it "should generate PNG images for jlatexmath blocks when format is set to 'png'" do
|
1029
|
+
doc = <<-eos
|
1030
|
+
= Hello, PlantUML!
|
1031
|
+
Doc Writer <doc@example.com>
|
1032
|
+
|
1033
|
+
== First Section
|
1034
|
+
|
1035
|
+
[plantuml,format="png"]
|
1036
|
+
----
|
1037
|
+
@startlatex
|
1038
|
+
e^{i\\pi} + 1 = 0
|
1039
|
+
@endlatex
|
1040
|
+
----
|
1041
|
+
eos
|
1042
|
+
|
1043
|
+
d = load_asciidoc doc
|
1044
|
+
expect(d).to_not be_nil
|
1045
|
+
|
1046
|
+
b = d.find { |bl| bl.context == :image }
|
1047
|
+
expect(b).to_not be_nil
|
1048
|
+
|
1049
|
+
expect(b.content_model).to eq :empty
|
1050
|
+
|
1051
|
+
target = b.attributes['target']
|
1052
|
+
expect(target).to_not be_nil
|
1053
|
+
expect(target).to match(/\.png$/)
|
1054
|
+
expect(File.exist?(target)).to be true
|
1055
|
+
|
1056
|
+
expect(b.attributes['width']).to_not be_nil
|
1057
|
+
expect(b.attributes['height']).to_not be_nil
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
it "should generate SVG images for jlatexmath blocks when format is set to 'svg'" do
|
1061
|
+
doc = <<-eos
|
1062
|
+
= Hello, PlantUML!
|
1063
|
+
Doc Writer <doc@example.com>
|
1064
|
+
|
1065
|
+
== First Section
|
1066
|
+
|
1067
|
+
[plantuml,format="svg"]
|
1068
|
+
----
|
1069
|
+
@startlatex
|
1070
|
+
e^{i\\pi} + 1 = 0
|
1071
|
+
@endlatex
|
1072
|
+
----
|
1073
|
+
eos
|
1074
|
+
|
1075
|
+
d = load_asciidoc doc
|
1076
|
+
expect(d).to_not be_nil
|
1077
|
+
|
1078
|
+
b = d.find { |bl| bl.context == :image }
|
1079
|
+
expect(b).to_not be_nil
|
1080
|
+
|
1081
|
+
expect(b.content_model).to eq :empty
|
1082
|
+
|
1083
|
+
target = b.attributes['target']
|
1084
|
+
expect(target).to_not be_nil
|
1085
|
+
expect(target).to match(/\.svg$/)
|
1086
|
+
expect(File.exist?(target)).to be true
|
1087
|
+
end
|
1088
|
+
|
1089
|
+
it "should generate PNG images for diagrams with latex tags when format is set to 'png'" do
|
1090
|
+
doc = <<-eos
|
1091
|
+
= Hello, PlantUML!
|
1092
|
+
Doc Writer <doc@example.com>
|
1093
|
+
|
1094
|
+
== First Section
|
1095
|
+
|
1096
|
+
[plantuml,format="png"]
|
1097
|
+
----
|
1098
|
+
:<latex>P(y|\\mathbf{x}) \\mbox{ or } f(\\mathbf{x})+\\epsilon</latex>;
|
1099
|
+
----
|
1100
|
+
eos
|
1101
|
+
|
1102
|
+
d = load_asciidoc doc
|
1103
|
+
expect(d).to_not be_nil
|
1104
|
+
|
1105
|
+
b = d.find { |bl| bl.context == :image }
|
1106
|
+
expect(b).to_not be_nil
|
1107
|
+
|
1108
|
+
expect(b.content_model).to eq :empty
|
1109
|
+
|
1110
|
+
target = b.attributes['target']
|
1111
|
+
expect(target).to_not be_nil
|
1112
|
+
expect(target).to match(/\.png$/)
|
1113
|
+
expect(File.exist?(target)).to be true
|
1114
|
+
|
1115
|
+
expect(b.attributes['width']).to_not be_nil
|
1116
|
+
expect(b.attributes['height']).to_not be_nil
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
it "should generate SVG images for diagrams with latex tags when format is set to 'svg'" do
|
1120
|
+
doc = <<-eos
|
1121
|
+
= Hello, PlantUML!
|
1122
|
+
Doc Writer <doc@example.com>
|
1123
|
+
|
1124
|
+
== First Section
|
1125
|
+
|
1126
|
+
[plantuml,format="svg"]
|
1127
|
+
----
|
1128
|
+
:<latex>P(y|\\mathbf{x}) \\mbox{ or } f(\\mathbf{x})+\\epsilon</latex>;
|
1129
|
+
----
|
1130
|
+
eos
|
1131
|
+
|
1132
|
+
d = load_asciidoc doc
|
1133
|
+
expect(d).to_not be_nil
|
1134
|
+
|
1135
|
+
b = d.find { |bl| bl.context == :image }
|
1136
|
+
expect(b).to_not be_nil
|
1137
|
+
|
1138
|
+
expect(b.content_model).to eq :empty
|
1139
|
+
|
1140
|
+
target = b.attributes['target']
|
1141
|
+
expect(target).to_not be_nil
|
1142
|
+
expect(target).to match(/\.svg$/)
|
1143
|
+
expect(File.exist?(target)).to be true
|
1144
|
+
|
1145
|
+
expect(b.attributes['width']).to_not be_nil
|
1146
|
+
expect(b.attributes['height']).to_not be_nil
|
1147
|
+
end
|
1148
|
+
|
1149
|
+
it "should report syntax errors" do
|
1150
|
+
doc = <<-eos
|
1151
|
+
= Hello, PlantUML!
|
1152
|
+
Doc Writer <doc@example.com>
|
1153
|
+
|
1154
|
+
== First Section
|
1155
|
+
|
1156
|
+
[plantuml,format="svg"]
|
1157
|
+
----
|
1158
|
+
Bob; Alice; foo
|
1159
|
+
----
|
1160
|
+
eos
|
1161
|
+
|
1162
|
+
expect {
|
1163
|
+
load_asciidoc doc
|
1164
|
+
}.to raise_error(/syntax error/i)
|
324
1165
|
end
|
325
1166
|
end
|