asciidoctor-diagram 2.0.2 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +25 -0
  3. data/README.adoc +13 -4
  4. data/lib/asciidoctor-diagram.rb +3 -0
  5. data/lib/asciidoctor-diagram/a2s/converter.rb +10 -6
  6. data/lib/asciidoctor-diagram/blockdiag/converter.rb +1 -1
  7. data/lib/asciidoctor-diagram/bpmn/converter.rb +3 -3
  8. data/lib/asciidoctor-diagram/diagram_converter.rb +5 -1
  9. data/lib/asciidoctor-diagram/diagram_processor.rb +64 -38
  10. data/lib/asciidoctor-diagram/diagram_source.rb +64 -17
  11. data/lib/asciidoctor-diagram/ditaa/converter.rb +6 -2
  12. data/lib/asciidoctor-diagram/dpic.rb +7 -0
  13. data/lib/asciidoctor-diagram/dpic/converter.rb +30 -0
  14. data/lib/asciidoctor-diagram/dpic/extension.rb +14 -0
  15. data/lib/asciidoctor-diagram/gnuplot/converter.rb +8 -8
  16. data/lib/asciidoctor-diagram/graphviz/converter.rb +2 -2
  17. data/lib/asciidoctor-diagram/http/converter.rb +25 -5
  18. data/lib/asciidoctor-diagram/http/server.rb +10 -5
  19. data/lib/asciidoctor-diagram/lilypond/converter.rb +2 -2
  20. data/lib/asciidoctor-diagram/meme/converter.rb +7 -7
  21. data/lib/asciidoctor-diagram/mermaid/converter.rb +16 -15
  22. data/lib/asciidoctor-diagram/msc/converter.rb +2 -2
  23. data/lib/asciidoctor-diagram/pikchr.rb +7 -0
  24. data/lib/asciidoctor-diagram/pikchr/converter.rb +26 -0
  25. data/lib/asciidoctor-diagram/pikchr/extension.rb +14 -0
  26. data/lib/asciidoctor-diagram/plantuml/converter.rb +3 -3
  27. data/lib/asciidoctor-diagram/smcat/converter.rb +3 -3
  28. data/lib/asciidoctor-diagram/svgbob/converter.rb +2 -2
  29. data/lib/asciidoctor-diagram/symbolator.rb +7 -0
  30. data/lib/asciidoctor-diagram/symbolator/converter.rb +23 -0
  31. data/lib/asciidoctor-diagram/symbolator/extension.rb +14 -0
  32. data/lib/asciidoctor-diagram/syntrax/converter.rb +9 -6
  33. data/lib/asciidoctor-diagram/util/cli_generator.rb +18 -0
  34. data/lib/asciidoctor-diagram/util/gif.rb +2 -2
  35. data/lib/asciidoctor-diagram/util/pdf.rb +2 -2
  36. data/lib/asciidoctor-diagram/util/png.rb +2 -2
  37. data/lib/asciidoctor-diagram/util/svg.rb +46 -19
  38. data/lib/asciidoctor-diagram/vega/converter.rb +2 -2
  39. data/lib/asciidoctor-diagram/version.rb +1 -1
  40. data/spec/a2s_spec.rb +2 -140
  41. data/spec/blockdiag_spec.rb +2 -200
  42. data/spec/bpmn_spec.rb +52 -92
  43. data/spec/bytefield_spec.rb +2 -140
  44. data/spec/ditaa_spec.rb +5 -143
  45. data/spec/dpic_spec.rb +19 -0
  46. data/spec/erd_spec.rb +2 -199
  47. data/spec/gnuplot_spec.rb +2 -255
  48. data/spec/graphviz_spec.rb +6 -145
  49. data/spec/lilypond_spec.rb +2 -140
  50. data/spec/mermaid_spec.rb +2 -199
  51. data/spec/msc_spec.rb +2 -199
  52. data/spec/nomnoml_spec.rb +4 -142
  53. data/spec/pikchr_spec.rb +51 -0
  54. data/spec/plantuml_spec.rb +6 -578
  55. data/spec/shaape_spec.rb +9 -221
  56. data/spec/shared_examples.rb +552 -0
  57. data/spec/smcat_spec.rb +2 -140
  58. data/spec/svgbob_spec.rb +2 -140
  59. data/spec/symbolator_spec.rb +23 -0
  60. data/spec/syntrax_spec.rb +5 -215
  61. data/spec/test_helper.rb +1 -22
  62. data/spec/tikz_spec.rb +4 -24
  63. data/spec/umlet_spec.rb +2 -58
  64. data/spec/vega_spec.rb +4 -117
  65. data/spec/wavedrom_spec.rb +2 -199
  66. metadata +20 -6
  67. data/spec/bpmn-example.xml +0 -44
