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/test_helper.rb
CHANGED
@@ -6,29 +6,8 @@ require 'stringio'
|
|
6
6
|
require 'tmpdir'
|
7
7
|
|
8
8
|
require_relative '../lib/asciidoctor-diagram'
|
9
|
-
require_relative '../lib/asciidoctor-diagram/a2s/extension'
|
10
|
-
require_relative '../lib/asciidoctor-diagram/blockdiag/extension'
|
11
|
-
require_relative '../lib/asciidoctor-diagram/bytefield'
|
12
|
-
require_relative '../lib/asciidoctor-diagram/ditaa/extension'
|
13
|
-
require_relative '../lib/asciidoctor-diagram/erd/extension'
|
14
|
-
require_relative '../lib/asciidoctor-diagram/gnuplot/extension'
|
15
|
-
require_relative '../lib/asciidoctor-diagram/graphviz/extension'
|
16
|
-
require_relative '../lib/asciidoctor-diagram/lilypond/extension'
|
17
|
-
require_relative '../lib/asciidoctor-diagram/meme/extension'
|
18
|
-
require_relative '../lib/asciidoctor-diagram/mermaid/extension'
|
19
|
-
require_relative '../lib/asciidoctor-diagram/msc/extension'
|
20
|
-
require_relative '../lib/asciidoctor-diagram/nomnoml/extension'
|
21
|
-
require_relative '../lib/asciidoctor-diagram/plantuml/extension'
|
22
|
-
require_relative '../lib/asciidoctor-diagram/shaape/extension'
|
23
|
-
require_relative '../lib/asciidoctor-diagram/smcat/extension'
|
24
|
-
require_relative '../lib/asciidoctor-diagram/svgbob/extension'
|
25
|
-
require_relative '../lib/asciidoctor-diagram/syntrax/extension'
|
26
|
-
require_relative '../lib/asciidoctor-diagram/tikz/extension'
|
27
|
-
require_relative '../lib/asciidoctor-diagram/umlet/extension'
|
28
|
-
require_relative '../lib/asciidoctor-diagram/vega/extension'
|
29
|
-
require_relative '../lib/asciidoctor-diagram/wavedrom/extension'
|
30
|
-
|
31
9
|
require_relative '../lib/asciidoctor-diagram/util/platform'
|
10
|
+
require_relative 'shared_examples'
|
32
11
|
|
33
12
|
module Asciidoctor
|
34
13
|
class AbstractBlock
|
@@ -106,12 +85,8 @@ RSpec.configure do |c|
|
|
106
85
|
c.filter_run_excluding :broken_on_windows => true
|
107
86
|
end
|
108
87
|
|
109
|
-
if ENV['
|
110
|
-
c.filter_run_excluding :
|
111
|
-
end
|
112
|
-
|
113
|
-
if ENV['APPVEYOR']
|
114
|
-
c.filter_run_excluding :broken_on_appveyor => true
|
88
|
+
if ENV['GITHUB_ACTIONS']
|
89
|
+
c.filter_run_excluding :broken_on_github => true
|
115
90
|
end
|
116
91
|
|
117
92
|
TEST_DIR = File.expand_path('testing')
|
@@ -133,4 +108,4 @@ RSpec.configure do |c|
|
|
133
108
|
example.run
|
134
109
|
end
|
135
110
|
end
|
136
|
-
end
|
111
|
+
end
|
data/spec/tikz_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
|
-
|
3
|
+
TIKZ_CODE = <<-'eos'
|
4
4
|
\begin{tikzpicture}[font=\LARGE]
|
5
5
|
|
6
6
|
% Figure parameters (tta and k needs to have the same sign)
|
@@ -98,30 +98,80 @@ code = <<-'eos'
|
|
98
98
|
\end{tikzpicture}
|
99
99
|
eos
|
100
100
|
|
101
|
-
describe Asciidoctor::Diagram::TikZBlockMacroProcessor, :
|
102
|
-
|
103
|
-
|
101
|
+
describe Asciidoctor::Diagram::TikZBlockMacroProcessor, :broken_on_windows do
|
102
|
+
include_examples "block_macro", :tikz, TIKZ_CODE, [:pdf]
|
103
|
+
end
|
104
104
|
|
105
|
-
|
106
|
-
|
105
|
+
describe Asciidoctor::Diagram::TikZBlockProcessor, :broken_on_windows do
|
106
|
+
include_examples "block", :tikz, TIKZ_CODE, [:pdf]
|
107
|
+
|
108
|
+
it "should support the preamble attribute" do
|
109
|
+
File.write("tikz.txt", TIKZ_CODE)
|
110
|
+
|
111
|
+
doc = <<'eos'
|
112
|
+
= Hello, tikz!
|
107
113
|
Doc Writer <doc@example.com>
|
108
114
|
|
109
115
|
== First Section
|
110
116
|
|
111
|
-
tikz
|
112
|
-
|
117
|
+
[tikz, preamble="true"]
|
118
|
+
----
|
119
|
+
\usepackage{tkz-euclide}
|
120
|
+
\usepackage{etoolbox}
|
121
|
+
\usepackage{MnSymbol}
|
122
|
+
\usetikzlibrary{angles,patterns,calc}
|
123
|
+
\usepackage[most]{tcolorbox}
|
124
|
+
\usepackage{pgfplots}
|
125
|
+
\pgfplotsset{compat=1.7}
|
126
|
+
~~~~
|
127
|
+
\begin{tikzpicture}
|
128
|
+
\tikzset{>=stealth}
|
129
|
+
% draw axises and labels. We store a single coordinate to have the
|
130
|
+
% direction of the x axis
|
131
|
+
\draw[->] (-4,0) -- ++(8,0) coordinate (X) node[below] {$x$};
|
132
|
+
\draw[->] (0,-4) -- ++(0,8) node[left] {$y$};
|
133
|
+
|
134
|
+
\newcommand\CircleRadius{3cm}
|
135
|
+
\draw (0,0) circle (\CircleRadius);
|
136
|
+
% special method of noting the position of a point
|
137
|
+
\coordinate (P) at (-495:\CircleRadius);
|
138
|
+
|
139
|
+
\draw[thick]
|
140
|
+
(0,0)
|
141
|
+
coordinate (O) % store origin
|
142
|
+
node[] {} % label
|
143
|
+
--
|
144
|
+
node[below left, pos=1] {$P(-\frac{\sqrt{2}}{2}, -\frac{\sqrt{2}}{2})$} % some labels
|
145
|
+
node[below right, midway] {$r$}
|
146
|
+
(P)
|
147
|
+
--
|
148
|
+
node[midway,left] {$y$}
|
149
|
+
(P |- O) coordinate (Px) % projection onto horizontal line through
|
150
|
+
% O, saved for later
|
151
|
+
--
|
152
|
+
node[midway, below] {$x$}
|
153
|
+
cycle % closed path
|
154
|
+
|
155
|
+
% pic trick is from the angles library, requires the three points of
|
156
|
+
% the marked angle to be named
|
157
|
+
|
158
|
+
pic [] {angle=X--O--P};
|
159
|
+
\draw[->,red] (5mm, 0mm) arc (0:-495:5mm) node[midway,xshift=-4mm,yshift=3.5mm] {$-495^\circ$};
|
160
|
+
% right angle marker
|
161
|
+
\draw ($(Px)+(0.3, 0)$) -- ++(0, -0.3) -- ++(-0.3,0);
|
162
|
+
\end{tikzpicture}
|
163
|
+
----
|
164
|
+
eos
|
113
165
|
|
114
|
-
|
115
|
-
|
166
|
+
d = load_asciidoc doc
|
167
|
+
expect(d).to_not be_nil
|
116
168
|
|
117
|
-
|
118
|
-
|
169
|
+
b = d.find { |bl| bl.context == :image }
|
170
|
+
expect(b).to_not be_nil
|
119
171
|
|
120
|
-
|
172
|
+
expect(b.content_model).to eq :empty
|
121
173
|
|
122
|
-
|
123
|
-
|
124
|
-
expect(target).to match(/\.pdf/)
|
125
|
-
expect(File.exist?(target)).to be true
|
174
|
+
target = b.attributes['target']
|
175
|
+
expect(target).to_not be_nil
|
126
176
|
end
|
127
|
-
end
|
177
|
+
end
|
data/spec/umlet_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
|
-
|
3
|
+
CODE = <<-eos
|
4
4
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
5
5
|
<diagram program="umlet" version="14.2">
|
6
6
|
<zoom_level>10</zoom_level>
|
@@ -21,65 +21,9 @@ eos
|
|
21
21
|
|
22
22
|
|
23
23
|
describe Asciidoctor::Diagram::UmletBlockMacroProcessor do
|
24
|
-
|
25
|
-
File.write('umlet.uxf', code)
|
26
|
-
|
27
|
-
doc = <<-eos
|
28
|
-
= Hello, Umlet!
|
29
|
-
Doc Writer <doc@example.com>
|
30
|
-
|
31
|
-
== First Section
|
32
|
-
|
33
|
-
umlet::umlet.uxf[]
|
34
|
-
eos
|
35
|
-
|
36
|
-
d = load_asciidoc doc
|
37
|
-
expect(d).to_not be_nil
|
38
|
-
|
39
|
-
b = d.find { |bl| bl.context == :image }
|
40
|
-
expect(b).to_not be_nil
|
41
|
-
|
42
|
-
expect(b.content_model).to eq :empty
|
43
|
-
|
44
|
-
target = b.attributes['target']
|
45
|
-
expect(target).to_not be_nil
|
46
|
-
expect(target).to match(/\.svg$/)
|
47
|
-
expect(File.exist?(target)).to be true
|
48
|
-
|
49
|
-
expect(b.attributes['width']).to_not be_nil
|
50
|
-
expect(b.attributes['height']).to_not be_nil
|
51
|
-
end
|
24
|
+
include_examples "block_macro", :umlet, CODE, [:svg]
|
52
25
|
end
|
53
26
|
|
54
|
-
|
55
27
|
describe Asciidoctor::Diagram::UmletBlockProcessor do
|
56
|
-
|
57
|
-
doc = <<-eos
|
58
|
-
= Hello, Umlet!
|
59
|
-
Doc Writer <doc@example.com>
|
60
|
-
|
61
|
-
== First Section
|
62
|
-
|
63
|
-
[umlet]
|
64
|
-
----
|
65
|
-
#{code}
|
66
|
-
----
|
67
|
-
eos
|
68
|
-
|
69
|
-
d = load_asciidoc doc
|
70
|
-
expect(d).to_not be_nil
|
71
|
-
|
72
|
-
b = d.find { |bl| bl.context == :image }
|
73
|
-
expect(b).to_not be_nil
|
74
|
-
|
75
|
-
expect(b.content_model).to eq :empty
|
76
|
-
|
77
|
-
target = b.attributes['target']
|
78
|
-
expect(target).to_not be_nil
|
79
|
-
expect(target).to match(/\.svg$/)
|
80
|
-
expect(File.exist?(target)).to be true
|
81
|
-
|
82
|
-
expect(b.attributes['width']).to_not be_nil
|
83
|
-
expect(b.attributes['height']).to_not be_nil
|
84
|
-
end
|
28
|
+
include_examples "block", :umlet, CODE, [:svg]
|
85
29
|
end
|
data/spec/vega_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
|
-
|
3
|
+
VEGA_CODE = <<-eos
|
4
4
|
{
|
5
5
|
"$schema": "https://vega.github.io/schema/vega/v3.json",
|
6
6
|
"width": 400,
|
@@ -98,7 +98,7 @@ vega_code = <<-eos
|
|
98
98
|
}
|
99
99
|
eos
|
100
100
|
|
101
|
-
|
101
|
+
VEGALITE_CODE = <<-eos
|
102
102
|
{
|
103
103
|
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
|
104
104
|
"description": "A simple bar chart with embedded data.",
|
@@ -118,124 +118,11 @@ vegalite_code = <<-eos
|
|
118
118
|
eos
|
119
119
|
|
120
120
|
describe Asciidoctor::Diagram::VegaBlockMacroProcessor, :broken_on_windows do
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
doc = <<-eos
|
125
|
-
= Hello, Vega!
|
126
|
-
Doc Writer <doc@example.com>
|
127
|
-
|
128
|
-
== First Section
|
129
|
-
|
130
|
-
vega::vega.json[]
|
131
|
-
eos
|
132
|
-
|
133
|
-
d = load_asciidoc doc
|
134
|
-
expect(d).to_not be_nil
|
135
|
-
|
136
|
-
b = d.find { |bl| bl.context == :image }
|
137
|
-
expect(b).to_not be_nil
|
138
|
-
|
139
|
-
expect(b.content_model).to eq :empty
|
140
|
-
|
141
|
-
target = b.attributes['target']
|
142
|
-
expect(target).to_not be_nil
|
143
|
-
expect(target).to match(/\.svg$/)
|
144
|
-
expect(File.exist?(target)).to be true
|
145
|
-
|
146
|
-
expect(b.attributes['width']).to_not be_nil
|
147
|
-
expect(b.attributes['height']).to_not be_nil
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should generate vegalite SVG images when format omitted" do
|
151
|
-
File.write('vega.json', vegalite_code)
|
152
|
-
|
153
|
-
doc = <<-eos
|
154
|
-
= Hello, Vega!
|
155
|
-
Doc Writer <doc@example.com>
|
156
|
-
|
157
|
-
== First Section
|
158
|
-
|
159
|
-
vegalite::vega.json[]
|
160
|
-
eos
|
161
|
-
|
162
|
-
d = load_asciidoc doc
|
163
|
-
expect(d).to_not be_nil
|
164
|
-
|
165
|
-
b = d.find { |bl| bl.context == :image }
|
166
|
-
expect(b).to_not be_nil
|
167
|
-
|
168
|
-
expect(b.content_model).to eq :empty
|
169
|
-
|
170
|
-
target = b.attributes['target']
|
171
|
-
expect(target).to_not be_nil
|
172
|
-
expect(target).to match(/\.svg$/)
|
173
|
-
expect(File.exist?(target)).to be true
|
174
|
-
|
175
|
-
expect(b.attributes['width']).to_not be_nil
|
176
|
-
expect(b.attributes['height']).to_not be_nil
|
177
|
-
end
|
121
|
+
include_examples "block_macro", :vega, VEGA_CODE, [:svg]
|
122
|
+
# include_examples "block_macro", :vegalite, VEGALITE_CODE, [:svg]
|
178
123
|
end
|
179
124
|
|
180
|
-
|
181
125
|
describe Asciidoctor::Diagram::VegaBlockProcessor, :broken_on_windows do
|
182
|
-
|
183
|
-
|
184
|
-
= Hello, Vega!
|
185
|
-
Doc Writer <doc@example.com>
|
186
|
-
|
187
|
-
== First Section
|
188
|
-
|
189
|
-
[vega]
|
190
|
-
----
|
191
|
-
#{vega_code}
|
192
|
-
----
|
193
|
-
eos
|
194
|
-
|
195
|
-
d = load_asciidoc doc
|
196
|
-
expect(d).to_not be_nil
|
197
|
-
|
198
|
-
b = d.find { |bl| bl.context == :image }
|
199
|
-
expect(b).to_not be_nil
|
200
|
-
|
201
|
-
expect(b.content_model).to eq :empty
|
202
|
-
|
203
|
-
target = b.attributes['target']
|
204
|
-
expect(target).to_not be_nil
|
205
|
-
expect(target).to match(/\.svg$/)
|
206
|
-
expect(File.exist?(target)).to be true
|
207
|
-
|
208
|
-
expect(b.attributes['width']).to_not be_nil
|
209
|
-
expect(b.attributes['height']).to_not be_nil
|
210
|
-
end
|
211
|
-
|
212
|
-
it "should generate vegalite SVG images when format is omitted" do
|
213
|
-
doc = <<-eos
|
214
|
-
= Hello, Vega!
|
215
|
-
Doc Writer <doc@example.com>
|
216
|
-
|
217
|
-
== First Section
|
218
|
-
|
219
|
-
[vegalite]
|
220
|
-
----
|
221
|
-
#{vegalite_code}
|
222
|
-
----
|
223
|
-
eos
|
224
|
-
|
225
|
-
d = load_asciidoc doc
|
226
|
-
expect(d).to_not be_nil
|
227
|
-
|
228
|
-
b = d.find { |bl| bl.context == :image }
|
229
|
-
expect(b).to_not be_nil
|
230
|
-
|
231
|
-
expect(b.content_model).to eq :empty
|
232
|
-
|
233
|
-
target = b.attributes['target']
|
234
|
-
expect(target).to_not be_nil
|
235
|
-
expect(target).to match(/\.svg$/)
|
236
|
-
expect(File.exist?(target)).to be true
|
237
|
-
|
238
|
-
expect(b.attributes['width']).to_not be_nil
|
239
|
-
expect(b.attributes['height']).to_not be_nil
|
240
|
-
end
|
126
|
+
include_examples "block", :vega, VEGA_CODE, [:svg]
|
127
|
+
# include_examples "block", :vegalite, VEGALITE_CODE, [:svg]
|
241
128
|
end
|
data/spec/wavedrom_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
|
-
|
3
|
+
WAVEDROM_CODE = <<-eos
|
4
4
|
{ signal : [
|
5
5
|
{ name: "clk", wave: "p......" },
|
6
6
|
{ name: "bus", wave: "x.34.5x", data: "head body tail" },
|
@@ -9,206 +9,9 @@ code = <<-eos
|
|
9
9
|
eos
|
10
10
|
|
11
11
|
describe Asciidoctor::Diagram::WavedromBlockMacroProcessor, :broken_on_windows do
|
12
|
-
|
13
|
-
File.write('wavedrom.txt', code)
|
14
|
-
|
15
|
-
doc = <<-eos
|
16
|
-
= Hello, Wavedrom!
|
17
|
-
Doc Writer <doc@example.com>
|
18
|
-
|
19
|
-
== First Section
|
20
|
-
|
21
|
-
wavedrom::wavedrom.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('wavedrom.txt', code)
|
43
|
-
|
44
|
-
doc = <<-eos
|
45
|
-
= Hello, Wavedrom!
|
46
|
-
Doc Writer <doc@example.com>
|
47
|
-
|
48
|
-
== First Section
|
49
|
-
|
50
|
-
wavedrom::wavedrom.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", :wavedrom, WAVEDROM_CODE, [:png, :svg]
|
69
13
|
end
|
70
14
|
|
71
15
|
describe Asciidoctor::Diagram::WavedromBlockProcessor, :broken_on_windows do
|
72
|
-
|
73
|
-
doc = <<-eos
|
74
|
-
= Hello, Wavedrom!
|
75
|
-
Doc Writer <doc@example.com>
|
76
|
-
|
77
|
-
== First Section
|
78
|
-
|
79
|
-
[wavedrom, 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, Wavedrom!
|
105
|
-
Doc Writer <doc@example.com>
|
106
|
-
|
107
|
-
== First Section
|
108
|
-
|
109
|
-
[wavedrom, 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, Wavedrom!
|
135
|
-
Doc Writer <doc@example.com>
|
136
|
-
|
137
|
-
== First Section
|
138
|
-
|
139
|
-
[wavedrom, 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('wavedrom.txt', code)
|
149
|
-
|
150
|
-
doc = <<-eos
|
151
|
-
= Hello, Wavedrom!
|
152
|
-
Doc Writer <doc@example.com>
|
153
|
-
|
154
|
-
== First Section
|
155
|
-
|
156
|
-
wavedrom::wavedrom.txt
|
157
|
-
|
158
|
-
[wavedrom, 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('wavedrom.txt', code)
|
181
|
-
|
182
|
-
doc = <<-eos
|
183
|
-
= Hello, Wavedrom!
|
184
|
-
Doc Writer <doc@example.com>
|
185
|
-
|
186
|
-
== First Section
|
187
|
-
|
188
|
-
wavedrom::wavedrom.txt[]
|
189
|
-
wavedrom::wavedrom.txt[]
|
190
|
-
eos
|
191
|
-
|
192
|
-
load_asciidoc doc
|
193
|
-
expect(File.exist?('wavedrom.png')).to be true
|
194
|
-
end
|
195
|
-
|
196
|
-
it "should respect target attribute in block macros" do
|
197
|
-
File.write('wavedrom.txt', code)
|
198
|
-
|
199
|
-
doc = <<-eos
|
200
|
-
= Hello, Wavedrom!
|
201
|
-
Doc Writer <doc@example.com>
|
202
|
-
|
203
|
-
== First Section
|
204
|
-
|
205
|
-
wavedrom::wavedrom.txt["foobar"]
|
206
|
-
wavedrom::wavedrom.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?('wavedrom.png')).to be false
|
213
|
-
end
|
16
|
+
include_examples "block", :wavedrom, WAVEDROM_CODE, [:png, :svg]
|
214
17
|
end
|