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
@@ -1,96 +1,56 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe Asciidoctor::Diagram::BpmnBlockMacroProcessor do
4
- it "should generate SVG images when format is set to 'svg'" do
5
- FileUtils.cp(
6
- File.expand_path('bpmn-example.xml', File.dirname(__FILE__)),
7
- File.expand_path('bpmn-example.xml', Dir.getwd)
8
- )
9
-
10
- doc = <<-eos
11
- = Hello, BPMN!
12
- Doc Writer <doc@example.com>
13
-
14
- == First Section
15
-
16
- bpmn::bpmn-example.xml[format="svg"]
17
- eos
18
-
19
- d = load_asciidoc doc
20
- expect(d).to_not be_nil
21
-
22
- b = d.find { |bl| bl.context == :image }
23
- expect(b).to_not be_nil
24
-
25
- expect(b.content_model).to eq :empty
26
-
27
- target = b.attributes['target']
28
- expect(target).to_not be_nil
29
- expect(target).to match(/\.svg/)
30
- expect(File.exist?(target)).to be true
31
-
32
- expect(b.attributes['width']).to_not be_nil
33
- expect(b.attributes['height']).to_not be_nil
34
- end
35
-
36
- it "should generate PNG images when format is set to 'png'" do
37
- FileUtils.cp(
38
- File.expand_path('bpmn-example.xml', File.dirname(__FILE__)),
39
- File.expand_path('bpmn-example.xml', Dir.getwd)
40
- )
41
-
42
- doc = <<-eos
43
- = Hello, BPMN!
44
- Doc Writer <doc@example.com>
45
-
46
- == First Section
47
-
48
- bpmn::bpmn-example.xml[format="png"]
49
- eos
50
-
51
- d = load_asciidoc doc
52
- expect(d).to_not be_nil
3
+ code = <<EOF
4
+ <?xml version="1.0" encoding="UTF-8"?>
5
+ <bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0zt4mn9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="bpmn-js (https://demo.bpmn.io)" exporterVersion="5.1.2">
6
+ <bpmn:process id="Process_081h9u7" isExecutable="false">
7
+ <bpmn:startEvent id="StartEvent_00w25dz" name="Start">
8
+ <bpmn:outgoing>SequenceFlow_11u0n1f</bpmn:outgoing>
9
+ </bpmn:startEvent>
10
+ <bpmn:task id="Task_0yx8j7s" name="Task">
11
+ <bpmn:incoming>SequenceFlow_11u0n1f</bpmn:incoming>
12
+ <bpmn:outgoing>SequenceFlow_104th5x</bpmn:outgoing>
13
+ </bpmn:task>
14
+ <bpmn:sequenceFlow id="SequenceFlow_11u0n1f" sourceRef="StartEvent_00w25dz" targetRef="Task_0yx8j7s" />
15
+ <bpmn:endEvent id="EndEvent_0jxehtp" name="End">
16
+ <bpmn:incoming>SequenceFlow_104th5x</bpmn:incoming>
17
+ </bpmn:endEvent>
18
+ <bpmn:sequenceFlow id="SequenceFlow_104th5x" sourceRef="Task_0yx8j7s" targetRef="EndEvent_0jxehtp" />
19
+ </bpmn:process>
20
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
21
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_081h9u7">
22
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_00w25dz">
23
+ <dc:Bounds x="156" y="81" width="36" height="36" />
24
+ <bpmndi:BPMNLabel>
25
+ <dc:Bounds x="162" y="124" width="24" height="14" />
26
+ </bpmndi:BPMNLabel>
27
+ </bpmndi:BPMNShape>
28
+ <bpmndi:BPMNShape id="Task_0yx8j7s_di" bpmnElement="Task_0yx8j7s">
29
+ <dc:Bounds x="250" y="59" width="100" height="80" />
30
+ </bpmndi:BPMNShape>
31
+ <bpmndi:BPMNEdge id="SequenceFlow_11u0n1f_di" bpmnElement="SequenceFlow_11u0n1f">
32
+ <di:waypoint x="192" y="99" />
33
+ <di:waypoint x="250" y="99" />
34
+ </bpmndi:BPMNEdge>
35
+ <bpmndi:BPMNShape id="EndEvent_0jxehtp_di" bpmnElement="EndEvent_0jxehtp">
36
+ <dc:Bounds x="412" y="81" width="36" height="36" />
37
+ <bpmndi:BPMNLabel>
38
+ <dc:Bounds x="420" y="124" width="20" height="14" />
39
+ </bpmndi:BPMNLabel>
40
+ </bpmndi:BPMNShape>
41
+ <bpmndi:BPMNEdge id="SequenceFlow_104th5x_di" bpmnElement="SequenceFlow_104th5x">
42
+ <di:waypoint x="350" y="99" />
43
+ <di:waypoint x="412" y="99" />
44
+ </bpmndi:BPMNEdge>
45
+ </bpmndi:BPMNPlane>
46
+ </bpmndi:BPMNDiagram>
47
+ </bpmn:definitions>
48
+ EOF
53
49
 
