asciidoctor-diagram 1.5.18 → 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.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +75 -0
  3. data/README.adoc +98 -23
  4. data/examples/features.adoc +2 -2
  5. data/lib/asciidoctor-diagram.rb +8 -0
  6. data/lib/asciidoctor-diagram/a2s/converter.rb +59 -0
  7. data/lib/asciidoctor-diagram/a2s/extension.rb +6 -52
  8. data/lib/asciidoctor-diagram/blockdiag/converter.rb +37 -0
  9. data/lib/asciidoctor-diagram/blockdiag/extension.rb +9 -116
  10. data/lib/asciidoctor-diagram/bpmn.rb +7 -0
  11. data/lib/asciidoctor-diagram/bpmn/converter.rb +62 -0
  12. data/lib/asciidoctor-diagram/bpmn/extension.rb +14 -0
  13. data/lib/asciidoctor-diagram/bytefield.rb +7 -0
  14. data/lib/asciidoctor-diagram/bytefield/converter.rb +26 -0
  15. data/lib/asciidoctor-diagram/bytefield/extension.rb +14 -0
  16. data/lib/asciidoctor-diagram/diagram_converter.rb +23 -0
  17. data/lib/asciidoctor-diagram/diagram_processor.rb +357 -0
  18. data/lib/asciidoctor-diagram/diagram_source.rb +322 -0
  19. data/lib/asciidoctor-diagram/ditaa/converter.rb +90 -0
  20. data/lib/asciidoctor-diagram/ditaa/extension.rb +6 -71
  21. data/lib/asciidoctor-diagram/dpic.rb +7 -0
  22. data/lib/asciidoctor-diagram/dpic/converter.rb +30 -0
  23. data/lib/asciidoctor-diagram/dpic/extension.rb +14 -0
  24. data/lib/asciidoctor-diagram/erd/converter.rb +31 -0
  25. data/lib/asciidoctor-diagram/erd/extension.rb +6 -35
  26. data/lib/asciidoctor-diagram/gnuplot.rb +7 -0
  27. data/lib/asciidoctor-diagram/gnuplot/converter.rb +63 -0
  28. data/lib/asciidoctor-diagram/gnuplot/extension.rb +14 -0
  29. data/lib/asciidoctor-diagram/graphviz/converter.rb +32 -0
  30. data/lib/asciidoctor-diagram/graphviz/extension.rb +6 -35
  31. data/lib/asciidoctor-diagram/http/converter.rb +99 -0
  32. data/lib/asciidoctor-diagram/http/server.rb +132 -0
  33. data/lib/asciidoctor-diagram/lilypond.rb +7 -0
  34. data/lib/asciidoctor-diagram/lilypond/converter.rb +54 -0
  35. data/lib/asciidoctor-diagram/lilypond/extension.rb +14 -0
  36. data/lib/asciidoctor-diagram/meme/converter.rb +122 -0
  37. data/lib/asciidoctor-diagram/meme/extension.rb +5 -107
  38. data/lib/asciidoctor-diagram/mermaid/converter.rb +179 -0
  39. data/lib/asciidoctor-diagram/mermaid/extension.rb +6 -159
  40. data/lib/asciidoctor-diagram/msc/converter.rb +35 -0
  41. data/lib/asciidoctor-diagram/msc/extension.rb +6 -36
  42. data/lib/asciidoctor-diagram/nomnoml/converter.rb +25 -0
  43. data/lib/asciidoctor-diagram/nomnoml/extension.rb +6 -28
  44. data/lib/asciidoctor-diagram/pikchr.rb +7 -0
  45. data/lib/asciidoctor-diagram/pikchr/converter.rb +26 -0
  46. data/lib/asciidoctor-diagram/pikchr/extension.rb +14 -0
  47. data/lib/asciidoctor-diagram/plantuml/converter.rb +117 -0
  48. data/lib/asciidoctor-diagram/plantuml/extension.rb +10 -119
  49. data/lib/asciidoctor-diagram/shaape/converter.rb +25 -0
  50. data/lib/asciidoctor-diagram/shaape/extension.rb +6 -28
  51. data/lib/asciidoctor-diagram/smcat.rb +7 -0
  52. data/lib/asciidoctor-diagram/smcat/converter.rb +44 -0
  53. data/lib/asciidoctor-diagram/smcat/extension.rb +14 -0
  54. data/lib/asciidoctor-diagram/svgbob/converter.rb +49 -0
  55. data/lib/asciidoctor-diagram/svgbob/extension.rb +6 -28
  56. data/lib/asciidoctor-diagram/symbolator.rb +7 -0
  57. data/lib/asciidoctor-diagram/symbolator/converter.rb +23 -0
  58. data/lib/asciidoctor-diagram/symbolator/extension.rb +14 -0
  59. data/lib/asciidoctor-diagram/syntrax/converter.rb +58 -0
  60. data/lib/asciidoctor-diagram/syntrax/extension.rb +6 -51
  61. data/lib/asciidoctor-diagram/tikz/converter.rb +56 -0
  62. data/lib/asciidoctor-diagram/tikz/extension.rb +6 -60
  63. data/lib/asciidoctor-diagram/umlet/converter.rb +24 -0
  64. data/lib/asciidoctor-diagram/umlet/extension.rb +6 -28
  65. data/lib/asciidoctor-diagram/util/cli.rb +14 -3
  66. data/lib/asciidoctor-diagram/util/cli_generator.rb +19 -1
  67. data/lib/asciidoctor-diagram/util/gif.rb +2 -2
  68. data/lib/asciidoctor-diagram/util/java.rb +1 -1
  69. data/lib/asciidoctor-diagram/util/java_socket.rb +7 -9
  70. data/lib/asciidoctor-diagram/util/pdf.rb +2 -2
  71. data/lib/asciidoctor-diagram/util/png.rb +2 -2
  72. data/lib/asciidoctor-diagram/util/svg.rb +46 -19
  73. data/lib/asciidoctor-diagram/util/which.rb +0 -29
  74. data/lib/asciidoctor-diagram/vega/converter.rb +47 -0
  75. data/lib/asciidoctor-diagram/vega/extension.rb +6 -44
  76. data/lib/asciidoctor-diagram/version.rb +1 -1
  77. data/lib/asciidoctor-diagram/wavedrom/converter.rb +50 -0
  78. data/lib/asciidoctor-diagram/wavedrom/extension.rb +6 -46
  79. data/lib/ditaa-1.3.15.jar +0 -0
  80. data/lib/ditaamini-0.12.jar +0 -0
  81. data/lib/plantuml-1.3.15.jar +0 -0
  82. data/lib/plantuml.jar +0 -0
  83. data/lib/server-1.3.15.jar +0 -0
  84. data/spec/a2s_spec.rb +2 -140
  85. data/spec/blockdiag_spec.rb +2 -200
  86. data/spec/bpmn_spec.rb +56 -0
  87. data/spec/bytefield_spec.rb +92 -0
  88. data/spec/ditaa_spec.rb +37 -143
  89. data/spec/dpic_spec.rb +19 -0
  90. data/spec/erd_spec.rb +2 -199
  91. data/spec/gnuplot_spec.rb +225 -0
  92. data/spec/graphviz_spec.rb +6 -145
  93. data/spec/lilypond_spec.rb +13 -0
  94. data/spec/mermaid_spec.rb +35 -200
  95. data/spec/msc_spec.rb +2 -199
  96. data/spec/nomnoml_spec.rb +4 -142
  97. data/spec/pikchr_spec.rb +51 -0
  98. data/spec/plantuml_spec.rb +24 -507
  99. data/spec/shaape_spec.rb +9 -221
  100. data/spec/shared_examples.rb +552 -0
  101. data/spec/smcat_spec.rb +26 -0
  102. data/spec/svgbob_spec.rb +2 -140
  103. data/spec/symbolator_spec.rb +23 -0
  104. data/spec/syntrax_spec.rb +5 -215
  105. data/spec/test_helper.rb +1 -18
  106. data/spec/tikz_spec.rb +4 -24
  107. data/spec/umlet_spec.rb +2 -58
  108. data/spec/vega_spec.rb +4 -117
  109. data/spec/wavedrom_spec.rb +2 -199
  110. metadata +73 -11
  111. data/lib/asciidoctor-diagram/extensions.rb +0 -568
  112. data/lib/ditaa-1.3.13.jar +0 -0
  113. data/lib/ditaamini-0.11.jar +0 -0
  114. data/lib/plantuml-1.3.13.jar +0 -0
  115. data/lib/server-1.3.13.jar +0 -0
