asciidoctor-diagram 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +77 -1
- data/README.adoc +25 -483
- 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 +303 -0
- data/docs/modules/ROOT/partials/create_diagram.adoc +131 -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 +38 -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 +4 -4
- data/lib/asciidoctor-diagram/bytefield.rb +7 -0
- data/lib/asciidoctor-diagram/bytefield/converter.rb +26 -0
- data/lib/asciidoctor-diagram/bytefield/extension.rb +14 -0
- data/lib/asciidoctor-diagram/diagram_converter.rb +5 -1
- data/lib/asciidoctor-diagram/diagram_processor.rb +106 -51
- data/lib/asciidoctor-diagram/diagram_source.rb +66 -19
- data/lib/asciidoctor-diagram/ditaa/converter.rb +20 -7
- data/lib/asciidoctor-diagram/ditaa/ditaa-1.3.17.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 +93 -0
- data/lib/asciidoctor-diagram/http/server.rb +10 -5
- data/lib/asciidoctor-diagram/lilypond/converter.rb +13 -3
- data/lib/asciidoctor-diagram/meme/converter.rb +24 -18
- 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 +22 -14
- data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.17.jar +0 -0
- data/lib/asciidoctor-diagram/smcat/converter.rb +3 -3
- data/lib/asciidoctor-diagram/svgbob/converter.rb +29 -1
- 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 +29 -3
- data/lib/asciidoctor-diagram/util/cli_generator.rb +22 -2
- 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 +9 -110
- data/lib/asciidoctor-diagram/util/pdf.rb +2 -2
- data/lib/asciidoctor-diagram/util/png.rb +2 -2
- data/lib/{server-1.3.14.jar → asciidoctor-diagram/util/server-1.3.17.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 +5 -143
- data/spec/blockdiag_spec.rb +5 -203
- data/spec/bpmn_spec.rb +52 -92
- data/spec/bytefield_spec.rb +92 -0
- data/spec/ditaa_spec.rb +37 -143
- data/spec/dpic_spec.rb +19 -0
- data/spec/erd_spec.rb +5 -202
- data/spec/gnuplot_spec.rb +2 -255
- data/spec/graphviz_spec.rb +6 -145
- data/spec/lilypond_spec.rb +5 -143
- data/spec/mermaid_spec.rb +68 -210
- data/spec/msc_spec.rb +2 -199
- data/spec/nomnoml_spec.rb +4 -142
- data/spec/pikchr_spec.rb +69 -0
- data/spec/plantuml_spec.rb +6 -578
- data/spec/shaape_spec.rb +12 -224
- data/spec/shared_examples.rb +603 -0
- data/spec/smcat_spec.rb +2 -140
- data/spec/svgbob_spec.rb +5 -143
- data/spec/symbolator_spec.rb +23 -0
- data/spec/syntrax_spec.rb +7 -217
- data/spec/test_helper.rb +4 -28
- data/spec/tikz_spec.rb +68 -18
- data/spec/umlet_spec.rb +2 -58
- data/spec/vega_spec.rb +4 -117
- data/spec/wavedrom_spec.rb +2 -199
- metadata +80 -15
- 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.14.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.14.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
|
+
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, 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
|
@@ -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_windows do
|
87
|
+
include_examples "block_macro", :bytefield, code, [:svg]
|
88
|
+
end
|
89
|
+
|
90
|
+
describe Asciidoctor::Diagram::BytefieldBlockProcessor, :broken_on_windows do
|
91
|
+
include_examples "block", :bytefield, code, [:svg]
|
92
|
+
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
|
+
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
|
13
|
+
eos
|
24
14
|
|
25
|
-
|
26
|
-
|
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
|
-
|
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(/Ambiguous input/i)
|
149
|
+
end
|
256
150
|
end
|
data/spec/dpic_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
code = <<-eos
|
4
|
+
arrow "$u$" above
|
5
|
+
S: circle rad 10/72.27 # 10 pt
|
6
|
+
line right 0.35
|
7
|
+
G: box "$G(s)$"
|
8
|
+
arrow "$y$" above
|
9
|
+
line -> down G.ht from last arrow then left last arrow.c.x-S.x then to S.s
|
10
|
+
"$-\;$" below rjust
|
11
|
+
eos
|
12
|
+
|
13
|
+
describe Asciidoctor::Diagram::DpicBlockMacroProcessor, :broken_on_windows do
|
14
|
+
include_examples "block_macro", :dpic, code, [:svg]
|
15
|
+
end
|
16
|
+
|
17
|
+
describe Asciidoctor::Diagram::DpicBlockProcessor, :broken_on_windows do
|
18
|
+
include_examples "block", :dpic, code, [:svg]
|
19
|
+
end
|