@@ -6,29 +6,8 @@ require 'stringio'
6
6
  require 'tmpdir'
7
7
 
8
8
  require_relative '../lib/asciidoctor-diagram'
9
- require_relative '../lib/asciidoctor-diagram/a2s/extension'
10
- require_relative '../lib/asciidoctor-diagram/blockdiag/extension'
11
- require_relative '../lib/asciidoctor-diagram/bytefield'
12
- require_relative '../lib/asciidoctor-diagram/ditaa/extension'
13
- require_relative '../lib/asciidoctor-diagram/erd/extension'
14
- require_relative '../lib/asciidoctor-diagram/gnuplot/extension'
15
- require_relative '../lib/asciidoctor-diagram/graphviz/extension'
16
- require_relative '../lib/asciidoctor-diagram/lilypond/extension'
17
- require_relative '../lib/asciidoctor-diagram/meme/extension'
18
- require_relative '../lib/asciidoctor-diagram/mermaid/extension'
19
- require_relative '../lib/asciidoctor-diagram/msc/extension'
20
- require_relative '../lib/asciidoctor-diagram/nomnoml/extension'
21
- require_relative '../lib/asciidoctor-diagram/plantuml/extension'
22
- require_relative '../lib/asciidoctor-diagram/shaape/extension'
23
- require_relative '../lib/asciidoctor-diagram/smcat/extension'
24
- require_relative '../lib/asciidoctor-diagram/svgbob/extension'
25
- require_relative '../lib/asciidoctor-diagram/syntrax/extension'
26
- require_relative '../lib/asciidoctor-diagram/tikz/extension'
27
- require_relative '../lib/asciidoctor-diagram/umlet/extension'
28
- require_relative '../lib/asciidoctor-diagram/vega/extension'
29
- require_relative '../lib/asciidoctor-diagram/wavedrom/extension'
30
-
31
9
  require_relative '../lib/asciidoctor-diagram/util/platform'
10
+ require_relative 'shared_examples'
32
11
 
33
12
  module Asciidoctor
34
13
  class AbstractBlock
@@ -99,29 +99,9 @@ code = <<-'eos'
99
99
  eos
100
100
 
101
101
  describe Asciidoctor::Diagram::TikZBlockMacroProcessor, :broken_on_travis, :broken_on_windows do
102
- it "should generate PDF images when format is set to 'pdf'" do
103
- File.write('tikz.txt', code)
102
+ include_examples "block_macro", :tikz, code, [:pdf]
103
+ end
104
104
 
105
- doc = <<-eos
106
- = Hello, Tikz!
107
- Doc Writer <doc@example.com>
108
-
109
- == First Section
110
-
111
- tikz::tikz.txt[format="pdf"]
112
- eos
113
-
114
- d = load_asciidoc doc
115
- expect(d).to_not be_nil
116
-
117
- b = d.find { |bl| bl.context == :image }
118
- expect(b).to_not be_nil
119
-
120
- expect(b.content_model).to eq :empty
121
-
122
- target = b.attributes['target']
123
- expect(target).to_not be_nil
124
- expect(target).to match(/\.pdf/)
125
- expect(File.exist?(target)).to be true
126
- end
105
+ describe Asciidoctor::Diagram::TikZBlockProcessor, :broken_on_travis, :broken_on_windows do
106
+ include_examples "block", :tikz, code, [:pdf]
127
107
  end