@@ -0,0 +1,19 @@
1
+ require_relative 'test_helper'
2
+
3
+ code = <<-eos
4
+ arrow "$u$" above
5
+ S: circle rad 10/72.27 # 10 pt
6
+ line right 0.35
7
+ G: box "$G(s)$"
8
+ arrow "$y$" above
9
+ line -> down G.ht from last arrow then left last arrow.c.x-S.x then to S.s
10
+ "$-\;$" below rjust
11
+ eos
12
+
13
+ describe Asciidoctor::Diagram::DpicBlockMacroProcessor, :broken_on_travis, :broken_on_windows do
14
+ include_examples "block_macro", :dpic, code, [:svg]
15
+ end
16
+
17
+ describe Asciidoctor::Diagram::DpicBlockProcessor, :broken_on_travis, :broken_on_windows do
18
+ include_examples "block", :dpic, code, [:svg]
19
+ end
@@ -84,206 +84,9 @@ player 1--* play_player
84
84
  eos
85
85
 
86
86
  describe Asciidoctor::Diagram::ErdBlockMacroProcessor, :broken_on_travis, :broken_on_windows do
87
- it "should generate PNG images when format is set to 'png'" do
88
- File.write('erd.txt', code)
89
-
90
- doc = <<-eos
91
- = Hello, Erd!
92
- Doc Writer <doc@example.com>
93
-
94
- == First Section
95
-
96
- erd::erd.txt[format="png"]
97
- eos
98
-
99
- d = load_asciidoc doc
100
- expect(d).to_not be_nil
101
-
102
- b = d.find { |bl| bl.context == :image }
103
- expect(b).to_not be_nil
104
-
105
- expect(b.content_model).to eq :empty
106
-
107
- target = b.attributes['target']
108
- expect(target).to_not be_nil
109
- expect(target).to match(/\.png$/)
110
- expect(File.exist?(target)).to be true
111
-
112
- expect(b.attributes['width']).to_not be_nil
113
- expect(b.attributes['height']).to_not be_nil
114
- end
115
-
116
- it "should generate SVG images when format is set to 'svg'" do
117
- File.write('erd.txt', code)
118
-
119
- doc = <<-eos
120
- = Hello, Erd!
121
- Doc Writer <doc@example.com>
122
-
123
- == First Section
124
-
125
- erd::erd.txt[format="svg"]
126
- eos
127
-
128
- d = load_asciidoc doc
129
- expect(d).to_not be_nil
130
-
131
- b = d.find { |bl| bl.context == :image }
132
- expect(b).to_not be_nil
133
-
134
- expect(b.content_model).to eq :empty
135
-
136
- target = b.attributes['target']
137
- expect(target).to_not be_nil
138
- expect(target).to match(/\.svg/)
139
- expect(File.exist?(target)).to be true
140
-
141
- expect(b.attributes['width']).to_not be_nil
142
- expect(b.attributes['height']).to_not be_nil
143
- end
87
+ include_examples "block_macro", :erd, code, [:svg]
144
88
  end
