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,159 +1,20 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe Asciidoctor::Diagram::GraphvizBlockMacroProcessor do
4
- it "should generate PNG images when format is set to 'png'" do
5
- code = <<-eos
3
+ code = <<-eos
6
4
  digraph foo {
7
5
  node [style=rounded]
8
6
  node1 [shape=box]
9
7
  node2 [fillcolor=yellow, style="rounded,filled", shape=diamond]
10
- node3 [shape=record, label="{ a | b | c }"]
8
+ node3 [shape=record, label=" a b c"]
11
9
 
12
10
  node1 -> node2 -> node3
13
11
  }
14
- eos
15
-
16
- File.write('graphviz.txt', code)
17
-
18
- doc = <<-eos
19
- = Hello, graphviz!
20
- Doc Writer <doc@example.com>
21
-
22
- == First Section
23
-
24
- graphviz::graphviz.txt[format="png"]
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
12
+ eos
32
13
 
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
14
+ describe Asciidoctor::Diagram::GraphvizBlockMacroProcessor do
15
+ include_examples "block_macro", :graphviz, code, [:png, :svg]
43
16
  end
44
17
 
45
18
  describe Asciidoctor::Diagram::GraphvizBlockProcessor do
46
- it "should generate PNG images when format is set to 'png'" do
47
- doc = <<-eos
48
- = Hello, graphviz!
49
- Doc Writer <doc@example.com>
50
-
51
- == First Section
52
-
53
- [graphviz, format="png"]
54
- ----
55
- digraph foo {
56
- node [style=rounded]
57
- node1 [shape=box]
58
- node2 [fillcolor=yellow, style="rounded,filled", shape=diamond]
59
- node3 [shape=record, label="{ a | b | c }"]
60
-
61
- node1 -> node2 -> node3
62
- }
63
- ----
64
- eos
65
-
66
- d = load_asciidoc doc
67
- expect(d).to_not be_nil
68
-
69
- b = d.find { |bl| bl.context == :image }
70
- expect(b).to_not be_nil
71
-
72
- expect(b.content_model).to eq :empty
73
-
74
- target = b.attributes['target']
75
- expect(target).to_not be_nil
76
- expect(target).to match(/\.png$/)
77
- expect(File.exist?(target)).to be true
78
-
79
- expect(b.attributes['width']).to_not be_nil
80
- expect(b.attributes['height']).to_not be_nil
81
- end
82
-
83
- it "should generate SVG images when format is set to 'svg'" do
84
- doc = <<-eos
85
- = Hello, graphviz!
86
- Doc Writer <doc@example.com>
87
-
88
- == First Section
89
-
90
- [graphviz, format="svg"]
91
- ----
92
- digraph foo {
93
- node [style=rounded]
94
- node1 [shape=box]
95
- node2 [fillcolor=yellow, style="rounded,filled", shape=diamond]
96
- node3 [shape=record, label="{ a | b | c }"]
97
-
98
- node1 -> node2 -> node3
99
- }
100
- ----
101
- eos
102
-
103
- d = load_asciidoc doc
104
- expect(d).to_not be_nil
105
-
106
- b = d.find { |bl| bl.context == :image }
107
- expect(b).to_not be_nil
108
-
109
- expect(b.content_model).to eq :empty
110
-
111
- target = b.attributes['target']
112
- expect(target).to_not be_nil
113
- expect(target).to match(/\.svg$/)
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 raise an error when when format is set to an invalid value" do
121
- doc = <<-eos
122
- = Hello, graphviz!
123
- Doc Writer <doc@example.com>
124
-
125
- == First Section
126
-
127
- [graphviz, format="foobar"]
128
- ----
129
- ----
130
- eos
131
-
132
- expect { load_asciidoc doc }.to raise_error(/support.*format/i)
133
- end
134
-
135
- it "should support neato layout engine" do
136
- doc = <<-eos
137
- = Hello, graphviz!
138
- Doc Writer <doc@example.com>
139
-
140
- == First Section
141
-
142
- [graphviz, layout=neato]
143
- ----
144
- digraph g { rankdir=LR; Text->Graphviz->Image }
145
- ----
146
- eos
147
-
148
- d = load_asciidoc doc
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
- expect(b.content_model).to eq :empty
155
-
156
- target = b.attributes['target']
157
- expect(File.exist?(target)).to be true
158
- end
19
+ include_examples "block", :graphviz, code, [:png, :svg]
159
20
  end
