asciidoctor-diagram 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.adoc +262 -7
- data/README.adoc +463 -40
- data/README_zh-CN.adoc +336 -0
- data/Rakefile +3 -7
- data/examples/features.adoc +2 -2
- data/images/asciidoctor-diagram-classes.png +0 -0
- data/images/asciidoctor-diagram-process.png +0 -0
- data/lib/asciidoctor-diagram/a2s/converter.rb +55 -0
- data/lib/asciidoctor-diagram/a2s/extension.rb +14 -0
- data/lib/asciidoctor-diagram/a2s.rb +7 -0
- data/lib/asciidoctor-diagram/blockdiag/converter.rb +37 -0
- data/lib/asciidoctor-diagram/blockdiag/extension.rb +11 -11
- data/lib/asciidoctor-diagram/blockdiag.rb +5 -4
- data/lib/asciidoctor-diagram/bpmn/converter.rb +62 -0
- data/lib/asciidoctor-diagram/bpmn/extension.rb +14 -0
- data/lib/asciidoctor-diagram/bpmn.rb +7 -0
- data/lib/asciidoctor-diagram/diagram_converter.rb +19 -0
- data/lib/asciidoctor-diagram/diagram_processor.rb +320 -0
- data/lib/asciidoctor-diagram/diagram_source.rb +275 -0
- data/lib/asciidoctor-diagram/ditaa/converter.rb +86 -0
- data/lib/asciidoctor-diagram/ditaa/extension.rb +6 -28
- data/lib/asciidoctor-diagram/ditaa.rb +3 -4
- data/lib/asciidoctor-diagram/erd/converter.rb +31 -0
- data/lib/asciidoctor-diagram/erd/extension.rb +14 -0
- data/lib/asciidoctor-diagram/erd.rb +7 -0
- data/lib/asciidoctor-diagram/gnuplot/converter.rb +63 -0
- data/lib/asciidoctor-diagram/gnuplot/extension.rb +14 -0
- data/lib/asciidoctor-diagram/gnuplot.rb +7 -0
- data/lib/asciidoctor-diagram/graphviz/converter.rb +32 -0
- data/lib/asciidoctor-diagram/graphviz/extension.rb +8 -10
- data/lib/asciidoctor-diagram/graphviz.rb +3 -4
- data/lib/asciidoctor-diagram/http/server.rb +127 -0
- data/lib/asciidoctor-diagram/lilypond/converter.rb +54 -0
- data/lib/asciidoctor-diagram/lilypond/extension.rb +14 -0
- data/lib/asciidoctor-diagram/lilypond.rb +7 -0
- data/lib/asciidoctor-diagram/meme/converter.rb +122 -0
- data/lib/asciidoctor-diagram/meme/extension.rb +28 -0
- data/lib/asciidoctor-diagram/meme.rb +6 -0
- data/lib/asciidoctor-diagram/mermaid/converter.rb +178 -0
- data/lib/asciidoctor-diagram/mermaid/extension.rb +14 -0
- data/lib/asciidoctor-diagram/mermaid.rb +7 -0
- data/lib/asciidoctor-diagram/msc/converter.rb +35 -0
- data/lib/asciidoctor-diagram/msc/extension.rb +14 -0
- data/lib/asciidoctor-diagram/msc.rb +7 -0
- data/lib/asciidoctor-diagram/nomnoml/converter.rb +25 -0
- data/lib/asciidoctor-diagram/nomnoml/extension.rb +14 -0
- data/lib/asciidoctor-diagram/nomnoml.rb +7 -0
- data/lib/asciidoctor-diagram/plantuml/converter.rb +115 -0
- data/lib/asciidoctor-diagram/plantuml/extension.rb +14 -20
- data/lib/asciidoctor-diagram/plantuml.rb +3 -5
- data/lib/asciidoctor-diagram/salt.rb +7 -0
- data/lib/asciidoctor-diagram/shaape/converter.rb +25 -0
- data/lib/asciidoctor-diagram/shaape/extension.rb +9 -11
- data/lib/asciidoctor-diagram/shaape.rb +3 -5
- data/lib/asciidoctor-diagram/smcat/converter.rb +44 -0
- data/lib/asciidoctor-diagram/smcat/extension.rb +14 -0
- data/lib/asciidoctor-diagram/smcat.rb +7 -0
- data/lib/asciidoctor-diagram/svgbob/converter.rb +25 -0
- data/lib/asciidoctor-diagram/svgbob/extension.rb +14 -0
- data/lib/asciidoctor-diagram/svgbob.rb +7 -0
- data/lib/asciidoctor-diagram/syntrax/converter.rb +55 -0
- data/lib/asciidoctor-diagram/syntrax/extension.rb +14 -0
- data/lib/asciidoctor-diagram/syntrax.rb +7 -0
- data/lib/asciidoctor-diagram/tikz/converter.rb +56 -0
- data/lib/asciidoctor-diagram/tikz/extension.rb +14 -0
- data/lib/asciidoctor-diagram/tikz.rb +7 -0
- data/lib/asciidoctor-diagram/umlet/converter.rb +24 -0
- data/lib/asciidoctor-diagram/umlet/extension.rb +14 -0
- data/lib/asciidoctor-diagram/umlet.rb +7 -0
- data/lib/asciidoctor-diagram/util/binaryio.rb +20 -0
- data/lib/asciidoctor-diagram/util/cli.rb +81 -0
- data/lib/asciidoctor-diagram/util/cli_generator.rb +73 -22
- data/lib/asciidoctor-diagram/util/gif.rb +21 -0
- data/lib/asciidoctor-diagram/util/java.rb +95 -1
- data/lib/asciidoctor-diagram/util/java_jruby.rb +14 -20
- data/lib/asciidoctor-diagram/util/java_socket.rb +175 -0
- data/lib/asciidoctor-diagram/util/pdf.rb +10 -0
- data/lib/asciidoctor-diagram/util/platform.rb +97 -0
- data/lib/asciidoctor-diagram/util/png.rb +1 -0
- data/lib/asciidoctor-diagram/util/svg.rb +4 -3
- data/lib/asciidoctor-diagram/util/which.rb +15 -9
- data/lib/asciidoctor-diagram/vega/converter.rb +47 -0
- data/lib/asciidoctor-diagram/vega/extension.rb +14 -0
- data/lib/asciidoctor-diagram/vega.rb +10 -0
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/lib/asciidoctor-diagram/wavedrom/converter.rb +50 -0
- data/lib/asciidoctor-diagram/wavedrom/extension.rb +14 -0
- data/lib/asciidoctor-diagram/wavedrom.rb +7 -0
- data/lib/asciidoctor-diagram.rb +22 -5
- 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/lib/server-1.3.14.jar +0 -0
- data/spec/a2s_spec.rb +167 -0
- data/spec/blockdiag_spec.rb +55 -24
- data/spec/bpmn-example.xml +44 -0
- data/spec/bpmn_spec.rb +96 -0
- data/spec/ditaa_spec.rb +150 -15
- data/spec/erd_spec.rb +289 -0
- data/spec/gnuplot_spec.rb +478 -0
- data/spec/graphviz_spec.rb +20 -20
- data/spec/lilypond_spec.rb +151 -0
- data/spec/man.jpg +0 -0
- data/spec/meme_spec.rb +67 -0
- data/spec/mermaid_spec.rb +336 -0
- data/spec/msc_spec.rb +230 -0
- data/spec/nomnoml_spec.rb +170 -0
- data/spec/plantuml_spec.rb +895 -54
- data/spec/shaape_spec.rb +25 -24
- data/spec/smcat_spec.rb +164 -0
- data/spec/svgbob_spec.rb +167 -0
- data/spec/syntrax_spec.rb +228 -0
- data/spec/test_helper.rb +88 -9
- data/spec/tikz_spec.rb +127 -0
- data/spec/umlet_spec.rb +85 -0
- data/spec/vega_spec.rb +241 -0
- data/spec/wavedrom_spec.rb +214 -0
- metadata +130 -35
- data/lib/asciidoctor-diagram/plantuml/generator.rb +0 -46
- data/lib/asciidoctor-diagram/util/diagram.rb +0 -220
- data/lib/asciidoctor-diagram/util/java_rjb.rb +0 -90
- data/lib/ditaamini0_9.jar +0 -0
@@ -0,0 +1,151 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
code = <<-eos
|
4
|
+
\\relative c' { f d f a d f e d cis a cis e a g f e }
|
5
|
+
eos
|
6
|
+
|
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
|
36
|
+
end
|
37
|
+
|
38
|
+
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
|
151
|
+
end
|
data/spec/man.jpg
ADDED
Binary file
|
data/spec/meme_spec.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe Asciidoctor::Diagram::MemeBlockMacroProcessor do
|
4
|
+
it "should generate PNG images when format is set to 'png'" do
|
5
|
+
FileUtils.cp(
|
6
|
+
File.expand_path('man.jpg', File.dirname(__FILE__)),
|
7
|
+
File.expand_path('man.jpg', Dir.getwd)
|
8
|
+
)
|
9
|
+
|
10
|
+
doc = <<-eos
|
11
|
+
= Hello, PlantUML!
|
12
|
+
Doc Writer <doc@example.com>
|
13
|
+
|
14
|
+
== First Section
|
15
|
+
|
16
|
+
meme::man.jpg[I don't always // write unit tests, but when I do // they generate memes, format=png, options=noupcase]
|
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(/\.png$/)
|
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 GIF images when format is set to 'gif'" do
|
37
|
+
FileUtils.cp(
|
38
|
+
File.expand_path('man.jpg', File.dirname(__FILE__)),
|
39
|
+
File.expand_path('man.jpg', Dir.getwd)
|
40
|
+
)
|
41
|
+
|
42
|
+
doc = <<-eos
|
43
|
+
= Hello, PlantUML!
|
44
|
+
Doc Writer <doc@example.com>
|
45
|
+
|
46
|
+
== First Section
|
47
|
+
|
48
|
+
meme::man.jpg[I don't always // write unit tests, but when I do // they generate memes, format=gif, options=noupcase]
|
49
|
+
eos
|
50
|
+
|
51
|
+
d = load_asciidoc doc
|
52
|
+
expect(d).to_not be_nil
|
53
|
+
|
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(/\.gif/)
|
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
|
+
end
|
@@ -0,0 +1,336 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
code = <<-eos
|
4
|
+
graph LR
|
5
|
+
A[Square Rect] -- Link text --> B((Circle))
|
6
|
+
A --> C(Round Rect)
|
7
|
+
B --> D{Rhombus}
|
8
|
+
C --> D
|
9
|
+
eos
|
10
|
+
|
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
|
69
|
+
end
|
70
|
+
|
71
|
+
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
|
214
|
+
|
215
|
+
it "should respect the sequenceConfig attribute" do
|
216
|
+
seq_diag = <<-eos
|
217
|
+
sequenceDiagram
|
218
|
+
Alice->>John: Hello John, how are you?
|
219
|
+
John-->>Alice: Great!
|
220
|
+
eos
|
221
|
+
|
222
|
+
seq_config = <<-eos
|
223
|
+
{
|
224
|
+
"diagramMarginX": 0,
|
225
|
+
"diagramMarginY": 0,
|
226
|
+
"actorMargin": 0,
|
227
|
+
"boxMargin": 0,
|
228
|
+
"boxTextMargin": 0,
|
229
|
+
"noteMargin": 0,
|
230
|
+
"messageMargin": 0
|
231
|
+
}
|
232
|
+
eos
|
233
|
+
File.write('seqconfig.txt', seq_config)
|
234
|
+
|
235
|
+
File.write('mermaid.txt', seq_diag)
|
236
|
+
|
237
|
+
doc = <<-eos
|
238
|
+
= Hello, Mermaid!
|
239
|
+
Doc Writer <doc@example.com>
|
240
|
+
|
241
|
+
== First Section
|
242
|
+
|
243
|
+
mermaid::mermaid.txt["with_config", sequenceConfig="seqconfig.txt"]
|
244
|
+
mermaid::mermaid.txt["without_config"]
|
245
|
+
eos
|
246
|
+
|
247
|
+
load_asciidoc doc
|
248
|
+
expect(File.exist?('with_config.png')).to be true
|
249
|
+
expect(File.exist?('without_config.png')).to be true
|
250
|
+
expect(File.size('with_config.png')).to_not be File.size('without_config.png')
|
251
|
+
end
|
252
|
+
|
253
|
+
it "should respect the width attribute" do
|
254
|
+
seq_diag = <<-eos
|
255
|
+
sequenceDiagram
|
256
|
+
Alice->>Bob: Hello Bob, how are you?
|
257
|
+
Bob->>Claire: Hello Claire, how are you?
|
258
|
+
Claire->>Doug: Hello Doug, how are you?
|
259
|
+
eos
|
260
|
+
|
261
|
+
File.write('mermaid.txt', seq_diag)
|
262
|
+
|
263
|
+
doc = <<-eos
|
264
|
+
= Hello, Mermaid!
|
265
|
+
Doc Writer <doc@example.com>
|
266
|
+
|
267
|
+
== First Section
|
268
|
+
|
269
|
+
mermaid::mermaid.txt["with_width", width="700"]
|
270
|
+
mermaid::mermaid.txt["without_width"]
|
271
|
+
eos
|
272
|
+
|
273
|
+
load_asciidoc doc
|
274
|
+
expect(File.exist?('with_width.png')).to be true
|
275
|
+
expect(File.exist?('without_width.png')).to be true
|
276
|
+
expect(File.size('with_width.png')).to_not be File.size('without_width.png')
|
277
|
+
end
|
278
|
+
|
279
|
+
it "should respect the theme attribute" do
|
280
|
+
seq_diag = <<-eos
|
281
|
+
sequenceDiagram
|
282
|
+
Alice->>Bob: Hello Bob, how are you?
|
283
|
+
Bob->>Claire: Hello Claire, how are you?
|
284
|
+
Claire->>Doug: Hello Doug, how are you?
|
285
|
+
eos
|
286
|
+
|
287
|
+
File.write('mermaid.txt', seq_diag)
|
288
|
+
|
289
|
+
doc = <<-eos
|
290
|
+
= Hello, Mermaid!
|
291
|
+
Doc Writer <doc@example.com>
|
292
|
+
|
293
|
+
== First Section
|
294
|
+
|
295
|
+
mermaid::mermaid.txt["default", format="svg"]
|
296
|
+
mermaid::mermaid.txt["dark", format="svg", theme="dark"]
|
297
|
+
eos
|
298
|
+
|
299
|
+
load_asciidoc doc
|
300
|
+
expect(File.exist?('default.svg')).to be true
|
301
|
+
expect(File.exist?('dark.svg')).to be true
|
302
|
+
expect(File.read('default.svg')).to_not be File.read('dark.svg')
|
303
|
+
end
|
304
|
+
|
305
|
+
it "should respect the puppeteerConfig attribute" do
|
306
|
+
seq_diag = <<-eos
|
307
|
+
sequenceDiagram
|
308
|
+
Alice->>John: Hello John, how are you?
|
309
|
+
John-->>Alice: Great!
|
310
|
+
eos
|
311
|
+
|
312
|
+
pptr_config = <<-eos
|
313
|
+
{
|
314
|
+
"args": ["--no-sandbox"]
|
315
|
+
}
|
316
|
+
eos
|
317
|
+
File.write('pptrconfig.txt', pptr_config)
|
318
|
+
|
319
|
+
File.write('mermaid.txt', seq_diag)
|
320
|
+
|
321
|
+
doc = <<-eos
|
322
|
+
= Hello, Mermaid!
|
323
|
+
Doc Writer <doc@example.com>
|
324
|
+
|
325
|
+
== First Section
|
326
|
+
|
327
|
+
mermaid::mermaid.txt["with_config", puppeteerConfig="pptrconfig.txt"]
|
328
|
+
mermaid::mermaid.txt["without_config"]
|
329
|
+
eos
|
330
|
+
|
331
|
+
load_asciidoc doc
|
332
|
+
expect(File.exist?('with_config.png')).to be true
|
333
|
+
expect(File.exist?('without_config.png')).to be true
|
334
|
+
expect(File.size('with_config.png')).to be File.size('without_config.png')
|
335
|
+
end
|
336
|
+
end
|