asciidoctor-diagram 2.2.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +159 -0
  3. data/README.adoc +17 -13
  4. data/lib/asciidoctor-diagram/a2s/converter.rb +7 -2
  5. data/lib/asciidoctor-diagram/barcode/converter.rb +83 -78
  6. data/lib/asciidoctor-diagram/blockdiag/converter.rb +12 -2
  7. data/lib/asciidoctor-diagram/bpmn/converter.rb +4 -1
  8. data/lib/asciidoctor-diagram/bytefield/converter.rb +4 -1
  9. data/lib/asciidoctor-diagram/d2/converter.rb +57 -0
  10. data/lib/asciidoctor-diagram/d2/extension.rb +18 -0
  11. data/lib/asciidoctor-diagram/d2.rb +8 -0
  12. data/lib/asciidoctor-diagram/dbml/converter.rb +27 -0
  13. data/lib/asciidoctor-diagram/dbml/extension.rb +18 -0
  14. data/lib/asciidoctor-diagram/dbml.rb +8 -0
  15. data/lib/asciidoctor-diagram/diagram_processor.rb +49 -9
  16. data/lib/asciidoctor-diagram/diagram_source.rb +35 -33
  17. data/lib/asciidoctor-diagram/diagrams/converter.rb +4 -1
  18. data/lib/asciidoctor-diagram/ditaa/converter.rb +15 -7
  19. data/lib/asciidoctor-diagram/ditaa/ditaa-2.2.0.jar +0 -0
  20. data/lib/asciidoctor-diagram/dpic/converter.rb +4 -1
  21. data/lib/asciidoctor-diagram/erd/converter.rb +5 -2
  22. data/lib/asciidoctor-diagram/gnuplot/converter.rb +7 -1
  23. data/lib/asciidoctor-diagram/graphviz/converter.rb +4 -1
  24. data/lib/asciidoctor-diagram/graphviz_py/converter.rb +4 -1
  25. data/lib/asciidoctor-diagram/http/converter.rb +16 -7
  26. data/lib/asciidoctor-diagram/http/server.rb +2 -2
  27. data/lib/asciidoctor-diagram/lilypond/converter.rb +3 -2
  28. data/lib/asciidoctor-diagram/meme/converter.rb +29 -3
  29. data/lib/asciidoctor-diagram/mermaid/converter.rb +4 -2
  30. data/lib/asciidoctor-diagram/msc/converter.rb +6 -2
  31. data/lib/asciidoctor-diagram/nomnoml/converter.rb +4 -1
  32. data/lib/asciidoctor-diagram/penrose/converter.rb +53 -0
  33. data/lib/asciidoctor-diagram/penrose/extension.rb +18 -0
  34. data/lib/asciidoctor-diagram/penrose.rb +8 -0
  35. data/lib/asciidoctor-diagram/pikchr/converter.rb +4 -1
  36. data/lib/asciidoctor-diagram/pintora/converter.rb +60 -0
  37. data/lib/asciidoctor-diagram/pintora/extension.rb +18 -0
  38. data/lib/asciidoctor-diagram/pintora.rb +8 -0
  39. data/lib/asciidoctor-diagram/plantuml/converter.rb +256 -43
  40. data/lib/asciidoctor-diagram/plantuml/plantuml-2.2.4.jar +0 -0
  41. data/lib/asciidoctor-diagram/shaape/converter.rb +4 -1
  42. data/lib/asciidoctor-diagram/smcat/converter.rb +5 -1
  43. data/lib/asciidoctor-diagram/structurizr/converter.rb +69 -0
  44. data/lib/asciidoctor-diagram/structurizr/extension.rb +52 -0
  45. data/lib/asciidoctor-diagram/structurizr/renderers.rb +63 -0
  46. data/lib/asciidoctor-diagram/structurizr/structurizr-2.2.2.jar +0 -0
  47. data/lib/asciidoctor-diagram/structurizr.rb +7 -0
  48. data/lib/asciidoctor-diagram/svgbob/converter.rb +6 -2
  49. data/lib/asciidoctor-diagram/symbolator/converter.rb +4 -1
  50. data/lib/asciidoctor-diagram/syntrax/converter.rb +72 -17
  51. data/lib/asciidoctor-diagram/syntrax/syntrax-2.2.0.jar +0 -0
  52. data/lib/asciidoctor-diagram/tikz/converter.rb +5 -2
  53. data/lib/asciidoctor-diagram/umlet/converter.rb +4 -1
  54. data/lib/asciidoctor-diagram/util/base64.rb +25 -0
  55. data/lib/asciidoctor-diagram/util/cli.rb +11 -3
  56. data/lib/asciidoctor-diagram/util/cli_generator.rb +1 -0
  57. data/lib/asciidoctor-diagram/util/java.rb +15 -7
  58. data/lib/asciidoctor-diagram/util/java_jruby.rb +14 -0
  59. data/lib/asciidoctor-diagram/util/java_socket.rb +4 -0
  60. data/lib/asciidoctor-diagram/util/server-2.2.3.jar +0 -0
  61. data/lib/asciidoctor-diagram/util/svg.rb +5 -3
  62. data/lib/asciidoctor-diagram/vega/converter.rb +5 -3
  63. data/lib/asciidoctor-diagram/version.rb +1 -1
  64. data/lib/asciidoctor-diagram/wavedrom/converter.rb +38 -24
  65. data/lib/asciidoctor-diagram.rb +5 -0
  66. metadata +32 -115
  67. data/Rakefile +0 -9
  68. data/docs/antora.yml +0 -3
  69. data/docs/modules/ROOT/images/asciidoctor-diagram-classes.png +0 -0
  70. data/docs/modules/ROOT/images/asciidoctor-diagram-process.png +0 -0
  71. data/docs/modules/ROOT/pages/index.adoc +0 -21
  72. data/docs/modules/ROOT/partials/advanced.adoc +0 -365
  73. data/docs/modules/ROOT/partials/create_diagram.adoc +0 -134
  74. data/docs/modules/ROOT/partials/generate.adoc +0 -15
  75. data/docs/modules/ROOT/partials/installation.adoc +0 -19
  76. data/docs/modules/ROOT/partials/uris.adoc +0 -41
  77. data/examples/Gemfile +0 -3
  78. data/examples/README.adoc +0 -18
  79. data/examples/design.adoc +0 -78
  80. data/examples/features.adoc +0 -189
  81. data/lib/asciidoctor-diagram/ditaa/ditaa-1.3.21.jar +0 -0
  82. data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.21.jar +0 -0
  83. data/lib/asciidoctor-diagram/util/server-1.3.21.jar +0 -0
  84. data/spec/a2s_spec.rb +0 -33
  85. data/spec/barcode_spec.rb +0 -176
  86. data/spec/blockdiag_spec.rb +0 -20
  87. data/spec/bpmn_spec.rb +0 -60
  88. data/spec/bytefield_spec.rb +0 -96
  89. data/spec/diagrams_spec.rb +0 -27
  90. data/spec/ditaa_spec.rb +0 -191
  91. data/spec/dpic_spec.rb +0 -23
  92. data/spec/erd_spec.rb +0 -96
  93. data/spec/gnuplot_spec.rb +0 -229
  94. data/spec/graphviz_py_spec.rb +0 -33
  95. data/spec/graphviz_spec.rb +0 -24
  96. data/spec/lilypond_spec.rb +0 -17
  97. data/spec/man.jpg +0 -0
  98. data/spec/meme_spec.rb +0 -67
  99. data/spec/mermaid_spec.rb +0 -198
  100. data/spec/msc_spec.rb +0 -37
  101. data/spec/nomnoml_spec.rb +0 -36
  102. data/spec/pikchr_spec.rb +0 -73
  103. data/spec/plantuml_spec.rb +0 -772
  104. data/spec/shaape_spec.rb +0 -20
  105. data/spec/shared_examples.rb +0 -764
  106. data/spec/smcat_spec.rb +0 -30
  107. data/spec/svgbob_spec.rb +0 -33
  108. data/spec/symbolator_spec.rb +0 -27
  109. data/spec/syntrax_spec.rb +0 -22
  110. data/spec/test_helper.rb +0 -113
  111. data/spec/tikz_spec.rb +0 -181
  112. data/spec/umlet_spec.rb +0 -32
  113. data/spec/vega_spec.rb +0 -133
  114. data/spec/wavedrom_spec.rb +0 -21