@@ -5,147 +5,9 @@ code = <<-eos
5
5
  eos
6
6
 
7
7
  describe Asciidoctor::Diagram::LilypondBlockMacroProcessor, :broken_on_windows do
8
- it "should generate PNG images when format is set to 'png'" do
9
- File.write('lilypond.txt', code)
10
-
11
- doc = <<-eos
12
- = Hello, Lilypond!
13
- Doc Writer <doc@example.com>
14
-
15
- == First Section
16
-
17
- lilypond::lilypond.txt[format="png"]
18
- eos
19
-
20
- d = load_asciidoc doc
21
- expect(d).to_not be_nil
22
-
23
- b = d.find { |bl| bl.context == :image }
24
- expect(b).to_not be_nil
25
-
26
- expect(b.content_model).to eq :empty
27
-
28
- target = b.attributes['target']
29
- expect(target).to_not be_nil
30
- expect(target).to match(/\.png/)
31
- expect(File.exist?(target)).to be true
32
-
33
- expect(b.attributes['width']).to_not be_nil
34
- expect(b.attributes['height']).to_not be_nil
35
- end
8
+ include_examples "block_macro", :lilypond, code, [:png]
36
9
  end
37
10
 
38
11
  describe Asciidoctor::Diagram::LilypondBlockProcessor, :broken_on_windows do
39
- it "should generate PNG images when format is set to 'png'" do
40
- doc = <<-eos
41
- = Hello, Lilypond!
42
- Doc Writer <doc@example.com>
43
-
44
- == First Section
45
-
46
- [lilypond, format="png"]
47
- ----
48
- #{code}
49
- ----
50
- eos
51
-
52
- d = load_asciidoc doc
53
- expect(d).to_not be_nil
54
-
55
- b = d.find { |bl| bl.context == :image }
56
- expect(b).to_not be_nil
57
-
58
- expect(b.content_model).to eq :empty
59
-
60
- target = b.attributes['target']
61
- expect(target).to_not be_nil
62
- expect(target).to match(/\.png/)
63
- expect(File.exist?(target)).to be true
64
-
65
- expect(b.attributes['width']).to_not be_nil
66
- expect(b.attributes['height']).to_not be_nil
67
- end
68
-
69
- it "should raise an error when when format is set to an invalid value" do
70
- doc = <<-eos
71
- = Hello, Lilypond!
72
- Doc Writer <doc@example.com>
73
-
74
- == First Section
75
-
76
- [lilypond, format="foobar"]
77
- ----
78
- ----
79
- eos
80
-
81
- expect { load_asciidoc doc }.to raise_error(/support.*format/i)
82
- end
83
-
84
- it "should not regenerate images when source has not changed" do
85
- File.write('lilypond.txt', code)
86
-
87
- doc = <<-eos
88
- = Hello, Lilypond!
89
- Doc Writer <doc@example.com>
90
-
91
- == First Section
92
-
93
- lilypond::lilypond.txt
94
-
95
- [lilypond, format="png"]
96
- ----
97
- #{code}
98
- ----
99
- eos
100
-
101
- d = load_asciidoc doc
102
- b = d.find { |bl| bl.context == :image }
103
- expect(b).to_not be_nil
104
- target = b.attributes['target']
105
- mtime1 = File.mtime(target)
106
-
107
- sleep 1
108
-
109
- d = load_asciidoc doc
110
-
111
- mtime2 = File.mtime(target)
112
-
113
- expect(mtime2).to eq mtime1
114
- end
115
-
116
- it "should handle two block macros with the same source" do
117
- File.write('lilypond.txt', code)
118
-
119
- doc = <<-eos
120
- = Hello, Lilypond!
121
- Doc Writer <doc@example.com>
122
-
123
- == First Section
124
-
125
- lilypond::lilypond.txt[]
126
- lilypond::lilypond.txt[]
127
- eos
128
-
129
- load_asciidoc doc
130
- expect(File.exist?('lilypond.png')).to be true
131
- end
132
-
133
- it "should respect target attribute in block macros" do
134
- File.write('lilypond.txt', code)
135
-
136
- doc = <<-eos
137
- = Hello, Lilypond!
138
- Doc Writer <doc@example.com>
139
-
140
- == First Section
141
-
142
- lilypond::lilypond.txt["foobar"]
143
- lilypond::lilypond.txt["foobaz"]
144
- eos
145
-
146
- load_asciidoc doc
147
- expect(File.exist?('foobar.png')).to be true
148
- expect(File.exist?('foobaz.png')).to be true
149
- expect(File.exist?('lilypond.png')).to be false
150
- end
12
+ include_examples "block", :lilypond, code, [:png]
151
13
  end