@@ -21,65 +21,9 @@ eos
21
21
 
22
22
 
23
23
  describe Asciidoctor::Diagram::UmletBlockMacroProcessor do
24
- it "should generate SVG images when format omitted" do
25
- File.write('umlet.uxf', code)
26
-
27
- doc = <<-eos
28
- = Hello, Umlet!
29
- Doc Writer <doc@example.com>
30
-
31
- == First Section
32
-
33
- umlet::umlet.uxf[]
34
- eos
35
-
36
- d = load_asciidoc doc
37
- expect(d).to_not be_nil
38
-
39
- b = d.find { |bl| bl.context == :image }
40
- expect(b).to_not be_nil
41
-
42
- expect(b.content_model).to eq :empty
43
-
44
- target = b.attributes['target']
45
- expect(target).to_not be_nil
46
- expect(target).to match(/\.svg$/)
47
- expect(File.exist?(target)).to be true
48
-
49
- expect(b.attributes['width']).to_not be_nil
50
- expect(b.attributes['height']).to_not be_nil
51
- end
24
+ include_examples "block_macro", :umlet, code, [:svg]
52
25
  end
53
26
 
54
-
55
27
  describe Asciidoctor::Diagram::UmletBlockProcessor do
56
- it "should generate SVG images when format is omitted" do
57
- doc = <<-eos
58
- = Hello, Umlet!
59
- Doc Writer <doc@example.com>
60
-
61
- == First Section
62
-
63
- [umlet]
64
- ----
65
- #{code}
66
- ----
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", :umlet, code, [:svg]
85
29
  end
@@ -118,124 +118,11 @@ vegalite_code = <<-eos
118
118
  eos
119
119
 
120
120
  describe Asciidoctor::Diagram::VegaBlockMacroProcessor, :broken_on_windows do
121
- it "should generate vega SVG images when format omitted" do
122
- File.write('vega.json', vega_code)
123
-
124
- doc = <<-eos
125
- = Hello, Vega!
126
- Doc Writer <doc@example.com>
127
-
128
- == First Section
129
-
130
- vega::vega.json[]
131
- eos
132
-
133
- d = load_asciidoc doc
134
- expect(d).to_not be_nil
135
-
136
- b = d.find { |bl| bl.context == :image }
137
- expect(b).to_not be_nil
138
-
139
- expect(b.content_model).to eq :empty
140
-
141
- target = b.attributes['target']
142
- expect(target).to_not be_nil
143
- expect(target).to match(/\.svg$/)
144
- expect(File.exist?(target)).to be true
145
-
146
- expect(b.attributes['width']).to_not be_nil
147
- expect(b.attributes['height']).to_not be_nil
148
- end
149
-
150
- it "should generate vegalite SVG images when format omitted" do
151
- File.write('vega.json', vegalite_code)
152
-
153
- doc = <<-eos
154
- = Hello, Vega!
155
- Doc Writer <doc@example.com>
156
-
157
- == First Section
158
-
159
- vegalite::vega.json[]
160
- eos
161
-
162
- d = load_asciidoc doc
163
- expect(d).to_not be_nil
164
-
165
- b = d.find { |bl| bl.context == :image }
166
- expect(b).to_not be_nil
167
-
168
- expect(b.content_model).to eq :empty
169
-
170
- target = b.attributes['target']
171
- expect(target).to_not be_nil
172
- expect(target).to match(/\.svg$/)
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
121
+ include_examples "block_macro", :vega, vega_code, [:svg]
122
+ # include_examples "block_macro", :vegalite, vegalite_code, [:svg]
178
123
  end
179
124
 
180
-
181
125
  describe Asciidoctor::Diagram::VegaBlockProcessor, :broken_on_windows do