54
- b = d.find { |bl| bl.context == :image }
55
- expect(b).to_not be_nil
56
-
57
- expect(b.content_model).to eq :empty
58
-
59
- target = b.attributes['target']
60
- expect(target).to_not be_nil
61
- expect(target).to match(/\.png$/)
62
- expect(File.exist?(target)).to be true
63
-
64
- expect(b.attributes['width']).to_not be_nil
65
- expect(b.attributes['height']).to_not be_nil
66
- end
67
-
68
- it "should generate PDF images when format is set to 'pdf'" do
69
- FileUtils.cp(
70
- File.expand_path('bpmn-example.xml', File.dirname(__FILE__)),
71
- File.expand_path('bpmn-example.xml', Dir.getwd)
72
- )
73
-
74
- doc = <<-eos
75
- = Hello, BPMN!
76
- Doc Writer <doc@example.com>
77
-
78
- == First Section
79
-
80
- bpmn::bpmn-example.xml[format="pdf"]
81
- eos
82
-
83
- d = load_asciidoc doc
84
- expect(d).to_not be_nil
85
-
86
- b = d.find { |bl| bl.context == :image }
87
- expect(b).to_not be_nil
88
-
89
- expect(b.content_model).to eq :empty
90
-
91
- target = b.attributes['target']
92
- expect(target).to_not be_nil
93
- expect(target).to match(/\.pdf$/)
94
- expect(File.exist?(target)).to be true
95
- end
50
+ describe Asciidoctor::Diagram::BpmnBlockMacroProcessor do
51
+ include_examples "block_macro", :bpmn, code, [:png, :svg, :pdf]
96
52
  end
53
+
54
+ describe Asciidoctor::Diagram::BpmnBlockProcessor do
55
+ include_examples "block", :bpmn, code, [:png, :svg, :pdf]
56
+ end
@@ -84,147 +84,9 @@ code = <<-eos
84
84
  eos
85
85
 
86
86
  describe Asciidoctor::Diagram::BytefieldBlockMacroProcessor, :broken_on_travis, :broken_on_windows do
87
- it "should generate SVG images when format is set to 'svg'" do
88
- File.write('bytefield.txt', code)
89
-
90
- doc = <<-eos
91
- = Hello, Bytefield!
92
- Doc Writer <doc@example.com>
93
-
94
- == First Section
95
-
96
- bytefield::bytefield.txt[format="svg"]
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(/\.svg/)
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
87
+ include_examples "block_macro", :bytefield, code, [:svg]
115
88
  end
116
89
 
117
90
  describe Asciidoctor::Diagram::BytefieldBlockProcessor, :broken_on_travis, :broken_on_windows do
