asciidoctor-diagram 2.2.11 → 2.2.12.next1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +7 -0
- data/lib/asciidoctor-diagram/plantuml/converter.rb +1 -0
- data/lib/asciidoctor-diagram/structurizr/renderers.rb +5 -0
- data/lib/asciidoctor-diagram/version.rb +1 -1
- metadata +5 -132
- data/Rakefile +0 -9
- data/docs/antora.yml +0 -5
- data/docs/modules/ROOT/images/a2s.svg +0 -44
- data/docs/modules/ROOT/images/actdiag.png +0 -0
- data/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/images/barcode.png +0 -0
- data/docs/modules/ROOT/images/barcode2.png +0 -0
- data/docs/modules/ROOT/images/blockdiag.png +0 -0
- data/docs/modules/ROOT/images/d2.png +0 -0
- data/docs/modules/ROOT/images/lilypond.png +0 -0
- data/docs/modules/ROOT/images/penrose.png +0 -0
- data/docs/modules/ROOT/nav.adoc +0 -41
- data/docs/modules/ROOT/pages/blocks.adoc +0 -140
- data/docs/modules/ROOT/pages/diagram_types/a2s.adoc +0 -47
- data/docs/modules/ROOT/pages/diagram_types/actdiag.adoc +0 -46
- data/docs/modules/ROOT/pages/diagram_types/barcode.adoc +0 -72
- data/docs/modules/ROOT/pages/diagram_types/blockdiag.adoc +0 -38
- data/docs/modules/ROOT/pages/diagram_types/bpmn.adoc +0 -21
- data/docs/modules/ROOT/pages/diagram_types/bytefield.adoc +0 -16
- data/docs/modules/ROOT/pages/diagram_types/d2.adoc +0 -43
- data/docs/modules/ROOT/pages/diagram_types/dbml.adoc +0 -16
- data/docs/modules/ROOT/pages/diagram_types/diagrams.adoc +0 -20
- data/docs/modules/ROOT/pages/diagram_types/ditaa.adoc +0 -31
- data/docs/modules/ROOT/pages/diagram_types/dpic.adoc +0 -16
- data/docs/modules/ROOT/pages/diagram_types/erd.adoc +0 -17
- data/docs/modules/ROOT/pages/diagram_types/gnuplot.adoc +0 -27
- data/docs/modules/ROOT/pages/diagram_types/graphviz.adoc +0 -21
- data/docs/modules/ROOT/pages/diagram_types/lilypond.adoc +0 -27
- data/docs/modules/ROOT/pages/diagram_types/meme.adoc +0 -34
- data/docs/modules/ROOT/pages/diagram_types/mermaid.adoc +0 -28
- data/docs/modules/ROOT/pages/diagram_types/msc.adoc +0 -23
- data/docs/modules/ROOT/pages/diagram_types/nomnoml.adoc +0 -16
- data/docs/modules/ROOT/pages/diagram_types/nwdiag.adoc +0 -22
- data/docs/modules/ROOT/pages/diagram_types/penrose.adoc +0 -50
- data/docs/modules/ROOT/pages/diagram_types/pikchr.adoc +0 -16
- data/docs/modules/ROOT/pages/diagram_types/plantuml.adoc +0 -24
- data/docs/modules/ROOT/pages/diagram_types/seqdiag.adoc +0 -18
- data/docs/modules/ROOT/pages/diagram_types/shaape.adoc +0 -18
- data/docs/modules/ROOT/pages/diagram_types/smcat.adoc +0 -18
- data/docs/modules/ROOT/pages/diagram_types/structurizr.adoc +0 -29
- data/docs/modules/ROOT/pages/diagram_types/svgbob.adoc +0 -21
- data/docs/modules/ROOT/pages/diagram_types/symbolator.adoc +0 -19
- data/docs/modules/ROOT/pages/diagram_types/syntrax.adoc +0 -28
- data/docs/modules/ROOT/pages/diagram_types/tikz.adoc +0 -21
- data/docs/modules/ROOT/pages/diagram_types/umlet.adoc +0 -19
- data/docs/modules/ROOT/pages/diagram_types/vega.adoc +0 -28
- data/docs/modules/ROOT/pages/diagram_types/wavedrom.adoc +0 -17
- data/docs/modules/ROOT/pages/enabling.adoc +0 -25
- data/docs/modules/ROOT/pages/generate.adoc +0 -15
- data/docs/modules/ROOT/pages/index.adoc +0 -12
- data/docs/modules/ROOT/pages/installation.adoc +0 -32
- data/docs/modules/ROOT/pages/output.adoc +0 -19
- data/docs/modules/ROOT/partials/shared-attrs.adoc +0 -12
- data/docs/modules/ROOT/partials/uris.adoc +0 -48
- data/examples/Gemfile +0 -3
- data/examples/README.adoc +0 -18
- data/examples/design.adoc +0 -78
- data/examples/features.adoc +0 -189
- data/spec/a2s_spec.rb +0 -33
- data/spec/barcode_spec.rb +0 -176
- data/spec/blockdiag_spec.rb +0 -20
- data/spec/bpmn_spec.rb +0 -60
- data/spec/bytefield_spec.rb +0 -96
- data/spec/d2_spec.rb +0 -87
- data/spec/dbml_spec.rb +0 -32
- data/spec/diagrams_spec.rb +0 -27
- data/spec/ditaa_spec.rb +0 -191
- data/spec/dpic_spec.rb +0 -23
- data/spec/erd_spec.rb +0 -96
- data/spec/gnuplot_spec.rb +0 -229
- data/spec/graphviz_py_spec.rb +0 -33
- data/spec/graphviz_spec.rb +0 -24
- data/spec/lilypond_spec.rb +0 -17
- data/spec/man.jpg +0 -0
- data/spec/meme_spec.rb +0 -67
- data/spec/mermaid_spec.rb +0 -161
- data/spec/msc_spec.rb +0 -37
- data/spec/nomnoml_spec.rb +0 -36
- data/spec/pikchr_spec.rb +0 -73
- data/spec/plantuml_spec.rb +0 -800
- data/spec/shaape_spec.rb +0 -20
- data/spec/shared_examples.rb +0 -766
- data/spec/smcat_spec.rb +0 -30
- data/spec/structurizr_spec.rb +0 -41
- data/spec/svgbob_spec.rb +0 -33
- data/spec/symbolator_spec.rb +0 -27
- data/spec/syntrax_spec.rb +0 -22
- data/spec/test_helper_methods.rb +0 -118
- data/spec/tikz_spec.rb +0 -181
- data/spec/umlet_spec.rb +0 -32
- data/spec/vega_spec.rb +0 -133
- data/spec/wavedrom_spec.rb +0 -21
data/spec/shared_examples.rb
DELETED
@@ -1,766 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require_relative 'test_helper_methods'
|
3
|
-
|
4
|
-
RSpec.shared_examples "block_macro" do |name, code, formats|
|
5
|
-
formats.each do |format|
|
6
|
-
if format == :txt
|
7
|
-
it "#{name} should generate literal blocks when format is set to 'txt'" do
|
8
|
-
File.write("#{name}.txt", code)
|
9
|
-
|
10
|
-
doc = <<-eos
|
11
|
-
= Hello, #{name}!
|
12
|
-
Doc Writer <doc@example.com>
|
13
|
-
|
14
|
-
== First Section
|
15
|
-
|
16
|
-
#{name}::#{name}.txt[#{format}]
|
17
|
-
eos
|
18
|
-
|
19
|
-
d = load_asciidoc doc
|
20
|
-
expect(d).to_not be_nil
|
21
|
-
|
22
|
-
b = d.find { |bl| bl.context == :literal }
|
23
|
-
expect(b).to_not be_nil
|
24
|
-
|
25
|
-
expect(b.content_model).to eq :verbatim
|
26
|
-
|
27
|
-
expect(b.attributes['target']).to be_nil
|
28
|
-
end
|
29
|
-
else
|
30
|
-
it "#{name} should generate image blocks when format is set to '#{format}'" do
|
31
|
-
File.write("#{name}.txt", code)
|
32
|
-
|
33
|
-
doc = <<-eos
|
34
|
-
= Hello, #{name}!
|
35
|
-
Doc Writer <doc@example.com>
|
36
|
-
|
37
|
-
== First Section
|
38
|
-
|
39
|
-
#{name}::#{name}.txt[#{format}]
|
40
|
-
eos
|
41
|
-
|
42
|
-
d = load_asciidoc doc
|
43
|
-
expect(d).to_not be_nil
|
44
|
-
|
45
|
-
b = d.find { |bl| bl.context == :image }
|
46
|
-
expect(b).to_not be_nil
|
47
|
-
|
48
|
-
expect(b.content_model).to eq :empty
|
49
|
-
|
50
|
-
target = b.attributes['target']
|
51
|
-
expect(target).to_not be_nil
|
52
|
-
expect(target).to match(/\.#{format}$/)
|
53
|
-
expect(File.exist?(target)).to be true
|
54
|
-
|
55
|
-
unless format == :pdf
|
56
|
-
expect(b.attributes['width']).to_not be_nil
|
57
|
-
expect(b.attributes['height']).to_not be_nil
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should support substitutions in the target attribute' do
|
64
|
-
File.write("#{name}.txt", code)
|
65
|
-
|
66
|
-
doc = <<-eos
|
67
|
-
= Hello, #{name}!
|
68
|
-
Doc Writer <doc@example.com>
|
69
|
-
:file: #{name}
|
70
|
-
|
71
|
-
== First Section
|
72
|
-
|
73
|
-
#{name}::{file}.txt[subs=attributes+]
|
74
|
-
eos
|
75
|
-
|
76
|
-
d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
|
77
|
-
expect(d).to_not be_nil
|
78
|
-
|
79
|
-
b = d.find { |bl| bl.context == :image }
|
80
|
-
expect(b).to_not be_nil
|
81
|
-
|
82
|
-
target = b.attributes['target']
|
83
|
-
expect(File.exist?(target)).to be true
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'should support substitutions in the format attribute' do
|
87
|
-
File.write("#{name}.txt", code)
|
88
|
-
|
89
|
-
doc = <<-eos
|
90
|
-
= Hello, #{name}!
|
91
|
-
Doc Writer <doc@example.com>
|
92
|
-
:file: #{name}
|
93
|
-
:outputformat: #{formats[0]}
|
94
|
-
|
95
|
-
== First Section
|
96
|
-
|
97
|
-
#{name}::{file}.txt[format="{outputformat}", subs=attributes+]
|
98
|
-
eos
|
99
|
-
|
100
|
-
d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
|
101
|
-
expect(d).to_not be_nil
|
102
|
-
|
103
|
-
b = d.find { |bl| bl.context == :image }
|
104
|
-
expect(b).to_not be_nil
|
105
|
-
|
106
|
-
target = b.attributes['target']
|
107
|
-
expect(target).to match(/\.#{formats[0]}$/)
|
108
|
-
expect(File.exist?(target)).to be true
|
109
|
-
|
110
|
-
unless formats[0] == :pdf
|
111
|
-
expect(b.attributes['width']).to_not be_nil
|
112
|
-
expect(b.attributes['height']).to_not be_nil
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'should generate blocks with figure captions' do
|
117
|
-
File.write("#{name}.txt", code)
|
118
|
-
|
119
|
-
doc = <<-eos
|
120
|
-
= Hello, #{name}!
|
121
|
-
Doc Writer <doc@example.com>
|
122
|
-
|
123
|
-
== First Section
|
124
|
-
|
125
|
-
.This is a diagram
|
126
|
-
#{name}::#{name}.txt[]
|
127
|
-
eos
|
128
|
-
|
129
|
-
d = load_asciidoc doc
|
130
|
-
expect(d).to_not be_nil
|
131
|
-
|
132
|
-
b = d.find { |bl| bl.context == :image }
|
133
|
-
expect(b).to_not be_nil
|
134
|
-
|
135
|
-
expect(b.caption).to match(/Figure \d+/)
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'should handle two block macros with the same source' do
|
139
|
-
File.write("#{name}.txt", code)
|
140
|
-
|
141
|
-
doc = <<-eos
|
142
|
-
= Hello, #{name}!
|
143
|
-
Doc Writer <doc@example.com>
|
144
|
-
|
145
|
-
== First Section
|
146
|
-
|
147
|
-
#{name}::#{name}.txt[]
|
148
|
-
#{name}::#{name}.txt[]
|
149
|
-
eos
|
150
|
-
|
151
|
-
d = load_asciidoc doc
|
152
|
-
|
153
|
-
b = d.find { |bl| bl.context == :image }
|
154
|
-
expect(b).to_not be_nil
|
155
|
-
|
156
|
-
target = b.attributes['target']
|
157
|
-
expect(File.exist?(target)).to be true
|
158
|
-
end
|
159
|
-
|
160
|
-
it 'should respect target attribute in block macros' do
|
161
|
-
File.write("#{name}.txt", code)
|
162
|
-
|
163
|
-
doc = <<-eos
|
164
|
-
= Hello, #{name}!
|
165
|
-
Doc Writer <doc@example.com>
|
166
|
-
|
167
|
-
== First Section
|
168
|
-
|
169
|
-
#{name}::#{name}.txt[target="foobar"]
|
170
|
-
#{name}::#{name}.txt[target="foobaz"]
|
171
|
-
eos
|
172
|
-
|
173
|
-
load_asciidoc doc
|
174
|
-
expect(File.exist?("foobar.#{formats[0]}")).to be true
|
175
|
-
expect(File.exist?("foobaz.#{formats[0]}")).to be true
|
176
|
-
expect(File.exist?("#{name}.#{formats[0]}")).to be false
|
177
|
-
end
|
178
|
-
|
179
|
-
it 'should respect target attribute values with relative paths in block macros' do
|
180
|
-
File.write("#{name}.txt", code)
|
181
|
-
|
182
|
-
doc = <<-eos
|
183
|
-
= Hello, #{name}!
|
184
|
-
Doc Writer <doc@example.com>
|
185
|
-
|
186
|
-
== First Section
|
187
|
-
|
188
|
-
#{name}::#{name}.txt[target="test/foobar"]
|
189
|
-
#{name}::#{name}.txt[target="test2/foobaz"]
|
190
|
-
eos
|
191
|
-
|
192
|
-
load_asciidoc doc
|
193
|
-
expect(File.exist?("test/foobar.#{formats[0]}")).to be true
|
194
|
-
expect(File.exist?("test2/foobaz.#{formats[0]}")).to be true
|
195
|
-
expect(File.exist?("#{name}.#{formats[0]}")).to be false
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
RSpec.shared_examples "inline_macro" do |name, code, formats|
|
200
|
-
formats.each do |format|
|
201
|
-
it "#{name} should generate image tags when format is set to '#{format}'" do
|
202
|
-
File.write("#{name}.txt", code)
|
203
|
-
|
204
|
-
doc = <<-eos
|
205
|
-
= Hello, #{name}!
|
206
|
-
Doc Writer <doc@example.com>
|
207
|
-
|
208
|
-
== First Section
|
209
|
-
|
210
|
-
#{name}:#{name}.txt[#{format}]
|
211
|
-
eos
|
212
|
-
|
213
|
-
d = load_asciidoc doc
|
214
|
-
expect(d).to_not be_nil
|
215
|
-
|
216
|
-
b = d.find { |bl| bl.context == :paragraph }
|
217
|
-
expect(b).to_not be_nil
|
218
|
-
|
219
|
-
output = b.convert
|
220
|
-
img_match = /<img[^>]*>/.match(output)
|
221
|
-
expect(img_match).to_not be_nil
|
222
|
-
img = img_match.to_s
|
223
|
-
|
224
|
-
src_match = /src="([^"]*)"/.match(img)
|
225
|
-
expect(src_match).to_not be_nil
|
226
|
-
src = src_match[1]
|
227
|
-
|
228
|
-
expect(src).to_not be_nil
|
229
|
-
expect(src).to match(/\.#{format}$/)
|
230
|
-
expect(File.exist?(src)).to be true
|
231
|
-
|
232
|
-
unless format == :pdf
|
233
|
-
expect(/width="([^"]*)"/.match(img)).to_not be_nil
|
234
|
-
expect(/height="([^"]*)"/.match(img)).to_not be_nil
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
it 'should support substitutions in the target attribute' do
|
240
|
-
File.write("#{name}.txt", code)
|
241
|
-
|
242
|
-
doc = <<-eos
|
243
|
-
= Hello, #{name}!
|
244
|
-
Doc Writer <doc@example.com>
|
245
|
-
:file: #{name}
|
246
|
-
|
247
|
-
== First Section
|
248
|
-
|
249
|
-
#{name}:{file}.txt[subs=attributes+]
|
250
|
-
eos
|
251
|
-
|
252
|
-
d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
|
253
|
-
expect(d).to_not be_nil
|
254
|
-
|
255
|
-
b = d.find { |bl| bl.context == :paragraph }
|
256
|
-
expect(b).to_not be_nil
|
257
|
-
|
258
|
-
output = b.convert
|
259
|
-
img_match = /<img[^>]*>/.match(output)
|
260
|
-
expect(img_match).to_not be_nil
|
261
|
-
img = img_match.to_s
|
262
|
-
|
263
|
-
src_match = /src="([^"]*)"/.match(img)
|
264
|
-
expect(src_match).to_not be_nil
|
265
|
-
src = src_match[1]
|
266
|
-
|
267
|
-
expect(src).to_not be_nil
|
268
|
-
expect(src).to match(/\.#{formats[0]}$/)
|
269
|
-
expect(File.exist?(src)).to be true
|
270
|
-
end
|
271
|
-
|
272
|
-
it 'should support substitutions in the format attribute' do
|
273
|
-
File.write("#{name}.txt", code)
|
274
|
-
|
275
|
-
doc = <<-eos
|
276
|
-
= Hello, #{name}!
|
277
|
-
Doc Writer <doc@example.com>
|
278
|
-
:file: #{name}
|
279
|
-
:outputformat: #{formats[0]}
|
280
|
-
|
281
|
-
== First Section
|
282
|
-
|
283
|
-
#{name}:{file}.txt[format="{outputformat}", subs=attributes+]
|
284
|
-
eos
|
285
|
-
|
286
|
-
d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
|
287
|
-
expect(d).to_not be_nil
|
288
|
-
|
289
|
-
b = d.find { |bl| bl.context == :paragraph }
|
290
|
-
expect(b).to_not be_nil
|
291
|
-
|
292
|
-
output = b.convert
|
293
|
-
img_match = /<img[^>]*>/.match(output)
|
294
|
-
expect(img_match).to_not be_nil
|
295
|
-
img = img_match.to_s
|
296
|
-
|
297
|
-
src_match = /src="([^"]*)"/.match(img)
|
298
|
-
expect(src_match).to_not be_nil
|
299
|
-
src = src_match[1]
|
300
|
-
|
301
|
-
expect(src).to_not be_nil
|
302
|
-
expect(src).to match(/\.#{formats[0]}$/)
|
303
|
-
expect(File.exist?(src)).to be true
|
304
|
-
|
305
|
-
unless formats[0] == :pdf
|
306
|
-
expect(/width="([^"]*)"/.match(img)).to_not be_nil
|
307
|
-
expect(/height="([^"]*)"/.match(img)).to_not be_nil
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
it 'should respect target attribute in inline macros' do
|
312
|
-
File.write("#{name}.txt", code)
|
313
|
-
|
314
|
-
doc = <<-eos
|
315
|
-
= Hello, #{name}!
|
316
|
-
Doc Writer <doc@example.com>
|
317
|
-
|
318
|
-
== First Section
|
319
|
-
|
320
|
-
#{name}:#{name}.txt[target="foobar"]
|
321
|
-
#{name}:#{name}.txt[target="foobaz"]
|
322
|
-
eos
|
323
|
-
|
324
|
-
d = load_asciidoc doc
|
325
|
-
|
326
|
-
b = d.find { |bl| bl.context == :paragraph }
|
327
|
-
expect(b).to_not be_nil
|
328
|
-
b.convert
|
329
|
-
|
330
|
-
expect(File.exist?("foobar.#{formats[0]}")).to be true
|
331
|
-
expect(File.exist?("foobaz.#{formats[0]}")).to be true
|
332
|
-
expect(File.exist?("#{name}.#{formats[0]}")).to be false
|
333
|
-
end
|
334
|
-
|
335
|
-
it 'should respect target attribute values with relative paths in inline macros' do
|
336
|
-
File.write("#{name}.txt", code)
|
337
|
-
|
338
|
-
doc = <<-eos
|
339
|
-
= Hello, #{name}!
|
340
|
-
Doc Writer <doc@example.com>
|
341
|
-
|
342
|
-
== First Section
|
343
|
-
|
344
|
-
#{name}:#{name}.txt[target="test/foobar"]
|
345
|
-
#{name}:#{name}.txt[target="test2/foobaz"]
|
346
|
-
eos
|
347
|
-
|
348
|
-
d = load_asciidoc doc
|
349
|
-
|
350
|
-
b = d.find { |bl| bl.context == :paragraph }
|
351
|
-
expect(b).to_not be_nil
|
352
|
-
b.convert
|
353
|
-
|
354
|
-
expect(File.exist?("test/foobar.#{formats[0]}")).to be true
|
355
|
-
expect(File.exist?("test2/foobaz.#{formats[0]}")).to be true
|
356
|
-
expect(File.exist?("#{name}.#{formats[0]}")).to be false
|
357
|
-
end
|
358
|
-
end
|
359
|
-
|
360
|
-
RSpec.shared_examples "block" do |name, code, formats|
|
361
|
-
formats.each do |format|
|
362
|
-
if format == :txt
|
363
|
-
it "#{name} should generate literal blocks when format is set to 'txt'" do
|
364
|
-
doc = <<-eos
|
365
|
-
= Hello, #{name}!
|
366
|
-
Doc Writer <doc@example.com>
|
367
|
-
|
368
|
-
== First Section
|
369
|
-
|
370
|
-
[#{name}, format="#{format}"]
|
371
|
-
----
|
372
|
-
#{code}
|
373
|
-
----
|
374
|
-
eos
|
375
|
-
|
376
|
-
d = load_asciidoc doc
|
377
|
-
expect(d).to_not be_nil
|
378
|
-
|
379
|
-
b = d.find { |bl| bl.context == :literal }
|
380
|
-
expect(b).to_not be_nil
|
381
|
-
|
382
|
-
expect(b.content_model).to eq :verbatim
|
383
|
-
|
384
|
-
expect(b.attributes['target']).to be_nil
|
385
|
-
end
|
386
|
-
else
|
387
|
-
it "#{name} should generate image blocks when format is set to '#{format}'" do
|
388
|
-
doc = <<-eos
|
389
|
-
= Hello, #{name}!
|
390
|
-
Doc Writer <doc@example.com>
|
391
|
-
|
392
|
-
== First Section
|
393
|
-
|
394
|
-
[#{name}, format="#{format}"]
|
395
|
-
----
|
396
|
-
#{code}
|
397
|
-
----
|
398
|
-
eos
|
399
|
-
|
400
|
-
d = load_asciidoc doc
|
401
|
-
expect(d).to_not be_nil
|
402
|
-
|
403
|
-
b = d.find { |bl| bl.context == :image }
|
404
|
-
expect(b).to_not be_nil
|
405
|
-
|
406
|
-
expect(b.content_model).to eq :empty
|
407
|
-
|
408
|
-
target = b.attributes['target']
|
409
|
-
expect(target).to_not be_nil
|
410
|
-
expect(target).to match(/\.#{format}$/)
|
411
|
-
expect(File.exist?(target)).to be true
|
412
|
-
|
413
|
-
unless format == :pdf
|
414
|
-
expect(b.attributes['width']).to_not be_nil
|
415
|
-
expect(b.attributes['height']).to_not be_nil
|
416
|
-
end
|
417
|
-
end
|
418
|
-
end
|
419
|
-
end
|
420
|
-
|
421
|
-
if formats.include? :svg
|
422
|
-
it "#{name} should respect the svg-type attribute when format is set to 'svg'" do
|
423
|
-
doc = <<-eos
|
424
|
-
= Hello, #{name}!
|
425
|
-
Doc Writer <doc@example.com>
|
426
|
-
|
427
|
-
== First Section
|
428
|
-
|
429
|
-
[#{name}, format="svg", svg-type="inline"]
|
430
|
-
----
|
431
|
-
#{code}
|
432
|
-
----
|
433
|
-
eos
|
434
|
-
|
435
|
-
d = load_asciidoc doc
|
436
|
-
expect(d).to_not be_nil
|
437
|
-
|
438
|
-
b = d.find { |bl| bl.context == :image }
|
439
|
-
expect(b).to_not be_nil
|
440
|
-
|
441
|
-
expect(b.content_model).to eq :empty
|
442
|
-
|
443
|
-
target = b.attributes['target']
|
444
|
-
expect(target).to_not be_nil
|
445
|
-
expect(target).to match(/\.svg/)
|
446
|
-
expect(File.exist?(target)).to be true
|
447
|
-
|
448
|
-
expect(b.option?('inline')).to be_truthy
|
449
|
-
|
450
|
-
unless formats[0] == :pdf
|
451
|
-
expect(b.attributes['width']).to_not be_nil
|
452
|
-
expect(b.attributes['height']).to_not be_nil
|
453
|
-
end
|
454
|
-
end
|
455
|
-
|
456
|
-
it "#{name} should respect the diagram-svg-type attribute when format is set to 'svg'" do
|
457
|
-
doc = <<-eos
|
458
|
-
= Hello, #{name}!
|
459
|
-
:diagram-svg-type: inline
|
460
|
-
Doc Writer <doc@example.com>
|
461
|
-
|
462
|
-
== First Section
|
463
|
-
|
464
|
-
[#{name}, format="svg"]
|
465
|
-
----
|
466
|
-
#{code}
|
467
|
-
----
|
468
|
-
eos
|
469
|
-
|
470
|
-
d = load_asciidoc doc
|
471
|
-
expect(d).to_not be_nil
|
472
|
-
|
473
|
-
b = d.find { |bl| bl.context == :image }
|
474
|
-
expect(b).to_not be_nil
|
475
|
-
|
476
|
-
expect(b.content_model).to eq :empty
|
477
|
-
|
478
|
-
target = b.attributes['target']
|
479
|
-
expect(target).to_not be_nil
|
480
|
-
expect(target).to match(/\.svg/)
|
481
|
-
expect(File.exist?(target)).to be true
|
482
|
-
|
483
|
-
expect(b.option?('inline')).to be_truthy
|
484
|
-
|
485
|
-
unless formats[0] == :pdf
|
486
|
-
expect(b.attributes['width']).to_not be_nil
|
487
|
-
expect(b.attributes['height']).to_not be_nil
|
488
|
-
end
|
489
|
-
end
|
490
|
-
end
|
491
|
-
|
492
|
-
it 'should raise an error when when format is set to an invalid value' do
|
493
|
-
doc = <<-eos
|
494
|
-
= Hello, #{name}!
|
495
|
-
Doc Writer <doc@example.com>
|
496
|
-
|
497
|
-
== First Section
|
498
|
-
|
499
|
-
[#{name}, format="foobar"]
|
500
|
-
----
|
501
|
-
#{code}
|
502
|
-
----
|
503
|
-
eos
|
504
|
-
|
505
|
-
expect { load_asciidoc doc }.to raise_error(/support.*format/i)
|
506
|
-
end
|
507
|
-
|
508
|
-
it 'should not regenerate images when source has not changed' do
|
509
|
-
doc = <<-eos
|
510
|
-
= Hello, #{name}!
|
511
|
-
Doc Writer <doc@example.com>
|
512
|
-
|
513
|
-
== First Section
|
514
|
-
|
515
|
-
[#{name}]
|
516
|
-
----
|
517
|
-
#{code}
|
518
|
-
----
|
519
|
-
eos
|
520
|
-
|
521
|
-
d = load_asciidoc doc
|
522
|
-
b1 = d.find { |bl| bl.context == :image }
|
523
|
-
target1 = b1.attributes['target']
|
524
|
-
mtime1 = File.mtime(target1)
|
525
|
-
|
526
|
-
sleep 1
|
527
|
-
|
528
|
-
d = load_asciidoc doc
|
529
|
-
b2 = d.find { |bl| bl.context == :image }
|
530
|
-
target2 = b2.attributes['target']
|
531
|
-
|
532
|
-
mtime2 = File.mtime(target1)
|
533
|
-
|
534
|
-
expect(mtime2).to eq mtime1
|
535
|
-
end
|
536
|
-
|
537
|
-
it 'should write files to outdir if set' do
|
538
|
-
doc = <<-eos
|
539
|
-
= Hello, #{name}!
|
540
|
-
Doc Writer <doc@example.com>
|
541
|
-
|
542
|
-
== First Section
|
543
|
-
|
544
|
-
[#{name}]
|
545
|
-
----
|
546
|
-
#{code}
|
547
|
-
----
|
548
|
-
eos
|
549
|
-
|
550
|
-
d = load_asciidoc doc, {:attributes => {'outdir' => 'foo'}}
|
551
|
-
b = d.find { |bl| bl.context == :image }
|
552
|
-
|
553
|
-
target = b.attributes['target']
|
554
|
-
expect(target).to_not be_nil
|
555
|
-
expect(File.exist?(target)).to be false
|
556
|
-
expect(File.exist?(File.expand_path(target, 'foo'))).to be true
|
557
|
-
end
|
558
|
-
|
559
|
-
it 'should write files to to_dir if set' do
|
560
|
-
doc = <<-eos
|
561
|
-
= Hello, #{name}!
|
562
|
-
Doc Writer <doc@example.com>
|
563
|
-
|
564
|
-
== First Section
|
565
|
-
|
566
|
-
[#{name}]
|
567
|
-
----
|
568
|
-
#{code}
|
569
|
-
----
|
570
|
-
eos
|
571
|
-
|
572
|
-
d = load_asciidoc doc, {:to_dir => 'foo'}
|
573
|
-
b = d.find { |bl| bl.context == :image }
|
574
|
-
|
575
|
-
target = b.attributes['target']
|
576
|
-
expect(target).to_not be_nil
|
577
|
-
expect(File.exist?(target)).to be false
|
578
|
-
expect(File.exist?(File.expand_path(target, 'foo'))).to be true
|
579
|
-
end
|
580
|
-
|
581
|
-
it 'should write files to to_dir if set in safe mode' do
|
582
|
-
doc = <<-eos
|
583
|
-
= Hello, #{name}!
|
584
|
-
Doc Writer <doc@example.com>
|
585
|
-
|
586
|
-
== First Section
|
587
|
-
|
588
|
-
[#{name}]
|
589
|
-
----
|
590
|
-
#{code}
|
591
|
-
----
|
592
|
-
eos
|
593
|
-
|
594
|
-
to_dir = File.expand_path('foo')
|
595
|
-
d = load_asciidoc doc, {:to_dir => to_dir, :safe => :safe}
|
596
|
-
b = d.find { |bl| bl.context == :image }
|
597
|
-
|
598
|
-
target = b.attributes['target']
|
599
|
-
expect(target).to_not be_nil
|
600
|
-
expect(File.exist?(target)).to be false
|
601
|
-
expect(File.exist?(File.expand_path(target, to_dir))).to be true
|
602
|
-
end
|
603
|
-
|
604
|
-
it 'should write files to to_dir if set when embedded in table' do
|
605
|
-
doc = <<-eos
|
606
|
-
= Hello, #{name}!
|
607
|
-
Doc Writer <doc@example.com>
|
608
|
-
|
609
|
-
== First Section
|
610
|
-
|
611
|
-
|===
|
612
|
-
|Type | Example
|
613
|
-
|
614
|
-
|graphviz
|
615
|
-
a|
|
616
|
-
[#{name}]
|
617
|
-
----
|
618
|
-
#{code.gsub('|', '\|')}
|
619
|
-
----
|
620
|
-
|===
|
621
|
-
eos
|
622
|
-
|
623
|
-
d = load_asciidoc doc, {:to_dir => 'foo'}
|
624
|
-
b = d.find { |bl| bl.context == :image }
|
625
|
-
|
626
|
-
target = b.attributes['target']
|
627
|
-
expect(target).to_not be_nil
|
628
|
-
expect(File.exist?(target)).to be false
|
629
|
-
expect(File.exist?(File.expand_path(target, 'foo'))).to be true
|
630
|
-
end
|
631
|
-
|
632
|
-
it 'should write files to imagesoutdir if set' do
|
633
|
-
doc = <<-eos
|
634
|
-
= Hello, #{name}!
|
635
|
-
Doc Writer <doc@example.com>
|
636
|
-
|
637
|
-
== First Section
|
638
|
-
|
639
|
-
[#{name}]
|
640
|
-
----
|
641
|
-
#{code}
|
642
|
-
----
|
643
|
-
eos
|
644
|
-
|
645
|
-
d = load_asciidoc doc, {:attributes => {'imagesoutdir' => 'bar', 'outdir' => 'foo'}}
|
646
|
-
b = d.find { |bl| bl.context == :image }
|
647
|
-
|
648
|
-
target = b.attributes['target']
|
649
|
-
expect(target).to_not be_nil
|
650
|
-
expect(File.exist?(target)).to be false
|
651
|
-
expect(File.exist?(File.expand_path(target, 'bar'))).to be true
|
652
|
-
expect(File.exist?(File.expand_path(target, 'foo'))).to be false
|
653
|
-
end
|
654
|
-
|
655
|
-
it 'should write files to imagesoutdir if set in safe mode' do
|
656
|
-
doc = <<-eos
|
657
|
-
= Hello, #{name}!
|
658
|
-
Doc Writer <doc@example.com>
|
659
|
-
|
660
|
-
== First Section
|
661
|
-
|
662
|
-
[#{name}]
|
663
|
-
----
|
664
|
-
#{code}
|
665
|
-
----
|
666
|
-
eos
|
667
|
-
|
668
|
-
out_dir = File.expand_path('foo')
|
669
|
-
images_out_dir = File.expand_path('bar')
|
670
|
-
|
671
|
-
d = load_asciidoc doc, {:attributes => {'imagesoutdir' => images_out_dir, 'outdir' => out_dir}, :safe => :safe}
|
672
|
-
b = d.find { |bl| bl.context == :image }
|
673
|
-
|
674
|
-
target = b.attributes['target']
|
675
|
-
expect(target).to_not be_nil
|
676
|
-
expect(File.exist?(target)).to be false
|
677
|
-
expect(File.exist?(File.expand_path(target, images_out_dir))).to be true
|
678
|
-
expect(File.exist?(File.expand_path(target, out_dir))).to be false
|
679
|
-
end
|
680
|
-
|
681
|
-
it 'should omit width/height attributes when generating docbook' do
|
682
|
-
doc = <<-eos
|
683
|
-
= Hello, #{name}!
|
684
|
-
Doc Writer <doc@example.com>
|
685
|
-
|
686
|
-
== First Section
|
687
|
-
|
688
|
-
[#{name}]
|
689
|
-
----
|
690
|
-
#{code}
|
691
|
-
----
|
692
|
-
eos
|
693
|
-
|
694
|
-
d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
|
695
|
-
expect(d).to_not be_nil
|
696
|
-
|
697
|
-
b = d.find { |bl| bl.context == :image }
|
698
|
-
expect(b).to_not be_nil
|
699
|
-
|
700
|
-
target = b.attributes['target']
|
701
|
-
expect(File.exist?(target)).to be true
|
702
|
-
|
703
|
-
expect(b.attributes['width']).to be_nil
|
704
|
-
expect(b.attributes['height']).to be_nil
|
705
|
-
end
|
706
|
-
|
707
|
-
it 'should generate blocks with figure captions' do
|
708
|
-
doc = <<-eos
|
709
|
-
= Hello, #{name}!
|
710
|
-
Doc Writer <doc@example.com>
|
711
|
-
|
712
|
-
== First Section
|
713
|
-
|
714
|
-
.Caption for my diagram
|
715
|
-
[#{name}]
|
716
|
-
----
|
717
|
-
#{code}
|
718
|
-
----
|
719
|
-
eos
|
720
|
-
|
721
|
-
d = load_asciidoc doc
|
722
|
-
expect(d).to_not be_nil
|
723
|
-
|
724
|
-
b = d.find { |bl| bl.context == :image }
|
725
|
-
expect(b).to_not be_nil
|
726
|
-
|
727
|
-
expect(b.caption).to match(/Figure \d+/)
|
728
|
-
end
|
729
|
-
|
730
|
-
it 'should support scaling diagrams' do
|
731
|
-
doc = <<-eos
|
732
|
-
= Hello, #{name}!
|
733
|
-
Doc Writer <doc@example.com>
|
734
|
-
|
735
|
-
== First Section
|
736
|
-
|
737
|
-
[#{name}, target="unscaled"]
|
738
|
-
----
|
739
|
-
#{code}
|
740
|
-
----
|
741
|
-
eos
|
742
|
-
|
743
|
-
scaled_doc = <<-eos
|
744
|
-
= Hello, #{name}!
|
745
|
-
Doc Writer <doc@example.com>
|
746
|
-
|
747
|
-
== First Section
|
748
|
-
|
749
|
-
[#{name}, scale="2", target="scaled"]
|
750
|
-
----
|
751
|
-
#{code}
|
752
|
-
----
|
753
|
-
eos
|
754
|
-
|
755
|
-
d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
|
756
|
-
unscaled_image = d.find { |bl| bl.context == :image }
|
757
|
-
|
758
|
-
d = load_asciidoc scaled_doc, :attributes => {'backend' => 'html5'}
|
759
|
-
scaled_image = d.find { |bl| bl.context == :image }
|
760
|
-
|
761
|
-
unless formats[0] == :pdf
|
762
|
-
expect(scaled_image.attributes['width']).to be_within(10).of(unscaled_image.attributes['width'] * 2)
|
763
|
-
expect(scaled_image.attributes['height']).to be_within(10).of(unscaled_image.attributes['height'] * 2)
|
764
|
-
end
|
765
|
-
end
|
766
|
-
end
|