182
- it "should generate vega SVG images when format is omitted" do
183
- doc = <<-eos
184
- = Hello, Vega!
185
- Doc Writer <doc@example.com>
186
-
187
- == First Section
188
-
189
- [vega]
190
- ----
191
- #{vega_code}
192
- ----
193
- eos
194
-
195
- d = load_asciidoc doc
196
- expect(d).to_not be_nil
197
-
198
- b = d.find { |bl| bl.context == :image }
199
- expect(b).to_not be_nil
200
-
201
- expect(b.content_model).to eq :empty
202
-
203
- target = b.attributes['target']
204
- expect(target).to_not be_nil
205
- expect(target).to match(/\.svg$/)
206
- expect(File.exist?(target)).to be true
207
-
208
- expect(b.attributes['width']).to_not be_nil
209
- expect(b.attributes['height']).to_not be_nil
210
- end
211
-
212
- it "should generate vegalite SVG images when format is omitted" do
213
- doc = <<-eos
214
- = Hello, Vega!
215
- Doc Writer <doc@example.com>
216
-
217
- == First Section
218
-
219
- [vegalite]
220
- ----
221
- #{vegalite_code}
222
- ----
223
- eos
224
-
225
- d = load_asciidoc doc
226
- expect(d).to_not be_nil
227
-
228
- b = d.find { |bl| bl.context == :image }
229
- expect(b).to_not be_nil
230
-
231
- expect(b.content_model).to eq :empty
232
-
233
- target = b.attributes['target']
234
- expect(target).to_not be_nil
235
- expect(target).to match(/\.svg$/)
236
- expect(File.exist?(target)).to be true
237
-
238
- expect(b.attributes['width']).to_not be_nil
239
- expect(b.attributes['height']).to_not be_nil
240
- end
126
+ include_examples "block", :vega, vega_code, [:svg]
127
+ # include_examples "block", :vegalite, vegalite_code, [:svg]
241
128
  end
@@ -9,206 +9,9 @@ code = <<-eos
9
9
  eos
10
10
 
11
11
  describe Asciidoctor::Diagram::WavedromBlockMacroProcessor, :broken_on_windows do
12
- it "should generate PNG images when format is set to 'png'" do
13
- File.write('wavedrom.txt', code)
14
-
15
- doc = <<-eos
16
- = Hello, Wavedrom!
17
- Doc Writer <doc@example.com>
18
-
19
- == First Section
20
-
21
- wavedrom::wavedrom.txt[format="png"]
22
- eos
23
-
24
- d = load_asciidoc doc
25
- expect(d).to_not be_nil
26
-
27
- b = d.find { |bl| bl.context == :image }
28
- expect(b).to_not be_nil
29
-
30
- expect(b.content_model).to eq :empty
31
-
32
- target = b.attributes['target']
33
- expect(target).to_not be_nil
34
- expect(target).to match(/\.png$/)
35
- expect(File.exist?(target)).to be true
36
-
37
- expect(b.attributes['width']).to_not be_nil
38
- expect(b.attributes['height']).to_not be_nil
39
- end
40
-
41
- it "should generate SVG images when format is set to 'svg'" do
42
- File.write('wavedrom.txt', code)
43
-
44
- doc = <<-eos
45
- = Hello, Wavedrom!
46
- Doc Writer <doc@example.com>
47
-
48
- == First Section
49
-
50
- wavedrom::wavedrom.txt[format="svg"]
51
- eos
52
-
53
- d = load_asciidoc doc
54
- expect(d).to_not be_nil
55
-
56
- b = d.find { |bl| bl.context == :image }
57
- expect(b).to_not be_nil
58
-
59
- expect(b.content_model).to eq :empty
60
-
61
- target = b.attributes['target']
62
- expect(target).to_not be_nil
63
- expect(target).to match(/\.svg/)
64
- expect(File.exist?(target)).to be true
65
-
66
- expect(b.attributes['width']).to_not be_nil
67
- expect(b.attributes['height']).to_not be_nil
68
- end
12
+ include_examples "block_macro", :wavedrom, code, [:png, :svg]
69
13
  end
70
14
 
71
15
  describe Asciidoctor::Diagram::WavedromBlockProcessor, :broken_on_windows do