118
- it "should generate SVG images when format is set to 'svg'" do
119
- doc = <<-eos
120
- = Hello, Bytefield!
121
- Doc Writer <doc@example.com>
122
-
123
- == First Section
124
-
125
- [bytefield, format="svg"]
126
- ----
127
- #{code}
128
- ----
129
- eos
130
-
131
- d = load_asciidoc doc
132
- expect(d).to_not be_nil
133
-
134
- b = d.find { |bl| bl.context == :image }
135
- expect(b).to_not be_nil
136
-
137
- expect(b.content_model).to eq :empty
138
-
139
- target = b.attributes['target']
140
- expect(target).to_not be_nil
141
- expect(target).to match(/\.svg/)
142
- expect(File.exist?(target)).to be true
143
-
144
- expect(b.attributes['width']).to_not be_nil
145
- expect(b.attributes['height']).to_not be_nil
146
- end
147
-
148
- it "should raise an error when when format is set to an invalid value" do
149
- doc = <<-eos
150
- = Hello, Bytefield!
151
- Doc Writer <doc@example.com>
152
-
153
- == First Section
154
-
155
- [bytefield, format="foobar"]
156
- ----
157
- ----
158
- eos
159
-
160
- expect { load_asciidoc doc }.to raise_error(/support.*format/i)
161
- end
162
-
163
- it "should not regenerate images when source has not changed" do
164
- File.write('bytefield.txt', code)
165
-
166
- doc = <<-eos
167
- = Hello, Bytefield!
168
- Doc Writer <doc@example.com>
169
-
170
- == First Section
171
-
172
- bytefield::bytefield.txt
173
-
174
- [bytefield, format="svg"]
175
- ----
176
- #{code}
177
- ----
178
- eos
179
-
180
- d = load_asciidoc doc
181
- b = d.find { |bl| bl.context == :image }
182
- expect(b).to_not be_nil
183
- target = b.attributes['target']
184
- mtime1 = File.mtime(target)
185
-
186
- sleep 1
187
-
188
- d = load_asciidoc doc
189
-
190
- mtime2 = File.mtime(target)
191
-
192
- expect(mtime2).to eq mtime1
193
- end
194
-
195
- it "should handle two block macros with the same source" do
196
- File.write('bytefield.txt', code)
197
-
198
- doc = <<-eos
199
- = Hello, Bytefield!
200
- Doc Writer <doc@example.com>
201
-
202
- == First Section
203
-
204
- bytefield::bytefield.txt[]
205
- bytefield::bytefield.txt[]
206
- eos
207
-
208
- load_asciidoc doc
209
- expect(File.exist?('bytefield.svg')).to be true
210
- end
211
-
212
- it "should respect target attribute in block macros" do
213
- File.write('bytefield.txt', code)
214
-
215
- doc = <<-eos
216
- = Hello, Bytefield!
217
- Doc Writer <doc@example.com>
218
-
219
- == First Section
220
-
221
- bytefield::bytefield.txt["foobar"]
222
- bytefield::bytefield.txt["foobaz"]
223
- eos
224
-
225
- load_asciidoc doc
226
- expect(File.exist?('foobar.svg')).to be true
227
- expect(File.exist?('foobaz.svg')).to be true
228
- expect(File.exist?('bytefield.svg')).to be false
229
- end
91
+ include_examples "block", :bytefield, code, [:svg]
230
92
  end
@@ -1,8 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe Asciidoctor::Diagram::DitaaBlockMacroProcessor do
4
- it "should generate PNG images when format is set to 'png'" do
5
- code = <<-eos
3
+ code = <<-eos
6
4
  +--------+ +-------+ +-------+
7
5
  | | --+ ditaa +--> | |
8
6
  | Text | +-------+ |diagram|
@@ -12,150 +10,14 @@ describe Asciidoctor::Diagram::DitaaBlockMacroProcessor do
12
10
  : ^
13
11
  | Lots of work |
14
12
  +-------------------------+
15
- eos
16
-
17
- File.write('ditaa.txt', code)
18
-
19
- doc = <<-eos
20
- = Hello, PlantUML!
21
- Doc Writer <doc@example.com>
22
-
23
- == First Section
24
-
25
- ditaa::ditaa.txt[format="png"]
26
- eos
27
-
28
- d = load_asciidoc doc
29
- expect(d).to_not be_nil
30
-
31
- b = d.find { |bl| bl.context == :image }
32
- expect(b).to_not be_nil
13
+ eos
33
14
 
