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
@@ -8,207 +8,9 @@ blockdiag {
8
8
  eos
9
9
 
10
10
  describe Asciidoctor::Diagram::BlockDiagBlockMacroProcessor, :broken_on_appveyor do
11
- it "should generate PNG images when format is set to 'png'" do
12
- File.write('blockdiag.txt', code)
13
-
14
- doc = <<-eos
15
- = Hello, BlockDiag!
16
- Doc Writer <doc@example.com>
17
-
18
- == First Section
19
-
20
- blockdiag::blockdiag.txt[format="png"]
21
- eos
22
-
23
- d = load_asciidoc doc
24
- expect(d).to_not be_nil
25
-
26
- b = d.find { |bl| bl.context == :image }
27
- expect(b).to_not be_nil
28
-
29
- expect(b.content_model).to eq :empty
30
-
31
- target = b.attributes['target']
32
- expect(target).to_not be_nil
33
- expect(target).to match(/\.png$/)
34
- expect(File.exist?(target)).to be true
35
-
36
- expect(b.attributes['width']).to_not be_nil
37
- expect(b.attributes['height']).to_not be_nil
38
- end
11
+ include_examples "block_macro", :blockdiag, code, [:png, :svg, :pdf]
39
12
  end
40
13
 
41
14
  describe Asciidoctor::Diagram::BlockDiagBlockProcessor, :broken_on_appveyor do
42
- it "should generate PNG images when format is set to 'png'" do
43
- doc = <<-eos
44
- = Hello, BlockDiag!
45
- Doc Writer <doc@example.com>
46
-
47
- == First Section
48
-
49
- [blockdiag, format="png"]
50
- ----
51
- #{code}
52
- ----
53
- eos
54
-
55
- d = load_asciidoc doc
56
- expect(d).to_not be_nil
57
-
58
- b = d.find { |bl| bl.context == :image }
59
- expect(b).to_not be_nil
60
-
61
- expect(b.content_model).to eq :empty
62
-
63
- target = b.attributes['target']
64
- expect(target).to_not be_nil
65
- expect(target).to match(/\.png$/)
66
- expect(File.exist?(target)).to be true
67
-
68
- expect(b.attributes['width']).to_not be_nil
69
- expect(b.attributes['height']).to_not be_nil
70
- end
71
-
72
- it "should generate SVG images when format is set to 'svg'" do
73
- doc = <<-eos
74
- = Hello, BlockDiag!
75
- Doc Writer <doc@example.com>
76
-
77
- == First Section
78
-
79
- [blockdiag, format="svg"]
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(/\.svg/)
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 PDF files when format is set to 'pdf'" do
103
- doc = <<-eos
104
- = Hello, BlockDiag!
105
- Doc Writer <doc@example.com>
106
-
107
- == First Section
108
-
109
- [blockdiag, format="pdf"]
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(/\.pdf/)
126
- expect(File.exist?(target)).to be true
127
-
128
- expect(b.attributes['width']).to be_nil
129
- expect(b.attributes['height']).to 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, BlockDiag!
135
- Doc Writer <doc@example.com>
136
-
137
- == First Section
138
-
139
- [blockdiag, 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('blockdiag.txt', code)
149
-
150
- doc = <<-eos
151
- = Hello, BlockDiag!
152
- Doc Writer <doc@example.com>
153
-
154
- == First Section
155
-
156
- blockdiag::blockdiag.txt
157
-
158
- [blockdiag, 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('blockdiag.txt', code)
181
-
182
- doc = <<-eos
183
- = Hello, BlockDiag!
184
- Doc Writer <doc@example.com>
185
-
186
- == First Section
187
-
188
- blockdiag::blockdiag.txt[]
189
- blockdiag::blockdiag.txt[]
190
- eos
191
-
192
- load_asciidoc doc
193
- expect(File.exist?('blockdiag.png')).to be true
194
- end
195
-
196
- it "should respect target attribute in block macros" do
197
- File.write('blockdiag.txt', code)
198
-
199
- doc = <<-eos
200
- = Hello, BlockDiag!
201
- Doc Writer <doc@example.com>
202
-
203
- == First Section
204
-
205
- blockdiag::blockdiag.txt["foobar"]
206
- blockdiag::blockdiag.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?('blockdiag.png')).to be false
213
- end
15
+ include_examples "block", :blockdiag, code, [:png, :svg, :pdf]
214
16
  end
@@ -0,0 +1,56 @@
1
+ require_relative 'test_helper'
2
+
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
49
+
50
+ describe Asciidoctor::Diagram::BpmnBlockMacroProcessor do
51
+ include_examples "block_macro", :bpmn, code, [:png, :svg, :pdf]
52
+ end
53
+
54
+ describe Asciidoctor::Diagram::BpmnBlockProcessor do
55
+ include_examples "block", :bpmn, code, [:png, :svg, :pdf]
56
+ end
@@ -0,0 +1,92 @@
1
+ require_relative 'test_helper'
2
+
3
+ code = <<-eos
4
+ ;; This the source for the sample diagram illustrated in the project Read Me.
5
+
6
+ ;; Some nice default background colors, used to distinguish header sections.
7
+ (defattrs :bg-green {:fill "#a0ffa0"})
8
+ (defattrs :bg-yellow {:fill "#ffffa0"})
9
+ (defattrs :bg-pink {:fill "#ffb0a0"})
10
+ (defattrs :bg-cyan {:fill "#a0fafa"})
11
+ (defattrs :bg-purple {:fill "#e4b5f7"})
12
+
13
+ (defn draw-group-label-header
14
+ "Creates a small borderless box used to draw the textual label headers
15
+ used below the byte labels for remotedb message diagrams.
16
+ Arguments are the number of colums to span and the text of the
17
+ label."
18
+ [span label]
19
+ (draw-box (text label [:math {:font-size 12}]) {:span span
20
+ :borders \#{}
21
+ :height 14}))
22
+
23
+ (defn draw-remotedb-header
24
+ "Generates the byte and field labels and standard header fields of a
25
+ request or response message for the remotedb database server with
26
+ the specified kind and args values."
27
+ [kind args]
28
+ (draw-column-headers)
29
+ (draw-group-label-header 5 "start")
30
+ (draw-group-label-header 5 "TxID")
31
+ (draw-group-label-header 3 "type")
32
+ (draw-group-label-header 2 "args")
33
+ (draw-group-label-header 1 "tags")
34
+ (next-row 18)
35
+
36
+ (draw-box 0x11 :bg-green)
37
+ (draw-box 0x872349ae [{:span 4} :bg-green])
38
+ (draw-box 0x11 :bg-yellow)
39
+ (draw-box (text "TxID" :math) [{:span 4} :bg-yellow])
40
+ (draw-box 0x10 :bg-pink)
41
+ (draw-box (hex-text kind 4 :bold) [{:span 2} :bg-pink])
42
+ (draw-box 0x0f :bg-cyan)
43
+ (draw-box (hex-text args 2 :bold) :bg-cyan)
44
+ (draw-box 0x14 :bg-purple)
45
+
46
+ (draw-box (text "0000000c" :hex [[:plain {:font-weight "light" :font-size 16}] " (12)"])
47
+ [{:span 4} :bg-purple])
48
+ (draw-box (hex-text 6 2 :bold) [:box-first :bg-purple])
49
+ (doseq [val [6 6 3 6 6 6 6 3]]
50
+ (draw-box (hex-text val 2 :bold) [:box-related :bg-purple]))
51
+ (doseq [val [0 0]]
52
+ (draw-box val [:box-related :bg-purple]))
53
+ (draw-box 0 [:box-last :bg-purple]))
54
+
55
+ ;; Figure 48: Cue point response message.
56
+
57
+ (draw-remotedb-header 0x4702 9)
58
+
59
+ (draw-box 0x11)
60
+ (draw-box 0x2104 {:span 4})
61
+ (draw-box 0x11)
62
+ (draw-box 0 {:span 4})
63
+ (draw-box 0x11)
64
+ (draw-box (text "length" [:math] [:sub 1]) {:span 4})
65
+ (draw-box 0x14)
66
+
67
+ (draw-box (text "length" [:math] [:sub 1]) {:span 4})
68
+ (draw-gap "Cue and loop point bytes")
69
+
70
+ (draw-box nil :box-below)
71
+ (draw-box 0x11)
72
+ (draw-box 0x36 {:span 4})
73
+ (draw-box 0x11)
74
+ (draw-box (text "num" [:math] [:sub "hot"]) {:span 4})
75
+ (draw-box 0x11)
76
+ (draw-box (text "num" [:math] [:sub "cue"]) {:span 4})
77
+
78
+ (draw-box 0x11)
79
+ (draw-box (text "length" [:math] [:sub 2]) {:span 4})
80
+ (draw-box 0x14)
81
+ (draw-box (text "length" [:math] [:sub 2]) {:span 4})
82
+ (draw-gap "Unknown bytes" {:min-label-columns 6})
83
+ (draw-bottom)
84
+ eos
85
+
86
+ describe Asciidoctor::Diagram::BytefieldBlockMacroProcessor, :broken_on_travis, :broken_on_windows do
87
+ include_examples "block_macro", :bytefield, code, [:svg]
88
+ end
89
+
90
+ describe Asciidoctor::Diagram::BytefieldBlockProcessor, :broken_on_travis, :broken_on_windows do
91
+ include_examples "block", :bytefield, code, [:svg]
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
13
+ eos
24
14
 
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
33
-
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
@@ -253,4 +115,36 @@ Doc Writer <doc@example.com>
253
115
  expect(b.attributes['width']).to_not be_nil
254
116
  expect(b.attributes['height']).to_not be_nil
255
117
  end
118
+
119
+ it "should report syntax errors" do
120
+ doc = <<-eos
121
+ = Hello, Ditaa!
122
+ Doc Writer <doc@example.com>
123
+
124
+ == First Section
125
+
126
+ [ditaa,format="svg"]
127
+ ----
128
+ This should cause a bug.
129
+
130
+ // TODO:
131
+ // - don't make bugs
132
+ // - oops I wrote a comment here
133
+
134
+ +--------+ +-------+ +-------+
135
+ | | --+ ditaa +--> | |
136
+ | Text | +-------+ |diagram|
137
+ |Document| |!magic!| | |
138
+ | {d}| | | | |
139
+ +---+----+ +-------+ +-------+
140
+ : ^
141
+ | Lots of work |
142
+ +-------------------------+
143
+ ----
144
+ eos
145
+
146
+ expect {
147
+ load_asciidoc doc
148
+ }.to raise_error(/Cannot follow cell/i)
149
+ end
256
150
  end