@@ -9,208 +9,11 @@ graph LR
9
9
  eos
10
10
 
11
11
  describe Asciidoctor::Diagram::MermaidBlockMacroProcessor do
12
- it "should generate PNG images when format is set to 'png'" do
13
- File.write('mermaid.txt', code)
14
-
15
- doc = <<-eos
16
- = Hello, Mermaid!
17
- Doc Writer <doc@example.com>
18
-
19
- == First Section
20
-
21
- mermaid::mermaid.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('mermaid.txt', code)
43
-
44
- doc = <<-eos
45
- = Hello, Mermaid!
46
- Doc Writer <doc@example.com>
47
-
48
- == First Section
49
-
50
- mermaid::mermaid.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", :mermaid, code, [:png, :svg]
69
13
  end
70
14
 
71
15
  describe Asciidoctor::Diagram::MermaidBlockProcessor do
72
- it "should generate PNG images when format is set to 'png'" do
73
- doc = <<-eos
74
- = Hello, Mermaid!
75
- Doc Writer <doc@example.com>
76
-
77
- == First Section
78
-
79
- [mermaid, 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, Mermaid!
105
- Doc Writer <doc@example.com>
106
-
107
- == First Section
108
-
109
- [mermaid, 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, Mermaid!
135
- Doc Writer <doc@example.com>
136
-
137
- == First Section
138
-
139
- [mermaid, 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('mermaid.txt', code)
149
-
150
- doc = <<-eos
151
- = Hello, Mermaid!
152
- Doc Writer <doc@example.com>
153
-
154
- == First Section
155
-
156
- mermaid::mermaid.txt
157
-
158
- [mermaid, 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('mermaid.txt', code)
181
-
182
- doc = <<-eos
183
- = Hello, Mermaid!
184
- Doc Writer <doc@example.com>
185
-
186
- == First Section
187
-
188
- mermaid::mermaid.txt[]
189
- mermaid::mermaid.txt[]
190
- eos
191
-
192
- load_asciidoc doc
193
- expect(File.exist?('mermaid.png')).to be true
194
- end
195
-
196
- it "should respect target attribute in block macros" do
197
- File.write('mermaid.txt', code)
198
-
199
- doc = <<-eos
200
- = Hello, Mermaid!
201
- Doc Writer <doc@example.com>
202
-
203
- == First Section
204
-
205
- mermaid::mermaid.txt["foobar"]
206
- mermaid::mermaid.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?('mermaid.png')).to be false
213
- end
16
+ include_examples "block", :mermaid, code, [:png, :svg]
214
17
 
215
18
  it "should respect the sequenceConfig attribute" do
216
19
  seq_diag = <<-eos