asciidoctor-diagram 2.0.2 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +78 -1
- data/README.adoc +25 -507
- data/Rakefile +1 -1
- data/docs/antora.yml +3 -0
- data/{images → docs/modules/ROOT/images}/asciidoctor-diagram-classes.png +0 -0
- data/docs/modules/ROOT/images/asciidoctor-diagram-process.png +0 -0
- data/docs/modules/ROOT/pages/index.adoc +21 -0
- data/docs/modules/ROOT/partials/advanced.adoc +319 -0
- data/docs/modules/ROOT/partials/create_diagram.adoc +132 -0
- data/docs/modules/ROOT/partials/generate.adoc +15 -0
- data/docs/modules/ROOT/partials/installation.adoc +19 -0
- data/docs/modules/ROOT/partials/uris.adoc +40 -0
- data/examples/features.adoc +1 -1
- data/lib/asciidoctor-diagram.rb +4 -0
- data/lib/asciidoctor-diagram/a2s/converter.rb +10 -6
- data/lib/asciidoctor-diagram/blockdiag/converter.rb +1 -1
- data/lib/asciidoctor-diagram/bpmn/converter.rb +3 -3
- data/lib/asciidoctor-diagram/diagram_converter.rb +9 -1
- data/lib/asciidoctor-diagram/diagram_processor.rb +92 -48
- data/lib/asciidoctor-diagram/diagram_source.rb +71 -24
- data/lib/asciidoctor-diagram/diagrams.rb +7 -0
- data/lib/asciidoctor-diagram/diagrams/converter.rb +49 -0
- data/lib/asciidoctor-diagram/diagrams/extension.rb +14 -0
- data/lib/asciidoctor-diagram/ditaa/converter.rb +20 -7
- data/lib/asciidoctor-diagram/ditaa/ditaa-1.3.20.jar +0 -0
- data/lib/asciidoctor-diagram/dpic.rb +7 -0
- data/lib/asciidoctor-diagram/dpic/converter.rb +30 -0
- data/lib/asciidoctor-diagram/dpic/extension.rb +14 -0
- data/lib/asciidoctor-diagram/gnuplot/converter.rb +8 -8
- data/lib/asciidoctor-diagram/graphviz/converter.rb +2 -2
- data/lib/asciidoctor-diagram/http/converter.rb +52 -14
- data/lib/asciidoctor-diagram/http/server.rb +11 -6
- data/lib/asciidoctor-diagram/lilypond/converter.rb +13 -3
- data/lib/asciidoctor-diagram/meme/converter.rb +22 -16
- data/lib/asciidoctor-diagram/mermaid/converter.rb +45 -14
- data/lib/asciidoctor-diagram/msc/converter.rb +2 -2
- data/lib/asciidoctor-diagram/pikchr.rb +7 -0
- data/lib/asciidoctor-diagram/pikchr/converter.rb +33 -0
- data/lib/asciidoctor-diagram/pikchr/extension.rb +14 -0
- data/lib/asciidoctor-diagram/plantuml/converter.rb +68 -43
- data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.20.jar +0 -0
- data/lib/asciidoctor-diagram/smcat/converter.rb +3 -3
- data/lib/asciidoctor-diagram/svgbob/converter.rb +6 -2
- data/lib/asciidoctor-diagram/symbolator.rb +7 -0
- data/lib/asciidoctor-diagram/symbolator/converter.rb +23 -0
- data/lib/asciidoctor-diagram/symbolator/extension.rb +14 -0
- data/lib/asciidoctor-diagram/syntrax/converter.rb +9 -6
- data/lib/asciidoctor-diagram/tikz/converter.rb +20 -1
- data/lib/asciidoctor-diagram/umlet/converter.rb +11 -2
- data/lib/asciidoctor-diagram/util/cli.rb +16 -1
- data/lib/asciidoctor-diagram/util/cli_generator.rb +30 -8
- data/lib/asciidoctor-diagram/util/gif.rb +2 -2
- data/lib/asciidoctor-diagram/util/java.rb +118 -3
- data/lib/asciidoctor-diagram/util/java_jruby.rb +4 -1
- data/lib/asciidoctor-diagram/util/java_socket.rb +8 -109
- data/lib/asciidoctor-diagram/util/pdf.rb +2 -2
- data/lib/asciidoctor-diagram/util/png.rb +2 -2
- data/lib/{server-1.3.15.jar → asciidoctor-diagram/util/server-1.3.20.jar} +0 -0
- data/lib/asciidoctor-diagram/util/svg.rb +66 -18
- data/lib/asciidoctor-diagram/vega/converter.rb +2 -2
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/spec/a2s_spec.rb +6 -144
- data/spec/blockdiag_spec.rb +6 -204
- data/spec/bpmn_spec.rb +52 -92
- data/spec/bytefield_spec.rb +6 -144
- data/spec/diagrams_spec.rb +23 -0
- data/spec/ditaa_spec.rb +6 -144
- data/spec/dpic_spec.rb +19 -0
- data/spec/erd_spec.rb +6 -203
- data/spec/gnuplot_spec.rb +10 -263
- data/spec/graphviz_spec.rb +6 -145
- data/spec/lilypond_spec.rb +6 -144
- data/spec/mermaid_spec.rb +69 -211
- data/spec/msc_spec.rb +6 -203
- data/spec/nomnoml_spec.rb +7 -145
- data/spec/pikchr_spec.rb +69 -0
- data/spec/plantuml_spec.rb +63 -553
- data/spec/shaape_spec.rb +12 -224
- data/spec/shared_examples.rb +603 -0
- data/spec/smcat_spec.rb +6 -144
- data/spec/svgbob_spec.rb +6 -144
- data/spec/symbolator_spec.rb +23 -0
- data/spec/syntrax_spec.rb +7 -217
- data/spec/test_helper.rb +4 -29
- data/spec/tikz_spec.rb +68 -18
- data/spec/umlet_spec.rb +3 -59
- data/spec/vega_spec.rb +6 -119
- data/spec/wavedrom_spec.rb +3 -200
- metadata +82 -18
- data/README_zh-CN.adoc +0 -336
- data/images/asciidoctor-diagram-process.png +0 -0
- data/lib/batik-all-1.10.jar +0 -0
- data/lib/ditaa-1.3.15.jar +0 -0
- data/lib/ditaamini-0.12.jar +0 -0
- data/lib/jlatexmath-minimal-1.0.5.jar +0 -0
- data/lib/plantuml-1.3.15.jar +0 -0
- data/lib/plantuml.jar +0 -0
- data/spec/bpmn-example.xml +0 -44
data/spec/bpmn_spec.rb
CHANGED
@@ -1,96 +1,56 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
bpmn
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
=
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
eos
|
50
|
-
|
51
|
-
d = load_asciidoc doc
|
52
|
-
expect(d).to_not be_nil
|
3
|
+
BPNM_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
|
-
|
55
|
-
|
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, BPNM_CODE, [:png, :svg, :pdf]
|
96
52
|
end
|
53
|
+
|
54
|
+
describe Asciidoctor::Diagram::BpmnBlockProcessor do
|
55
|
+
include_examples "block", :bpmn, BPNM_CODE, [:png, :svg, :pdf]
|
56
|
+
end
|
data/spec/bytefield_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
|
-
|
3
|
+
BYTEFIELD_CODE = <<-eos
|
4
4
|
;; This the source for the sample diagram illustrated in the project Read Me.
|
5
5
|
|
6
6
|
;; Some nice default background colors, used to distinguish header sections.
|
@@ -83,148 +83,10 @@ code = <<-eos
|
|
83
83
|
(draw-bottom)
|
84
84
|
eos
|
85
85
|
|
86
|
-
describe Asciidoctor::Diagram::BytefieldBlockMacroProcessor
|
87
|
-
|
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
|
86
|
+
describe Asciidoctor::Diagram::BytefieldBlockMacroProcessor do
|
87
|
+
include_examples "block_macro", :bytefield, BYTEFIELD_CODE, [:svg]
|
115
88
|
end
|
116
89
|
|
117
|
-
describe Asciidoctor::Diagram::BytefieldBlockProcessor
|
118
|
-
|
119
|
-
|
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
|
230
|
-
end
|
90
|
+
describe Asciidoctor::Diagram::BytefieldBlockProcessor do
|
91
|
+
include_examples "block", :bytefield, BYTEFIELD_CODE, [:svg]
|
92
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
DIAGRAMS_CODE = <<-eos
|
4
|
+
from diagrams import Diagram
|
5
|
+
from diagrams.aws.compute import EC2
|
6
|
+
from diagrams.aws.database import RDS
|
7
|
+
from diagrams.aws.network import ELB
|
8
|
+
|
9
|
+
with Diagram("Grouped Workers", show=False, direction="TB"):
|
10
|
+
ELB("lb") >> [EC2("worker1"),
|
11
|
+
EC2("worker2"),
|
12
|
+
EC2("worker3"),
|
13
|
+
EC2("worker4"),
|
14
|
+
EC2("worker5")] >> RDS("events")
|
15
|
+
eos
|
16
|
+
|
17
|
+
describe Asciidoctor::Diagram::DiagramsBlockMacroProcessor do
|
18
|
+
include_examples "block_macro", :diagrams, DIAGRAMS_CODE, [:png, :svg]
|
19
|
+
end
|
20
|
+
|
21
|
+
describe Asciidoctor::Diagram::DiagramsBlockProcessor do
|
22
|
+
include_examples "block", :diagrams, DIAGRAMS_CODE, [:png, :svg]
|
23
|
+
end
|
data/spec/ditaa_spec.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
it "should generate PNG images when format is set to 'png'" do
|
5
|
-
code = <<-eos
|
3
|
+
DITAA_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
|
-
|
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
|
-
|
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, DITAA_CODE, [:png, :svg]
|
44
17
|
end
|
45
18
|
|
46
19
|
describe Asciidoctor::Diagram::DitaaBlockProcessor do
|
47
|
-
|
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, DITAA_CODE, [:png, :svg]
|
159
21
|
|
160
22
|
it "should support ditaa options as attributes" do
|
161
23
|
doc = <<-eos
|
@@ -283,6 +145,6 @@ This should cause a bug.
|
|
283
145
|
|
284
146
|
expect {
|
285
147
|
load_asciidoc doc
|
286
|
-
}.to raise_error(/
|
148
|
+
}.to raise_error(/Ambiguous input/i)
|
287
149
|
end
|
288
150
|
end
|