145
89
 
146
90
  describe Asciidoctor::Diagram::ErdBlockProcessor, :broken_on_travis, :broken_on_windows do
147
- it "should generate PNG images when format is set to 'png'" do
148
- doc = <<-eos
149
- = Hello, Erd!
150
- Doc Writer <doc@example.com>
151
-
152
- == First Section
153
-
154
- [erd, format="png"]
155
- ----
156
- #{code}
157
- ----
158
- eos
159
-
160
- d = load_asciidoc doc
161
- expect(d).to_not be_nil
162
-
163
- b = d.find { |bl| bl.context == :image }
164
- expect(b).to_not be_nil
165
-
166
- expect(b.content_model).to eq :empty
167
-
168
- target = b.attributes['target']
169
- expect(target).to_not be_nil
170
- expect(target).to match(/\.png$/)
171
- expect(File.exist?(target)).to be true
172
-
173
- expect(b.attributes['width']).to_not be_nil
174
- expect(b.attributes['height']).to_not be_nil
175
- end
176
-
177
- it "should generate SVG images when format is set to 'svg'" do
178
- doc = <<-eos
179
- = Hello, Erd!
180
- Doc Writer <doc@example.com>
181
-
182
- == First Section
183
-
184
- [erd, format="svg"]
185
- ----
186
- #{code}
187
- ----
188
- eos
189
-
190
- d = load_asciidoc doc
191
- expect(d).to_not be_nil
192
-
193
- b = d.find { |bl| bl.context == :image }
194
- expect(b).to_not be_nil
195
-
196
- expect(b.content_model).to eq :empty
197
-
198
- target = b.attributes['target']
199
- expect(target).to_not be_nil
200
- expect(target).to match(/\.svg/)
201
- expect(File.exist?(target)).to be true
202
-
203
- expect(b.attributes['width']).to_not be_nil
204
- expect(b.attributes['height']).to_not be_nil
205
- end
206
-
207
- it "should raise an error when when format is set to an invalid value" do
208
- doc = <<-eos
209
- = Hello, Erd!
210
- Doc Writer <doc@example.com>
211
-
212
- == First Section
213
-
214
- [erd, format="foobar"]
215
- ----
216
- ----
217
- eos
218
-
219
- expect { load_asciidoc doc }.to raise_error(/support.*format/i)
220
- end
221
-
222
- it "should not regenerate images when source has not changed" do
223
- File.write('erd.txt', code)
224
-
225
- doc = <<-eos
226
- = Hello, Erd!
227
- Doc Writer <doc@example.com>
228
-
229
- == First Section
230
-
231
- erd::erd.txt
232
-
233
- [erd, format="png"]
234
- ----
235
- #{code}
236
- ----
237
- eos
238
-
239
- d = load_asciidoc doc
240
- b = d.find { |bl| bl.context == :image }
241
- expect(b).to_not be_nil
242
- target = b.attributes['target']
243
- mtime1 = File.mtime(target)
244
-
245
- sleep 1
246
-
247
- d = load_asciidoc doc
248
-
249
- mtime2 = File.mtime(target)
250
-
251
- expect(mtime2).to eq mtime1
252
- end
253
-
254
- it "should handle two block macros with the same source" do
255
- File.write('erd.txt', code)
256
-
257
- doc = <<-eos
258
- = Hello, Erd!
259
- Doc Writer <doc@example.com>
260
-
261
- == First Section
262
-
263
- erd::erd.txt[]
264
- erd::erd.txt[]
265
- eos
266
-
267
- load_asciidoc doc
268
- expect(File.exist?('erd.png')).to be true
269
- end
270
-
271
- it "should respect target attribute in block macros" do
272
- File.write('erd.txt', code)
273
-
274
- doc = <<-eos
275
- = Hello, Erd!
276
- Doc Writer <doc@example.com>
277
-
278
- == First Section
279
-
280
- erd::erd.txt["foobar"]
281
- erd::erd.txt["foobaz"]
282
- eos
283
-
284
- load_asciidoc doc
285
- expect(File.exist?('foobar.png')).to be true
286
- expect(File.exist?('foobaz.png')).to be true
287
- expect(File.exist?('erd.png')).to be false
288
- end
91
+ include_examples "block", :erd, code, [:svg]
289
92
  end