@@ -1,772 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- PLANTUML_CODE = <<-eos
4
- User -> (Start)
5
- User --> (Use the application) : Label
6
-
7
- :Main Admin: ---> (Use the application) : Another label
8
- eos
9
-
10
- describe Asciidoctor::Diagram::PlantUmlInlineMacroProcessor do
11
- include_examples "inline_macro", :plantuml, PLANTUML_CODE, [:png, :svg]
12
- end
13
-
14
- describe Asciidoctor::Diagram::PlantUmlBlockMacroProcessor do
15
- include_examples "block_macro", :plantuml, PLANTUML_CODE, [:png, :svg, :txt]
16
-
17
- it 'should support substitutions in diagram code' do
18
- code = <<-eos
19
- class {parent-class}
20
- class {child-class}
21
- {parent-class} <|-- {child-class}
22
- eos
23
-
24
- File.write('plantuml.txt', code)
25
-
26
- doc = <<-eos
27
- = Hello, PlantUML!
28
- Doc Writer <doc@example.com>
29
- :parent-class: ParentClass
30
- :child-class: ChildClass
31
-
32
- == First Section
33
-
34
- plantuml::plantuml.txt[format="svg", subs=attributes+]
35
- eos
36
-
37
- d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
38
- expect(d).to_not be_nil
39
-
40
- b = d.find { |bl| bl.context == :image }
41
- expect(b).to_not be_nil
42
-
43
- target = b.attributes['target']
44
- expect(File.exist?(target)).to be true
45
-
46
- content = File.read(target, :encoding => Encoding::UTF_8)
47
- expect(content).to include('ParentClass')
48
- expect(content).to include('ChildClass')
49
- end
50
-
51
- it 'should support substitutions in the target attribute' do
52
- code = <<-eos
53
- class {parent-class}
54
- class {child-class}
55
- {parent-class} <|-- {child-class}
56
- eos
57
-
58
- File.write('plantuml.txt', code)
59
-
60
- doc = <<-eos
61
- = Hello, PlantUML!
62
- Doc Writer <doc@example.com>
63
- :file: plantuml
64
- :parent-class: ParentClass
65
- :child-class: ChildClass
66
-
67
- == First Section
68
-
69
- plantuml::{file}.txt[format="svg", subs=attributes+]
70
- eos
71
-
72
- d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
73
- expect(d).to_not be_nil
74
-
75
- b = d.find { |bl| bl.context == :image }
76
- expect(b).to_not be_nil
77
-
78
- target = b.attributes['target']
79
- expect(File.exist?(target)).to be true
80
-
81
- content = File.read(target, :encoding => Encoding::UTF_8)
82
- expect(content).to include('ParentClass')
83
- expect(content).to include('ChildClass')
84
- end
85
-
86
- it 'should support substitutions in the format attribute' do
87
- code = <<-eos
88
- class Parent
89
- class Child
90
- Parent <|-- Child
91
- eos
92
-
93
- File.write('plantuml.txt', code)
94
-
95
- doc = <<-eos
96
- = Hello, PlantUML!
97
- Doc Writer <doc@example.com>
98
- :file: plantuml
99
- :plantumlformat: png
100
-
101
- == First Section
102
-
103
- plantuml::{file}.txt[format="{plantumlformat}", subs=attributes+]
104
- eos
105
-
106
- d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
107
- expect(d).to_not be_nil
108
-
109
- b = d.find { |bl| bl.context == :image }
110
- expect(b).to_not be_nil
111
-
112
- target = b.attributes['target']
113
- expect(target).to match(/\.png$/)
114
- expect(File.exist?(target)).to be true
115
-
116
- expect(b.attributes['width']).to_not be_nil
117
- expect(b.attributes['height']).to_not be_nil
118
- end
119
-
120
- it 'should resolve !include directives with relative paths' do
121
- included = <<-eos
122
- interface List
123
- List : int size()
124
- List : void clear()
125
- eos
126
-
127
- code = <<-eos
128
- !include list.iuml
129
- List <|.. ArrayList
130
- eos
131
-
132
- Dir.mkdir('dir')
133
- File.write('dir/list.iuml', included)
134
- File.write('dir/plantuml.txt', code)
135
-
136
- doc = <<-eos
137
- = Hello, PlantUML!
138
- Doc Writer <doc@example.com>
139
- :parent-class: ParentClass
140
- :child-class: ChildClass
141
-
142
- == First Section
143
-
144
- plantuml::dir/plantuml.txt[format="svg", subs=attributes+]
145
- eos
146
-
147
- d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
148
-
149
- expect(d).to_not be_nil
150
-
151
- b = d.find { |bl| bl.context == :image }
152
- expect(b).to_not be_nil
153
-
154
- target = b.attributes['target']
155
- expect(File.exist?(target)).to be true
156
-
157
- content = File.read(target, :encoding => Encoding::UTF_8)
158
- expect(content).to_not include('!include')
159
- end
160
- end
161
-
162
- describe Asciidoctor::Diagram::PlantUmlBlockProcessor do
163
- include_examples "block", :plantuml, PLANTUML_CODE, [:png, :svg, :txt]
164
-
165
- it "should work with plantuml.com" do
166
- doc = <<-eos
167
- = Hello, kroki!
168
- :diagram-server-url: http://plantuml.com/plantuml
169
- :diagram-server-type: plantuml
170
- Doc Writer <doc@example.com>
171
-
172
- == First Section
173
-
174
- [plantuml, format=svg]
175
- ----
176
- #{PLANTUML_CODE}
177
- ----
178
- eos
179
-
180
- d = load_asciidoc doc
181
- expect(d).to_not be_nil
182
-
183
- b = d.find { |bl| bl.context == :image }
184
- expect(b).to_not be_nil
185
-
186
- expect(b.content_model).to eq :empty
187
-
188
- target = b.attributes['target']
189
- expect(target).to_not be_nil
190
- expect(target).to match(/\.svg$/)
191
- expect(File.exist?(target)).to be true
192
-
193
- expect(b.attributes['width']).to_not be_nil
194
- expect(b.attributes['height']).to_not be_nil
195
- end
196
-
197
- it "should handle syntax errors gracefully" do
198
- doc = <<-eos
199
- [plantuml]
200
- ----
201
- @startuml
202
- xxx
203
- @enduml
204
- ----
205
- eos
206
-
207
- options = {}
208
- options[:attributes] = {}
209
- options[:attributes]['diagram-on-error'] = 'log'
210
-
211
- d = load_asciidoc doc, options
212
- expect(d).to_not be_nil
213
-
214
- b = d.find { |bl| bl.context == :listing }
215
- expect(b).to_not be_nil
216
-
217
- expect(b.source).to include 'Failed to generate image'
218
- end
219
-
220
- it 'should use plantuml configuration when specified as a document attribute' do
221
- doc = <<-eos
222
- = Hello, PlantUML!
223
- Doc Writer <doc@example.com>
224
- :plantuml-config: test.config
225
- :plantuml-format: svg
226
-
227
- == First Section
228
-
229
- [plantuml]
230
- ----
231
- actor Foo1
232
- boundary Foo2
233
- Foo1 -> Foo2 : To boundary
234
- ----
235
- eos
236
-
237
- config = <<-eos
238
- skinparam ArrowColor #DEADBE
239
- eos
240
-
241
- File.open('test.config', 'w') do |f|
242
- f.write config
243
- end
244
-
245
- d = load_asciidoc doc
246
- b = d.find { |bl| bl.context == :image }
247
-
248
- target = b.attributes['target']
249
- expect(target).to_not be_nil
250
- expect(File.exist?(target)).to be true
251
-
252
- svg = File.read(target, :encoding => Encoding::UTF_8)
253
- expect(svg).to match(/<[^<]+ fill=["']#DEADBE["']/)
254
- end
255
-
256
- it 'should use plantuml include dir when specified as a document attribute' do
257
- doc = <<-eos
258
- = Hello, PlantUML!
259
- Doc Writer <doc@example.com>
260
- :plantuml-includedir: include
261
- :plantuml-format: svg
262
-
263
- == First Section
264
-
265
- [plantuml]
266
- ----
267
- !include common.puml
268
- actor Foo1
269
- boundary Foo2
270
- Foo1 -> Foo2 : To boundary
271
- ----
272
- eos
273
-
274
- includefile = <<-eos
275
- skinparam ArrowColor #DEADBE
276
- eos
277
- Dir.mkdir('include')
278
- File.open('include/common.puml', 'w') do |f|
279
- f.write includefile
280
- end
281
-
282
- d = load_asciidoc doc
283
- b = d.find { |bl| bl.context == :image }
284
-
285
- target = b.attributes['target']
286
- expect(target).to_not be_nil
287
- expect(File.exist?(target)).to be true
288
-
289
- svg = File.read(target, :encoding => Encoding::UTF_8)
290
- expect(svg).to match(/<[^<]+ fill=["']#DEADBE["']/)
291
- end
292
-
293
- it 'should support salt diagrams using salt block type' do
294
- doc = <<-eos
295
- = Hello, PlantUML!
296
- Doc Writer <doc@example.com>
297
-
298
- == First Section
299
-
300
- [salt, format="png"]
301
- ----
302
- {
303
- Just plain text
304
- [This is my button]
305
- () Unchecked radio
306
- (X) Checked radio
307
- [] Unchecked box
308
- [X] Checked box
309
- "Enter text here "
310
- ^This is a droplist^
311
- }
312
- ----
313
- eos
314
-
315
- d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
316
- expect(d).to_not be_nil
317
-
318
- b = d.find { |bl| bl.context == :image }
319
- expect(b).to_not be_nil
320
-
321
- target = b.attributes['target']
322
- expect(File.exist?(target)).to be true
323
-
324
- expect(b.attributes['width']).to be_nil
325
- expect(b.attributes['height']).to be_nil
326
- end
327
-
328
- it 'should support salt diagrams using plantuml block type' do
329
- doc = <<-eos
330
- = Hello, PlantUML!
331
- Doc Writer <doc@example.com>
332
-
333
- == First Section
334
-
335
- [plantuml, format="png"]
336
- ----
337
- salt
338
- {
339
- Just plain text
340
- [This is my button]
341
- () Unchecked radio
342
- (X) Checked radio
343
- [] Unchecked box
344
- [X] Checked box
345
- "Enter text here "
346
- ^This is a droplist^
347
- }
348
- ----
349
- eos
350
-
351
- d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
352
- expect(d).to_not be_nil
353
-
354
- b = d.find { |bl| bl.context == :image }
355
- expect(b).to_not be_nil
356
-
357
- target = b.attributes['target']
358
- expect(File.exist?(target)).to be true
359
-
360
- expect(b.attributes['width']).to be_nil
361
- expect(b.attributes['height']).to be_nil
362
- end
363
-
364
- it 'should support salt diagrams containing tree widgets' do
365
- doc = <<-eos
366
- = Hello, PlantUML!
367
- Doc Writer <doc@example.com>
368
-
369
- == First Section
370
-
371
- [plantuml, format="png"]
372
- ----
373
- salt
374
- {
375
- {T
376
- +A
377
- ++a
378
- }
379
- }
380
- ----
381
- eos
382
-
383
- d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
384
- expect(d).to_not be_nil
385
-
386
- b = d.find { |bl| bl.context == :image }
387
- expect(b).to_not be_nil
388
-
389
- target = b.attributes['target']
390
- expect(File.exist?(target)).to be true
391
-
392
- expect(b.attributes['width']).to be_nil
393
- expect(b.attributes['height']).to be_nil
394
- end
395
-
396
- it 'should support ditaa diagrams' do
397
- doc = <<-eos
398
- = Hello, PlantUML!
399
- Doc Writer <doc@example.com>
400
-
401
- == First Section
402
-
403
- [plantuml, format="png"]
404
- ----
405
- @startditaa -E
406
- +---------+
407
- | example |
408
- +---------+
409
- @endditaa
410
- ----
411
- eos
412
-
413
- d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
414
- expect(d).to_not be_nil
415
-
416
- b = d.find { |bl| bl.context == :image }
417
- expect(b).to_not be_nil
418
-
419
- target = b.attributes['target']
420
- expect(File.exist?(target)).to be true
421
-
422
- expect(b.attributes['width']).to be_nil
423
- expect(b.attributes['height']).to be_nil
424
- end
425
-
426
- it 'should handle embedded creole images correctly' do
427
- creole_doc = <<-eos
428
- = Hello, PlantUML!
429
- Doc Writer <doc@example.com>
430
-
431
- == First Section
432
-
433
- [plantuml, format="png"]
434
- ----
435
- :* You can change <color:red>text color</color>
436
- * You can change <back:cadetblue>background color</back>
437
- * You can change <size:18>size</size>
438
- * You use <u>legacy</u> <b>HTML <i>tag</i></b>
439
- * You use <u:red>color</u> <s:green>in HTML</s> <w:#0000FF>tag</w>
440
- * Use image : <img:sourceforge.jpg>
441
- * Use image : <img:http://www.foo.bar/sourceforge.jpg>
442
- * Use image : <img:file:///sourceforge.jpg>
443
-
444
- ;
445
- ----
446
- eos
447
-
448
- load_asciidoc creole_doc, :attributes => {'backend' => 'html5'}
449
-
450
- # No real way to assert this since PlantUML doesn't produce an error on file not found
451
- end
452
-
453
- it 'should resolve !include directives with relative paths' do
454
- included = <<-eos
455
- interface List
456
- List : int size()
457
- List : void clear()
458
- eos
459
-
460
- sub = <<-eos
461
- @startuml
462
- A -> A : stuff1
463
- !startsub BASIC
464
- B -> B : stuff2
465
- !endsub
466
- C -> C : stuff3
467
- !startsub BASIC
468
- D -> D : stuff4
469
- !endsub
470
- @enduml
471
- eos
472
-
473
- Dir.mkdir('dir')
474
- File.write('dir/List.iuml', included)
475
- File.write('dir/Sub.iuml', sub)
476
-
477
- creole_doc = <<-eos
478
- = Hello, PlantUML!
479
- Doc Writer <doc@example.com>
480
-
481
- == First Section
482
-
483
- [plantuml, format="svg"]
484
- ----
485
- !include dir/List.iuml
486
- !includesub dir/Sub.iuml!BASIC
487
- List <|.. ArrayList
488
- ----
489
- eos
490
-
491
- d = load_asciidoc creole_doc, :attributes => {'backend' => 'html5'}
492
-
493
- expect(d).to_not be_nil
494
-
495
- b = d.find { |bl| bl.context == :image }
496
- expect(b).to_not be_nil
497
-
498
- target = b.attributes['target']
499
- expect(File.exist?(target)).to be true
500
-
501
- content = File.read(target, :encoding => Encoding::UTF_8)
502
- expect(content).to_not include('!include')
503
- expect(content).to_not include('!includesub')
504
- end
505
-
506
- it 'should not resolve stdlib !include directives' do
507
- doc = <<-eos
508
- = Hello, PlantUML!
509
- Doc Writer <doc@example.com>
510
-
511
- == First Section
512
-
513
- [plantuml, format="svg"]
514
- ----
515
- @startuml
516
- !include <tupadr3/common>
517
- !include <tupadr3/font-awesome/server>
518
- !include <tupadr3/font-awesome/database>
519
-
520
- title Styling example
521
-
522
- FA_SERVER(web1,web1) #Green
523
- FA_SERVER(web2,web2) #Yellow
524
- FA_SERVER(web3,web3) #Blue
525
- FA_SERVER(web4,web4) #YellowGreen
526
-
527
- FA_DATABASE(db1,LIVE,database,white) #RoyalBlue
528
- FA_DATABASE(db2,SPARE,database) #Red
529
-
530
- db1 <--> db2
531
-
532
- web1 <--> db1
533
- web2 <--> db1
534
- web3 <--> db1
535
- web4 <--> db1
536
- @enduml
537
- ----
538
- eos
539
-
540
- d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
541
-
542
- expect(d).to_not be_nil
543
-
544
- b = d.find { |bl| bl.context == :image }
545
- expect(b).to_not be_nil
546
-
547
- target = b.attributes['target']
548
- expect(File.exist?(target)).to be true
549
-
550
- content = File.read(target, :encoding => Encoding::UTF_8)
551
- expect(content).to_not include('!include')
552
- end
553
-
554
- it 'should support substitutions' do
555
- doc = <<-eos
556
- = Hello, PlantUML!
557
- :parent-class: ParentClass
558
- :child-class: ChildClass
559
-
560
- [plantuml,class-inheritence,svg,subs=attributes+]
561
- ....
562
- class {parent-class}
563
- class {child-class}
564
- {parent-class} <|-- {child-class}
565
- ....
566
- eos
567
-
568
- d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
569
- expect(d).to_not be_nil
570
-
571
- b = d.find { |bl| bl.context == :image }
572
- expect(b).to_not be_nil
573
-
574
- target = b.attributes['target']
575
- expect(File.exist?(target)).to be true
576
-
577
- content = File.read(target, :encoding => Encoding::UTF_8)
578
- expect(content).to include('ParentClass')
579
- expect(content).to include('ChildClass')
580
- end
581
-
582
- it "should generate PNG images for jlatexmath blocks when format is set to 'png'" do
583
- doc = <<-eos
584
- = Hello, PlantUML!
585
- Doc Writer <doc@example.com>
586
-
587
- == First Section
588
-
589
- [plantuml,format="png"]
590
- ----
591
- @startlatex
592
- e^{i\\pi} + 1 = 0
593
- @endlatex
594
- ----
595
- eos
596
-
597
- d = load_asciidoc doc
598
- expect(d).to_not be_nil
599
-
600
- b = d.find { |bl| bl.context == :image }
601
- expect(b).to_not be_nil
602
-
603
- expect(b.content_model).to eq :empty
604
-
605
- target = b.attributes['target']
606
- expect(target).to_not be_nil
607
- expect(target).to match(/\.png$/)
608
- expect(File.exist?(target)).to be true
609
-
610
- expect(b.attributes['width']).to_not be_nil
611
- expect(b.attributes['height']).to_not be_nil
612
- end
613
-
614
- it "should generate SVG images for jlatexmath blocks when format is set to 'svg'" do
615
- doc = <<-eos
616
- = Hello, PlantUML!
617
- Doc Writer <doc@example.com>
618
-
619
- == First Section
620
-
621
- [plantuml,format="svg"]
622
- ----
623
- @startlatex
624
- e^{i\\pi} + 1 = 0
625
- @endlatex
626
- ----
627
- eos
628
-
629
- d = load_asciidoc doc
630
- expect(d).to_not be_nil
631
-
632
- b = d.find { |bl| bl.context == :image }
633
- expect(b).to_not be_nil
634
-
635
- expect(b.content_model).to eq :empty
636
-
637
- target = b.attributes['target']
638
- expect(target).to_not be_nil
639
- expect(target).to match(/\.svg$/)
640
- expect(File.exist?(target)).to be true
641
- end
642
-
643
- it "should generate PNG images for diagrams with latex tags when format is set to 'png'" do
644
- doc = <<-eos
645
- = Hello, PlantUML!
646
- Doc Writer <doc@example.com>
647
-
648
- == First Section
649
-
650
- [plantuml,format="png"]
651
- ----
652
- :<latex>P(y|\\mathbf{x}) \\mbox{ or } f(\\mathbf{x})+\\epsilon</latex>;
653
- ----
654
- eos
655
-
656
- d = load_asciidoc doc
657
- expect(d).to_not be_nil
658
-
659
- b = d.find { |bl| bl.context == :image }
660
- expect(b).to_not be_nil
661
-
662
- expect(b.content_model).to eq :empty
663
-
664
- target = b.attributes['target']
665
- expect(target).to_not be_nil
666
- expect(target).to match(/\.png$/)
667
- expect(File.exist?(target)).to be true
668
-
669
- expect(b.attributes['width']).to_not be_nil
670
- expect(b.attributes['height']).to_not be_nil
671
- end
672
-
673
- it "should generate SVG images for diagrams with latex tags when format is set to 'svg'" do
674
- doc = <<-eos
675
- = Hello, PlantUML!
676
- Doc Writer <doc@example.com>
677
-
678
- == First Section
679
-
680
- [plantuml,format="svg"]
681
- ----
682
- :<latex>P(y|\\mathbf{x}) \\mbox{ or } f(\\mathbf{x})+\\epsilon</latex>;
683
- ----
684
- eos
685
-
686
- d = load_asciidoc doc
687
- expect(d).to_not be_nil
688
-
689
- b = d.find { |bl| bl.context == :image }
690
- expect(b).to_not be_nil
691
-
692
- expect(b.content_model).to eq :empty
693
-
694
- target = b.attributes['target']
695
- expect(target).to_not be_nil
696
- expect(target).to match(/\.svg$/)
697
- expect(File.exist?(target)).to be true
698
-
699
- expect(b.attributes['width']).to_not be_nil
700
- expect(b.attributes['height']).to_not be_nil
701
- end
702
-
703
- it "should report syntax errors" do
704
- doc = <<-eos
705
- = Hello, PlantUML!
706
- Doc Writer <doc@example.com>
707
-
708
- == First Section
709
-
710
- [plantuml,format="svg"]
711
- ----
712
- Bob; Alice; foo
713
- ----
714
- eos
715
-
716
- expect {
717
- load_asciidoc doc
718
- }.to raise_error(/syntax error/i)
719
- end
720
-
721
- it "should support complex preprocessor usage" do
722
- doc = <<-eos
723
- = Hello, PlantUML!
724
- Doc Writer <doc@example.com>
725
-
726
- == First Section
727
-
728
- [plantuml,format="png"]
729
- ----
730
- @startuml
731
- !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
732
-
733
- !define DEVICONS https://raw.githubusercontent.com/tupadr3/plantuml-icon-font-sprites/master/devicons
734
- !define FONTAWESOME https://raw.githubusercontent.com/tupadr3/plantuml-icon-font-sprites/master/font-awesome-5
735
- !include DEVICONS/angular.puml
736
- !include DEVICONS/java.puml
737
- !include DEVICONS/msql_server.puml
738
- !include FONTAWESOME/users.puml
739
-
740
- LAYOUT_WITH_LEGEND()
741
-
742
- Person(user, "Customer", "People that need products", "users")
743
- Container(spa, "SPA", "angular", "The main interface that the customer interacts with", "angular")
744
- Container(api, "API", "java", "Handles all business logic", "java")
745
- ContainerDb(db, "Database", "Microsoft SQL", "Holds product, order and invoice information", "msql_server")
746
-
747
- !$protocol ?= "https"
748
-
749
- Rel(user, spa, "Uses", $protocol)
750
- Rel(spa, api, "Uses", "https")
751
- Rel_R(api, db, "Reads/Writes")
752
- @enduml
753
- ----
754
- eos
755
-
756
- d = load_asciidoc doc
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
- expect(b.content_model).to eq :empty
763
-
764
- target = b.attributes['target']
765
- expect(target).to_not be_nil
766
- expect(target).to match(/\.png$/)
767
- expect(File.exist?(target)).to be true
768
-
769
- expect(b.attributes['width']).to_not be_nil
770
- expect(b.attributes['height']).to_not be_nil
771
- end
772
- end