34
- expect(b.content_model).to eq :empty
35
-
36
- target = b.attributes['target']
37
- expect(target).to_not be_nil
38
- expect(target).to match(/\.png$/)
39
- expect(File.exist?(target)).to be true
40
-
41
- expect(b.attributes['width']).to_not be_nil
42
- expect(b.attributes['height']).to_not be_nil
43
- end
15
+ describe Asciidoctor::Diagram::DitaaBlockMacroProcessor do
16
+ include_examples "block_macro", :ditaa, code, [:png, :svg]
44
17
  end
45
18
 
46
19
  describe Asciidoctor::Diagram::DitaaBlockProcessor do
47
- it "should generate PNG images when format is set to 'png'" do
48
- doc = <<-eos
49
- = Hello, ditaa!
50
- Doc Writer <doc@example.com>
51
-
52
- == First Section
53
-
54
- [ditaa, format="png"]
55
- ----
56
- +--------+ +-------+ +-------+
57
- | | --+ ditaa +--> | |
58
- | Text | +-------+ |diagram|
59
- |Document| |!magic!| | |
60
- | {d}| | | | |
61
- +---+----+ +-------+ +-------+
62
- : ^
63
- | Lots of work |
64
- +-------------------------+
65
- ----
66
- eos
67
-
68
- d = load_asciidoc doc
69
- expect(d).to_not be_nil
70
-
71
- b = d.find { |bl| bl.context == :image }
72
- expect(b).to_not be_nil
73
-
74
- expect(b.content_model).to eq :empty
75
-
76
- target = b.attributes['target']
77
- expect(target).to_not be_nil
78
- expect(target).to match(/\.png$/)
79
- expect(File.exist?(target)).to be true
80
-
81
- expect(b.attributes['width']).to_not be_nil
82
- expect(b.attributes['height']).to_not be_nil
83
- end
84
-
85
- it "should generate SVG images when format is set to 'svg'" do
86
- doc = <<-eos
87
- = Hello, ditaa!
88
- Doc Writer <doc@example.com>
89
-
90
- == First Section
91
-
92
- [ditaa, format="svg"]
93
- ----
94
- +--------+ +-------+ +-------+
95
- | | --+ ditaa +--> | |
96
- | Text | +-------+ |diagram|
97
- |Document| |!magic!| | |
98
- | {d}| | | | |
99
- +---+----+ +-------+ +-------+
100
- : ^
101
- | Lots of work |
102
- +-------------------------+
103
- ----
104
- eos
105
-
106
- d = load_asciidoc doc
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
- expect(b.content_model).to eq :empty
113
-
114
- target = b.attributes['target']
115
- expect(target).to_not be_nil
116
- expect(target).to match(/\.svg/)
117
- expect(File.exist?(target)).to be true
118
-
119
- expect(b.attributes['width']).to_not be_nil
120
- expect(b.attributes['height']).to_not be_nil
121
- end
122
-
123
- it "should raise an error when when format is set to an invalid value" do
124
- doc = <<-eos
125
- = Hello, PlantUML!
126
- Doc Writer <doc@example.com>
127
-
128
- == First Section
129
-
130
- [ditaa, format="foobar"]
131
- ----
132
- ----
133
- eos
134
-
135
- expect { load_asciidoc doc }.to raise_error(/support.*format/i)
136
- end
137
-
138
- it "should use a default format when none was given" do
139
- doc = <<-eos
140
- = Hello, PlantUML!
141
- Doc Writer <doc@example.com>
142
-
143
- == First Section
144
-
145
- [ditaa]
146
- ----
147
- ----
148
- eos
149
-
150
- d = load_asciidoc doc
151
- expect(d).to_not be_nil
152
-
153
- b = d.find { |bl| bl.context == :image }
154
- expect(b).to_not be_nil
155
- target = b.attributes['target']
156
- expect(target).to match(/\.png$/)
157
- expect(File.exist?(target)).to be true
158
- end
20
+ include_examples "block", :ditaa, code, [:png, :svg]
159
21
 
160
22
  it "should support ditaa options as attributes" do
161
23
  doc = <<-eos