@@ -0,0 +1,225 @@
1
+ require_relative 'test_helper'
2
+
3
+ code = <<-eos
4
+ plot [0:5][0:20] x**2 title 'O(n^2)'
5
+ eos
6
+
7
+ describe Asciidoctor::Diagram::GnuplotBlockMacroProcessor do
8
+ include_examples "block_macro", :gnuplot, code, [:png, :svg, :gif, :txt]
9
+ end
10
+
11
+ describe Asciidoctor::Diagram::GnuplotBlockProcessor do
12
+ include_examples "block", :gnuplot, code, [:png, :svg, :gif, :txt]
13
+
14
+ it "should generate images with user defined size" do
15
+ doc = <<-eos
16
+ = Hello, Gnuplot!
17
+ Doc Writer <doc@example.com>
18
+
19
+ == First Section
20
+
21
+ [gnuplot, format="png",width="800", height="600"]
22
+ ----
23
+ #{code}
24
+ ----
25
+ eos
26
+
27
+ d = load_asciidoc doc
28
+ expect(d).to_not be_nil
29
+
30
+ b = d.find { |bl| bl.context == :image }
31
+ expect(b).to_not be_nil
32
+
33
+ expect(b.content_model).to eq :empty
34
+
35
+ target = b.attributes['target']
36
+ expect(target).to_not be_nil
37
+ expect(target).to match(/\.png$/)
38
+ expect(File.exist?(target)).to be true
39
+
40
+ expect(b.attributes['width']).to_not be_nil
41
+ expect(b.attributes['height']).to_not be_nil
42
+ end
43
+
44
+ it "should generate nocrop/notrasparent images" do
45
+ doc = <<-eos
46
+ = Hello, Gnuplot!
47
+ Doc Writer <doc@example.com>
48
+
49
+ == First Section
50
+
51
+ [gnuplot, format="png", crop=false, transparent=false]
52
+ ----
53
+ #{code}
54
+ ----
55
+ eos
56
+
57
+ d = load_asciidoc doc
58
+ expect(d).to_not be_nil
59
+
60
+ b = d.find { |bl| bl.context == :image }
61
+ expect(b).to_not be_nil
62
+
63
+ expect(b.content_model).to eq :empty
64
+
65
+ target = b.attributes['target']
66
+ expect(target).to_not be_nil
67
+ expect(target).to match(/\.png$/)
68
+ expect(File.exist?(target)).to be true
69
+
70
+ expect(b.attributes['width']).to_not be_nil
71
+ expect(b.attributes['height']).to_not be_nil
72
+ end
73
+
74
+ it "should generate crop/trasparent images" do
75
+ doc = <<-eos
76
+ = Hello, Gnuplot!
77
+ Doc Writer <doc@example.com>
78
+
79
+ == First Section
80
+
81
+ [gnuplot, format="png", crop=true, transparent=true]
82
+ ----
83
+ #{code}
84
+ ----
85
+ eos
86
+
87
+ d = load_asciidoc doc
88
+ expect(d).to_not be_nil
89
+
90
+ b = d.find { |bl| bl.context == :image }
91
+ expect(b).to_not be_nil
92
+
93
+ expect(b.content_model).to eq :empty
94
+
95
+ target = b.attributes['target']
96
+ expect(target).to_not be_nil
97
+ expect(target).to match(/\.png$/)
98
+ expect(File.exist?(target)).to be true
99
+
100
+ expect(b.attributes['width']).to_not be_nil
101
+ expect(b.attributes['height']).to_not be_nil
102
+ end
103
+
104
+ it "should generate image with font name" do
105
+ doc = <<-eos
106
+ = Hello, Gnuplot!
107
+ Doc Writer <doc@example.com>
108
+
109
+ == First Section
110
+
111
+ [gnuplot, format="png", font="Arial"]
112
+ ----
113
+ #{code}
114
+ ----
115
+ eos
116
+
117
+ d = load_asciidoc doc
118
+ expect(d).to_not be_nil
119
+
120
+ b = d.find { |bl| bl.context == :image }
121
+ expect(b).to_not be_nil
122
+
123
+ expect(b.content_model).to eq :empty
124
+
125
+ target = b.attributes['target']
126
+ expect(target).to_not be_nil
127
+ expect(target).to match(/\.png$/)
128
+ expect(File.exist?(target)).to be true
129
+
130
+ expect(b.attributes['width']).to_not be_nil
131
+ expect(b.attributes['height']).to_not be_nil
132
+ end
133
+
134
+ it "should generate image with font name and size" do
135
+ doc = <<-eos
136
+ = Hello, Gnuplot!
137
+ Doc Writer <doc@example.com>
138
+
139
+ == First Section
140
+
141
+ [gnuplot, format="png", font="Arial,11"]
142
+ ----
143
+ #{code}
144
+ ----
145
+ eos
146
+
147
+ d = load_asciidoc doc
148
+ expect(d).to_not be_nil
149
+
150
+ b = d.find { |bl| bl.context == :image }
151
+ expect(b).to_not be_nil
152
+
153
+ expect(b.content_model).to eq :empty
154
+
155
+ target = b.attributes['target']
156
+ expect(target).to_not be_nil
157
+ expect(target).to match(/\.png$/)
158
+ expect(File.exist?(target)).to be true
159
+
160
+ expect(b.attributes['width']).to_not be_nil
161
+ expect(b.attributes['height']).to_not be_nil
162
+ end
163
+
164
+ it "should generate image with font name and scale" do
165
+ doc = <<-eos
166
+ = Hello, Gnuplot!
167
+ Doc Writer <doc@example.com>
168
+
169
+ == First Section
170
+
171
+ [gnuplot, format="png", font="Arial", scale="0.5"]
172
+ ----
173
+ #{code}
174
+ ----
175
+ eos
176
+
177
+ d = load_asciidoc doc
178
+ expect(d).to_not be_nil
179
+
180
+ b = d.find { |bl| bl.context == :image }
181
+ expect(b).to_not be_nil
182
+
183
+ expect(b.content_model).to eq :empty
184
+
185
+ target = b.attributes['target']
186
+ expect(target).to_not be_nil
187
+ expect(target).to match(/\.png$/)
188
+ expect(File.exist?(target)).to be true
189
+
190
+ expect(b.attributes['width']).to_not be_nil
191
+ expect(b.attributes['height']).to_not be_nil
192
+ end
193
+
194
+ it %(should generate image with font background="red") do
195
+ doc = <<-eos
196
+ = Hello, Gnuplot!
197
+ Doc Writer <doc@example.com>
198
+
199
+ == First Section
200
+
201
+ [gnuplot, format="png", background="red"]
202
+ ----
203
+ #{code}
204
+ ----
205
+ eos
206
+
207
+ d = load_asciidoc doc
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
+ expect(b.content_model).to eq :empty
214
+
215
+ target = b.attributes['target']
216
+ expect(target).to_not be_nil
217
+ expect(target).to match(/\.png$/)
218
+ expect(File.exist?(target)).to be true
219
+
220
+ expect(b.attributes['width']).to_not be_nil
221
+ expect(b.attributes['height']).to_not be_nil
222
+ end
223
+
224
+
225
+ end