72
- it "should generate PNG images when format is set to 'png'" do
73
- doc = <<-eos
74
- = Hello, Wavedrom!
75
- Doc Writer <doc@example.com>
76
-
77
- == First Section
78
-
79
- [wavedrom, format="png"]
80
- ----
81
- #{code}
82
- ----
83
- eos
84
-
85
- d = load_asciidoc doc
86
- expect(d).to_not be_nil
87
-
88
- b = d.find { |bl| bl.context == :image }
89
- expect(b).to_not be_nil
90
-
91
- expect(b.content_model).to eq :empty
92
-
93
- target = b.attributes['target']
94
- expect(target).to_not be_nil
95
- expect(target).to match(/\.png$/)
96
- expect(File.exist?(target)).to be true
97
-
98
- expect(b.attributes['width']).to_not be_nil
99
- expect(b.attributes['height']).to_not be_nil
100
- end
101
-
102
- it "should generate SVG images when format is set to 'svg'" do
103
- doc = <<-eos
104
- = Hello, Wavedrom!
105
- Doc Writer <doc@example.com>
106
-
107
- == First Section
108
-
109
- [wavedrom, format="svg"]
110
- ----
111
- #{code}
112
- ----
113
- eos
114
-
115
- d = load_asciidoc doc
116
- expect(d).to_not be_nil
117
-
118
- b = d.find { |bl| bl.context == :image }
119
- expect(b).to_not be_nil
120
-
121
- expect(b.content_model).to eq :empty
122
-
123
- target = b.attributes['target']
124
- expect(target).to_not be_nil
125
- expect(target).to match(/\.svg/)
126
- expect(File.exist?(target)).to be true
127
-
128
- expect(b.attributes['width']).to_not be_nil
129
- expect(b.attributes['height']).to_not be_nil
130
- end
131
-
132
- it "should raise an error when when format is set to an invalid value" do
133
- doc = <<-eos
134
- = Hello, Wavedrom!
135
- Doc Writer <doc@example.com>
136
-
137
- == First Section
138
-
139
- [wavedrom, format="foobar"]
140
- ----
141
- ----
142
- eos
143
-
144
- expect { load_asciidoc doc }.to raise_error(/support.*format/i)
145
- end
146
-
147
- it "should not regenerate images when source has not changed" do
148
- File.write('wavedrom.txt', code)
149
-
150
- doc = <<-eos
151
- = Hello, Wavedrom!
152
- Doc Writer <doc@example.com>
153
-
154
- == First Section
155
-
156
- wavedrom::wavedrom.txt
157
-
158
- [wavedrom, format="png"]
159
- ----
160
- #{code}
161
- ----
162
- eos
163
-
164
- d = load_asciidoc doc
165
- b = d.find { |bl| bl.context == :image }
166
- expect(b).to_not be_nil
167
- target = b.attributes['target']
168
- mtime1 = File.mtime(target)
169
-
170
- sleep 1
171
-
172
- d = load_asciidoc doc
173
-
174
- mtime2 = File.mtime(target)
175
-
176
- expect(mtime2).to eq mtime1
177
- end
178
-
179
- it "should handle two block macros with the same source" do
180
- File.write('wavedrom.txt', code)
181
-
182
- doc = <<-eos
183
- = Hello, Wavedrom!
184
- Doc Writer <doc@example.com>
185
-
186
- == First Section
187
-
188
- wavedrom::wavedrom.txt[]
189
- wavedrom::wavedrom.txt[]
190
- eos
191
-
192
- load_asciidoc doc
193
- expect(File.exist?('wavedrom.png')).to be true
194
- end
195
-
196
- it "should respect target attribute in block macros" do
197
- File.write('wavedrom.txt', code)
198
-
199
- doc = <<-eos
200
- = Hello, Wavedrom!
201
- Doc Writer <doc@example.com>
202
-
203
- == First Section
204
-
205
- wavedrom::wavedrom.txt["foobar"]
206
- wavedrom::wavedrom.txt["foobaz"]
207
- eos
208
-
209
- load_asciidoc doc
210
- expect(File.exist?('foobar.png')).to be true
211
- expect(File.exist?('foobaz.png')).to be true
212
- expect(File.exist?('wavedrom.png')).to be false
213
- end
16
+ include_examples "block", :wavedrom, code, [:png, :svg]
214
17
  end