asciidoctor-diagram 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +12 -1
- data/README.adoc +74 -24
- data/README_zh-CN.adoc +4 -1
- data/lib/asciidoctor-diagram/blockdiag/extension.rb +1 -1
- data/lib/asciidoctor-diagram/extensions.rb +35 -21
- data/lib/asciidoctor-diagram/graphviz/extension.rb +2 -2
- data/lib/asciidoctor-diagram/meme/extension.rb +12 -12
- data/lib/asciidoctor-diagram/mermaid/extension.rb +24 -6
- data/lib/asciidoctor-diagram/plantuml/extension.rb +12 -12
- data/lib/asciidoctor-diagram/util/java_socket.rb +1 -12
- data/lib/asciidoctor-diagram/util/pdf.rb +10 -0
- data/lib/asciidoctor-diagram/util/platform.rb +48 -8
- data/lib/asciidoctor-diagram/util/which.rb +1 -1
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/lib/asciidoctor-diagram/wavedrom/extension.rb +2 -2
- data/lib/plantuml.jar +0 -0
- data/spec/blockdiag_spec.rb +30 -0
- data/spec/plantuml_spec.rb +35 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed682b9f1a5ebc023f78291b9cb575ab954a7c98
|
4
|
+
data.tar.gz: fb35b25a74669f7eb1540a2733b7c667ba0f2859
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29d512423d17e0cd4bb3c6f4ef21816e5716ad07e11df2059961c50a667d15a963521f6fe24b5702852d2610fededad4ab4b699aab5be52efed428e507deff6a
|
7
|
+
data.tar.gz: 21829e5be06344ea24a6a48c43968d71a8c2f51c4828acaf456b97d04f80141a2fc83cb731829dfdf7ef52682966c6b30891e5d9f823fcdc4f23558302339b95
|
data/CHANGELOG.adoc
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
= Asciidoctor-diagram Changelog
|
2
2
|
|
3
|
-
==
|
3
|
+
== 1.5.3
|
4
|
+
|
5
|
+
Enhancements::
|
6
|
+
|
7
|
+
* Issue #124: Improve compatibility with Cygwin
|
8
|
+
* Issue #133: Support substitutions in block macro target attribute
|
9
|
+
* Issue #135: Add support for PDF output for blockdiag and graphviz.
|
10
|
+
* Update PlantUML to revision 8053 (21/12/2016)
|
11
|
+
|
12
|
+
Bug Fixes::
|
13
|
+
|
14
|
+
* Resolve error when using WaveDromEditor.app on macOS
|
4
15
|
|
5
16
|
== 1.5.2
|
6
17
|
|
data/README.adoc
CHANGED
@@ -103,23 +103,23 @@ Diagram in appropriate syntax
|
|
103
103
|
|
104
104
|
The following diagram types and output formats are available:
|
105
105
|
|
106
|
-
[cols=">,
|
106
|
+
[cols=">,5*^",options="header"]
|
107
107
|
|===
|
108
|
-
|Diagram Type |gif |png |svg |txt
|
109
|
-
|{uri-actdiag}[actdiag] | |{check}|{check}|
|
110
|
-
|{uri-blockdiag}[blockdiag] | |{check}|{check}|
|
111
|
-
|{uri-ditaa}[ditaa] | |{check}| |
|
112
|
-
|{uri-erd}[erd] | |{check}|{check}|
|
113
|
-
|{uri-dot}[graphviz] | |{check}|{check}|
|
114
|
-
|<<meme,meme>> |{check}|{check}| |
|
115
|
-
|{uri-mermaid}[mermaid] | |{check}|{check}|
|
116
|
-
|{uri-nwdiag}[nwdiag] | |{check}|{check}|
|
117
|
-
|{uri-packetdiag}[packetdiag]| |{check}|{check}|
|
118
|
-
|{uri-plantuml}[plantuml] | |{check}|{check}|{check}
|
119
|
-
|{uri-rackdiag}[rackdiag] | |{check}|{check}|
|
120
|
-
|{uri-seqdiag}[seqdiag] | |{check}|{check}|
|
121
|
-
|{uri-shaape}[shaape] | |{check}|{check}|
|
122
|
-
|{uri-wavedrom}[wavedrom] | |{check}|{check}|
|
108
|
+
|Diagram Type |gif |pdf |png |svg |txt
|
109
|
+
|{uri-actdiag}[actdiag] | |{check}|{check}|{check}|
|
110
|
+
|{uri-blockdiag}[blockdiag] | |{check}|{check}|{check}|
|
111
|
+
|{uri-ditaa}[ditaa] | | |{check}| |
|
112
|
+
|{uri-erd}[erd] | | |{check}|{check}|
|
113
|
+
|{uri-dot}[graphviz] | |{check}|{check}|{check}|
|
114
|
+
|<<meme,meme>> |{check}| |{check}| |
|
115
|
+
|{uri-mermaid}[mermaid] | | |{check}|{check}|
|
116
|
+
|{uri-nwdiag}[nwdiag] | |{check}|{check}|{check}|
|
117
|
+
|{uri-packetdiag}[packetdiag]| |{check}|{check}|{check}|
|
118
|
+
|{uri-plantuml}[plantuml] | | |{check}|{check}|{check}
|
119
|
+
|{uri-rackdiag}[rackdiag] | |{check}|{check}|{check}|
|
120
|
+
|{uri-seqdiag}[seqdiag] | |{check}|{check}|{check}|
|
121
|
+
|{uri-shaape}[shaape] | | |{check}|{check}|
|
122
|
+
|{uri-wavedrom}[wavedrom] | | |{check}|{check}|
|
123
123
|
|===
|
124
124
|
|
125
125
|
The example below illustrates the structure of a basic ditaa block written directly in an AsciiDoc document.
|
@@ -309,12 +309,62 @@ The target of the block macro tells the extension which image to use as backgrou
|
|
309
309
|
The first two positional attributes are `top` and `bottom` and are used for the top and bottom label.
|
310
310
|
Occurrences of `\\` surrounded by whitespace are interpreted as line breaks.
|
311
311
|
|
312
|
-
|
312
|
+
=== Diagram Attributes
|
313
313
|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
314
|
+
Certain diagram types allow image generation to be customized using attributes.
|
315
|
+
|
316
|
+
==== Ditaa
|
317
|
+
|
318
|
+
[cols=">,<,<",options="header"]
|
319
|
+
|===
|
320
|
+
|Name |Default value |Description
|
321
|
+
|scale |1 |A scale factor that is applied to the image.
|
322
|
+
|tabs |8 |An integer value that specifies the tab size as a number of spaces.
|
323
|
+
|background |FFFFFF |The background colour of the image. The format should be a six-digit hexadecimal number (as in HTML, FF0000 for red). Pass an eight-digit hex to define transparency.
|
324
|
+
|antialias |true |Enables or disables anti-aliasing.
|
325
|
+
|separation |true |Prevents the separation of common edges of shapes.
|
326
|
+
|round-corners|false |Causes all corners to be rendered as round corners.
|
327
|
+
|shadows |true |Enables or disable drop shadows.
|
328
|
+
|debug |false |Renders the debug grid over the resulting image.
|
329
|
+
|fixed-slope |false |Makes sides of parallelograms and trapezoids fixed slope instead of fixed width.
|
330
|
+
|transparent |false |Makes the background of the image transparent instead of using the background color.
|
331
|
+
|===
|
332
|
+
|
333
|
+
==== GraphViz
|
334
|
+
|
335
|
+
[cols=">,<,<",options="header"]
|
336
|
+
|===
|
337
|
+
|Name |Default value |Description
|
338
|
+
|layout |unspecified |The graphviz layout engine to use (dot -K option).
|
339
|
+
|===
|
340
|
+
|
341
|
+
==== Meme
|
342
|
+
|
343
|
+
[cols=">,<,<",options="header"]
|
344
|
+
|===
|
345
|
+
|Name |Default value |Description
|
346
|
+
|fillColor |white |The fill color for the text.
|
347
|
+
|strokeColor |black |The outline color for the text
|
348
|
+
|strokeWidth |2 |The width of the text outline.
|
349
|
+
|font |Impact |The font face to use for the text.
|
350
|
+
|options |unspecified |a comma separate list of flags that modify the image rendering. Currently only `noupcase` is supported which disable upper casing the labels.
|
351
|
+
|===
|
352
|
+
|
353
|
+
==== Mermaid
|
354
|
+
|
355
|
+
[cols=">,<,<",options="header"]
|
356
|
+
|===
|
357
|
+
|Name |Default value |Description
|
358
|
+
|css |unspecified |Path to a CSS file to pass to mermaid.
|
359
|
+
|ganttconfig |unspecified |Path to a gantt config file to pass to mermaid.
|
360
|
+
|sequenceconfig|unspecified |Path to a sequence config file to pass to mermaid.
|
361
|
+
|width |unspecified |The width of the generated image.
|
362
|
+
|===
|
363
|
+
|
364
|
+
==== PlantUML
|
365
|
+
|
366
|
+
[cols=">,<,<",options="header"]
|
367
|
+
|===
|
368
|
+
|Name |Default value |Description
|
369
|
+
|config |unspecified |Path to a config file to pass to PlantUML.
|
370
|
+
|===
|
data/README_zh-CN.adoc
CHANGED
@@ -21,6 +21,7 @@ ifndef::env-site[:status:]
|
|
21
21
|
:uri-blockdiag: http://blockdiag.com
|
22
22
|
:uri-ditaa: http://ditaa.sourceforge.net/
|
23
23
|
:uri-dot: http://www.graphviz.org/content/dot-language
|
24
|
+
:uri-erd: https://github.com/BurntSushi/erd
|
24
25
|
:uri-graphviz: http://www.graphviz.org
|
25
26
|
:uri-imagemagick: http://www.imagemagick.org
|
26
27
|
:uri-java: http://java.sun.com
|
@@ -115,6 +116,7 @@ gem 'asciidoctor-diagram', '~> 1.4.0'
|
|
115
116
|
|{uri-actdiag}[actdiag] | |{check}|{check}|
|
116
117
|
|{uri-blockdiag}[blockdiag] | |{check}|{check}|
|
117
118
|
|{uri-ditaa}[ditaa] | |{check}| |
|
119
|
+
|{uri-erd}[erd] | |{check}|{check}|
|
118
120
|
|{uri-dot}[graphviz] | |{check}|{check}|
|
119
121
|
|<<meme,meme>> |{check}|{check}| |
|
120
122
|
|{uri-mermaid}[mermaid] | |{check}|{check}|
|
@@ -238,7 +240,7 @@ require 'asciidoctor-diagram'
|
|
238
240
|
require 'asciidoctor-diagram/<extension_name>'
|
239
241
|
----
|
240
242
|
|
241
|
-
`<extension_name>` 可以是 `blockdiag`、`ditaa`、`graphviz`、`meme`、`mermaid`、`plantuml`、`shaape` 或 `wavedrom`。
|
243
|
+
`<extension_name>` 可以是 `blockdiag`、`ditaa`、`erd`、`graphviz`、`meme`、`mermaid`、`plantuml`、`shaape` 或 `wavedrom`。
|
242
244
|
|
243
245
|
加载一个或多个这些文件将为所有需要处理的文档自动注册这些扩展。
|
244
246
|
|
@@ -289,6 +291,7 @@ Asciidoctor Diagram 依赖外部工具来生成图片。
|
|
289
291
|
|actdiag |{uri-actdiag}[ActDiag] |`actdiag`
|
290
292
|
|blockdiag |{uri-blockdiag}[BlockDiag] |`blockdiag`
|
291
293
|
|ditaa |{uri-java}[Java] |`java`
|
294
|
+
|erd |{uri-erd}[Erd] |`erd`
|
292
295
|
|graphviz |{uri-graphviz}[GraphViz] |`dot` 或 `graphvizdot`
|
293
296
|
|meme |{uri-imagemagick}[ImageMagick] |`convert` 和 `identify`
|
294
297
|
|mermaid |{uri-mermaid}[Mermaid] |`mermaid`
|
@@ -6,6 +6,7 @@ require 'fileutils'
|
|
6
6
|
require_relative 'version'
|
7
7
|
require_relative 'util/java'
|
8
8
|
require_relative 'util/gif'
|
9
|
+
require_relative 'util/pdf'
|
9
10
|
require_relative 'util/png'
|
10
11
|
require_relative 'util/svg'
|
11
12
|
|
@@ -26,7 +27,7 @@ module Asciidoctor
|
|
26
27
|
#
|
27
28
|
# Examples
|
28
29
|
#
|
29
|
-
# register_format(:png, :image ) do |
|
30
|
+
# register_format(:png, :image ) do |parent_block, source|
|
30
31
|
# File.read(source.to_s)
|
31
32
|
# end
|
32
33
|
def register_format(format, type, &block)
|
@@ -74,6 +75,10 @@ module Asciidoctor
|
|
74
75
|
:png => {
|
75
76
|
:encoding => Encoding::ASCII_8BIT,
|
76
77
|
:decoder => PNG
|
78
|
+
},
|
79
|
+
:pdf => {
|
80
|
+
:encoding => Encoding::ASCII_8BIT,
|
81
|
+
:decoder => PDF
|
77
82
|
}
|
78
83
|
}
|
79
84
|
|
@@ -133,7 +138,7 @@ module Asciidoctor
|
|
133
138
|
# Creates a DiagramSource object for the block or block macro being processed. Classes using this
|
134
139
|
# mixin must implement this method.
|
135
140
|
#
|
136
|
-
# @param
|
141
|
+
# @param parent_block [Asciidoctor::AbstractBlock] the parent asciidoc block of the block or block macro being processed
|
137
142
|
# @param reader_or_target [Asciidoctor::Reader, String] a reader that provides the contents of a block or the
|
138
143
|
# target value of a block macro
|
139
144
|
# @param attributes [Hash] the attributes of the block or block macro
|
@@ -141,7 +146,7 @@ module Asciidoctor
|
|
141
146
|
# @return [DiagramSource] an object that implements the interface described by DiagramSource
|
142
147
|
#
|
143
148
|
# @abstract
|
144
|
-
def create_source(
|
149
|
+
def create_source(parent_block, reader_or_target, attributes)
|
145
150
|
raise NotImplementedError.new
|
146
151
|
end
|
147
152
|
|
@@ -264,8 +269,8 @@ module Asciidoctor
|
|
264
269
|
# Creates a ReaderSource from the given reader.
|
265
270
|
#
|
266
271
|
# @return [ReaderSource] a ReaderSource
|
267
|
-
def create_source(
|
268
|
-
ReaderSource.new(
|
272
|
+
def create_source(parent_block, reader, attributes)
|
273
|
+
ReaderSource.new(parent_block, reader, attributes)
|
269
274
|
end
|
270
275
|
end
|
271
276
|
|
@@ -281,7 +286,8 @@ module Asciidoctor
|
|
281
286
|
#
|
282
287
|
# @return [FileSource] a FileSource
|
283
288
|
def create_source(parent, target, attributes)
|
284
|
-
|
289
|
+
target = parent.sub_attributes(target, :attribute_missing => 'warn') if target
|
290
|
+
FileSource.new(parent, target, attributes)
|
285
291
|
end
|
286
292
|
end
|
287
293
|
|
@@ -308,11 +314,12 @@ module Asciidoctor
|
|
308
314
|
#
|
309
315
|
# @param name [String, Symbol] the name of the attribute to lookup
|
310
316
|
# @param default_value [Object] the value to return if the attribute is not found
|
311
|
-
# @inherit [Boolean] indicates whether to check for the attribute on the AsciiDoctor::Document if not found on this node
|
317
|
+
# @inherit [Boolean, String] indicates whether to check for the attribute on the AsciiDoctor::Document if not found on this node.
|
318
|
+
# When a non-nil String is given the an attribute name "#{inherit}-#{name}" is looked for on the document.
|
312
319
|
#
|
313
320
|
# @return the value of the attribute or the default value if the attribute is not found in the attributes of this node or the document node
|
314
321
|
# @abstract
|
315
|
-
def attr(name, default_value = nil, inherit =
|
322
|
+
def attr(name, default_value = nil, inherit = nil)
|
316
323
|
raise NotImplementedError.new
|
317
324
|
end
|
318
325
|
|
@@ -354,8 +361,8 @@ module Asciidoctor
|
|
354
361
|
|
355
362
|
attr_reader :attributes
|
356
363
|
|
357
|
-
def initialize(
|
358
|
-
@
|
364
|
+
def initialize(parent_block, attributes)
|
365
|
+
@parent_block = parent_block
|
359
366
|
@attributes = attributes
|
360
367
|
end
|
361
368
|
|
@@ -366,11 +373,18 @@ module Asciidoctor
|
|
366
373
|
def attr(name, default_value=nil, inherit=nil)
|
367
374
|
name = name.to_s if ::Symbol === name
|
368
375
|
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
376
|
+
value = @attributes[name]
|
377
|
+
|
378
|
+
if value.nil? && inherit
|
379
|
+
case inherit
|
380
|
+
when String
|
381
|
+
value = @parent_block.attr("#{inherit}-#{name}", default_value, true)
|
382
|
+
else
|
383
|
+
value = @parent_block.attr(name, default_value, true)
|
384
|
+
end
|
373
385
|
end
|
386
|
+
|
387
|
+
value || default_value
|
374
388
|
end
|
375
389
|
|
376
390
|
def should_process?(image_file, image_metadata)
|
@@ -388,7 +402,7 @@ module Asciidoctor
|
|
388
402
|
protected
|
389
403
|
def resolve_diagram_subs
|
390
404
|
if @attributes.key? 'subs'
|
391
|
-
subs = @
|
405
|
+
subs = @parent_block.resolve_block_subs @attributes['subs'], nil, 'diagram'
|
392
406
|
subs.empty? ? nil : subs
|
393
407
|
else
|
394
408
|
nil
|
@@ -411,8 +425,8 @@ module Asciidoctor
|
|
411
425
|
class ReaderSource < BasicSource
|
412
426
|
include DiagramSource
|
413
427
|
|
414
|
-
def initialize(
|
415
|
-
super(
|
428
|
+
def initialize(parent_block, reader, attributes)
|
429
|
+
super(parent_block, attributes)
|
416
430
|
@reader = reader
|
417
431
|
end
|
418
432
|
|
@@ -421,14 +435,14 @@ module Asciidoctor
|
|
421
435
|
end
|
422
436
|
|
423
437
|
def code
|
424
|
-
@code ||= @
|
438
|
+
@code ||= @parent_block.apply_subs(@reader.lines, resolve_diagram_subs).join("\n")
|
425
439
|
end
|
426
440
|
end
|
427
441
|
|
428
442
|
# A diagram source that retrieves the code for a diagram from an external source file.
|
429
443
|
class FileSource < BasicSource
|
430
|
-
def initialize(
|
431
|
-
super(
|
444
|
+
def initialize(parent_block, file_name, attributes)
|
445
|
+
super(parent_block, attributes)
|
432
446
|
@file_name = file_name
|
433
447
|
end
|
434
448
|
|
@@ -458,7 +472,7 @@ module Asciidoctor
|
|
458
472
|
if @file_name
|
459
473
|
lines = File.readlines(@file_name)
|
460
474
|
lines = ::Asciidoctor::Helpers.normalize_lines(lines)
|
461
|
-
@
|
475
|
+
@parent_block.apply_subs(lines, resolve_diagram_subs).join("\n")
|
462
476
|
else
|
463
477
|
''
|
464
478
|
end
|
@@ -11,7 +11,7 @@ module Asciidoctor
|
|
11
11
|
include Which
|
12
12
|
|
13
13
|
def self.included(mod)
|
14
|
-
[:png, :svg].each do |f|
|
14
|
+
[:pdf, :png, :svg].each do |f|
|
15
15
|
mod.register_format(f, :image) do |parent, source|
|
16
16
|
graphviz(parent, source, f)
|
17
17
|
end
|
@@ -22,7 +22,7 @@ module Asciidoctor
|
|
22
22
|
generate_stdin(which(parent, 'dot', :alt_attrs => ['graphvizdot']), format.to_s, source.to_s) do |tool_path, output_path|
|
23
23
|
args = [tool_path, "-o#{Platform.native_path(output_path)}", "-T#{format.to_s}"]
|
24
24
|
|
25
|
-
layout = source.attr('layout')
|
25
|
+
layout = source.attr('layout', nil, 'graphviz')
|
26
26
|
args << "-K#{layout}" if layout
|
27
27
|
|
28
28
|
args
|
@@ -18,22 +18,22 @@ module Asciidoctor
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def meme(
|
22
|
-
convert = which(
|
23
|
-
identify = which(
|
21
|
+
def meme(parent_block, source, format)
|
22
|
+
convert = which(parent_block, 'convert')
|
23
|
+
identify = which(parent_block, 'identify')
|
24
24
|
|
25
|
-
bg_img =
|
25
|
+
bg_img = source.attr('background', nil, 'meme')
|
26
26
|
raise "background attribute is required" unless bg_img
|
27
27
|
|
28
|
-
bg_img =
|
28
|
+
bg_img = parent_block.normalize_system_path(bg_img, parent_block.attr('imagesdir'))
|
29
29
|
|
30
|
-
top_label =
|
31
|
-
bottom_label =
|
32
|
-
fill_color =
|
33
|
-
stroke_color =
|
34
|
-
stroke_width =
|
35
|
-
font =
|
36
|
-
options =
|
30
|
+
top_label = source.attr('top')
|
31
|
+
bottom_label = source.attr('bottom')
|
32
|
+
fill_color = source.attr('fillColor', 'white', 'meme')
|
33
|
+
stroke_color = source.attr('strokeColor', 'black', 'meme')
|
34
|
+
stroke_width = source.attr('strokeWidth', '2', 'meme')
|
35
|
+
font = source.attr('font', 'Impact', 'meme')
|
36
|
+
options = source.attr('options', '', 'meme').split(',')
|
37
37
|
noupcase = options.include?('noupcase')
|
38
38
|
|
39
39
|
dimensions = Cli.run(identify, '-format', '%w %h', bg_img).match(/(?<w>\d+) (?<h>\d+)/)
|
@@ -19,18 +19,28 @@ module Asciidoctor
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def mermaid(
|
23
|
-
mermaid = which(
|
22
|
+
def mermaid(parent_block, source, format)
|
23
|
+
mermaid = which(parent_block, 'mermaid')
|
24
24
|
@is_mermaid_v6 ||= ::Asciidoctor::Diagram::Cli.run(mermaid, '--version').split('.')[0].to_i >= 6
|
25
25
|
# Mermaid >= 6.0.0 requires PhantomJS 2.1; older version required 1.9
|
26
|
-
phantomjs = which(
|
26
|
+
phantomjs = which(parent_block, 'phantomjs', :alt_attrs => [@is_mermaid_v6 ? 'phantomjs_2' : 'phantomjs_19'])
|
27
27
|
|
28
|
-
|
28
|
+
css = source.attr('css', nil, 'mermaid')
|
29
|
+
if css
|
30
|
+
css = parent_block.normalize_system_path(css, source.base_dir)
|
31
|
+
end
|
32
|
+
|
33
|
+
gantt_config = source.attr('ganttConfig', nil, 'mermaid') || source.attr('ganttconfig', nil, 'mermaid')
|
34
|
+
if gantt_config
|
35
|
+
gantt_config = parent_block.normalize_system_path(gantt_config, source.base_dir)
|
36
|
+
end
|
37
|
+
|
38
|
+
seq_config = source.attr('sequenceConfig', nil, 'mermaid') || source.attr('sequenceconfig', nil, 'mermaid')
|
29
39
|
if seq_config
|
30
|
-
seq_config =
|
40
|
+
seq_config = parent_block.normalize_system_path(seq_config, source.base_dir)
|
31
41
|
end
|
32
42
|
|
33
|
-
width = source.attr('width')
|
43
|
+
width = source.attr('width', nil, 'mermaid')
|
34
44
|
|
35
45
|
generate_file(mermaid, 'mmd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
|
36
46
|
output_dir = File.dirname(output_path)
|
@@ -38,6 +48,14 @@ module Asciidoctor
|
|
38
48
|
|
39
49
|
args = [tool_path, '--phantomPath', Platform.native_path(phantomjs), "--#{format.to_s}", '-o', Platform.native_path(output_dir)]
|
40
50
|
|
51
|
+
if css
|
52
|
+
args << '--css' << Platform.native_path(css)
|
53
|
+
end
|
54
|
+
|
55
|
+
if gantt_config
|
56
|
+
args << '--gantt_config' << Platform.native_path(gantt_config)
|
57
|
+
end
|
58
|
+
|
41
59
|
if seq_config
|
42
60
|
args << '--sequenceConfig' << Platform.native_path(seq_config)
|
43
61
|
end
|
@@ -15,23 +15,23 @@ module Asciidoctor
|
|
15
15
|
end
|
16
16
|
Java.classpath.concat JARS
|
17
17
|
|
18
|
-
def plantuml(
|
18
|
+
def plantuml(parent_block, source, tag, mime_type)
|
19
19
|
Java.load
|
20
20
|
|
21
|
-
code = preprocess_code(
|
21
|
+
code = preprocess_code(parent_block, source, tag)
|
22
22
|
|
23
23
|
headers = {
|
24
24
|
'Accept' => mime_type
|
25
25
|
}
|
26
26
|
|
27
|
-
config_file =
|
27
|
+
config_file = source.attr('plantumlconfig', nil, true) || source.attr('config', nil, 'plantuml')
|
28
28
|
if config_file
|
29
|
-
headers['X-PlantUML-Config'] = File.expand_path(config_file,
|
29
|
+
headers['X-PlantUML-Config'] = File.expand_path(config_file, source.attr('docdir', nil, true))
|
30
30
|
end
|
31
31
|
|
32
|
-
dot = which(
|
32
|
+
dot = which(parent_block, 'dot', :alt_attrs => ['graphvizdot'], :raise_on_error => false)
|
33
33
|
if dot
|
34
|
-
headers['X-Graphviz'] = dot
|
34
|
+
headers['X-Graphviz'] = ::Asciidoctor::Diagram::Platform.host_os_path(dot)
|
35
35
|
end
|
36
36
|
|
37
37
|
response = Java.send_request(
|
@@ -78,14 +78,14 @@ module Asciidoctor
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def self.included(mod)
|
81
|
-
mod.register_format(:png, :image) do |
|
82
|
-
plantuml(
|
81
|
+
mod.register_format(:png, :image) do |parent_block, source|
|
82
|
+
plantuml(parent_block, source, mod.tag, 'image/png')
|
83
83
|
end
|
84
|
-
mod.register_format(:svg, :image) do |
|
85
|
-
plantuml(
|
84
|
+
mod.register_format(:svg, :image) do |parent_block, source|
|
85
|
+
plantuml(parent_block, source, mod.tag, 'image/svg+xml')
|
86
86
|
end
|
87
|
-
mod.register_format(:txt, :literal) do |
|
88
|
-
plantuml(
|
87
|
+
mod.register_format(:txt, :literal) do |parent_block, source|
|
88
|
+
plantuml(parent_block, source, mod.tag, 'text/plain;charset=utf-8')
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
@@ -15,18 +15,7 @@ module Asciidoctor
|
|
15
15
|
args = []
|
16
16
|
args << '-Djava.awt.headless=true'
|
17
17
|
args << '-cp'
|
18
|
-
|
19
|
-
if ::Asciidoctor::Diagram::Platform.os_variant == :cygwin
|
20
|
-
cygpath = ::Asciidoctor::Diagram::Which.which('cygpath')
|
21
|
-
if cygpath != nil
|
22
|
-
args << classpath.flatten.map { |jar| ::Asciidoctor::Diagram::Cli.run(cygpath, '-w', jar).strip }.join(";")
|
23
|
-
else
|
24
|
-
puts 'cygwin warning: cygpath not found'
|
25
|
-
args << classpath.flatten.join(File::PATH_SEPARATOR)
|
26
|
-
end
|
27
|
-
else
|
28
|
-
args << classpath.flatten.join(File::PATH_SEPARATOR)
|
29
|
-
end
|
18
|
+
args << classpath.flatten.map { |jar| ::Asciidoctor::Diagram::Platform.host_os_path(jar).strip }.join(::Asciidoctor::Diagram::Platform.host_os_path_separator)
|
30
19
|
args << 'org.asciidoctor.diagram.CommandServer'
|
31
20
|
|
32
21
|
@server = IO.popen([java, *args])
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'rbconfig'
|
2
|
+
require_relative 'cli'
|
3
|
+
require_relative 'which'
|
2
4
|
|
3
5
|
module Asciidoctor
|
4
6
|
module Diagram
|
@@ -11,24 +13,42 @@ module Asciidoctor
|
|
11
13
|
os_info[:os_variant]
|
12
14
|
end
|
13
15
|
|
16
|
+
def self.file_separator
|
17
|
+
os_info[:file_sep]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.host_os_file_separator
|
21
|
+
os_info[:host_os_file_sep]
|
22
|
+
end
|
23
|
+
|
14
24
|
def self.path_separator
|
15
25
|
os_info[:path_sep]
|
16
26
|
end
|
17
27
|
|
28
|
+
def self.host_os_path_separator
|
29
|
+
os_info[:host_os_path_sep]
|
30
|
+
end
|
31
|
+
|
18
32
|
def self.os_info
|
19
33
|
@os ||= (
|
20
34
|
host_os = RbConfig::CONFIG['host_os']
|
21
35
|
|
22
|
-
|
36
|
+
file_sep = '/'
|
37
|
+
host_os_file_sep = nil
|
23
38
|
variant = nil
|
39
|
+
path_sep = ::File::PATH_SEPARATOR
|
40
|
+
host_os_path_sep = nil
|
41
|
+
|
24
42
|
case host_os
|
25
|
-
when /(mswin|bccwin|wince|emc)/i
|
43
|
+
when /(msys|mingw|mswin|bccwin|wince|emc)/i
|
26
44
|
os = :windows
|
27
45
|
variant = $1.downcase.to_sym
|
28
|
-
|
29
|
-
when /(
|
46
|
+
file_sep = '\\'
|
47
|
+
when /(cygwin)/i
|
30
48
|
os = :windows
|
31
49
|
variant = $1.downcase.to_sym
|
50
|
+
host_os_file_sep = '\\'
|
51
|
+
host_os_path_sep = ';'
|
32
52
|
when /darwin|mac os/i
|
33
53
|
os = :macosx
|
34
54
|
when /linux/i
|
@@ -37,7 +57,12 @@ module Asciidoctor
|
|
37
57
|
os = :unix
|
38
58
|
end
|
39
59
|
{
|
40
|
-
:os => os,
|
60
|
+
:os => os,
|
61
|
+
:os_variant => variant || os,
|
62
|
+
:file_sep => file_sep,
|
63
|
+
:host_os_file_sep => host_os_file_sep || file_sep,
|
64
|
+
:path_sep => path_sep,
|
65
|
+
:host_os_path_sep => host_os_path_sep || path_sep
|
41
66
|
}
|
42
67
|
)
|
43
68
|
end
|
@@ -45,13 +70,28 @@ module Asciidoctor
|
|
45
70
|
def self.native_path(path)
|
46
71
|
return path if path.nil?
|
47
72
|
|
48
|
-
|
49
|
-
if
|
50
|
-
path.to_s.gsub('/',
|
73
|
+
sep = file_separator
|
74
|
+
if sep != '/'
|
75
|
+
path.to_s.gsub('/', sep)
|
51
76
|
else
|
52
77
|
path.to_s
|
53
78
|
end
|
54
79
|
end
|
80
|
+
|
81
|
+
def self.host_os_path(path)
|
82
|
+
# special case for cygwin, it requires path translation for java to work
|
83
|
+
if os_variant == :cygwin
|
84
|
+
cygpath = ::Asciidoctor::Diagram::Which.which('cygpath')
|
85
|
+
if cygpath != nil
|
86
|
+
::Asciidoctor::Diagram::Cli.run(cygpath, '-w', path)
|
87
|
+
else
|
88
|
+
puts 'cygwin warning: cygpath not found'
|
89
|
+
native_path(path)
|
90
|
+
end
|
91
|
+
else
|
92
|
+
native_path(path)
|
93
|
+
end
|
94
|
+
end
|
55
95
|
end
|
56
96
|
end
|
57
97
|
end
|
@@ -17,7 +17,7 @@ module Asciidoctor
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def which(parent_block, cmd, options = {})
|
20
|
-
attr_names = options.fetch(:alt_attrs, []) + [cmd]
|
20
|
+
attr_names = options[:attrs] || options.fetch(:alt_attrs, []) + [cmd]
|
21
21
|
cmd_names = [cmd] + options.fetch(:alt_cmds, [])
|
22
22
|
|
23
23
|
cmd_var = '@' + attr_names[0]
|
@@ -28,12 +28,12 @@ module Asciidoctor
|
|
28
28
|
end
|
29
29
|
else
|
30
30
|
if ::Asciidoctor::Diagram::Platform.os == :macosx
|
31
|
-
wavedrom = which(parent, 'WaveDromEditor.app', :
|
31
|
+
wavedrom = which(parent, 'WaveDromEditor.app', :attrs => ['WaveDromEditorApp'],:path => ['/Applications'])
|
32
32
|
if wavedrom
|
33
33
|
wavedrom = File.join(wavedrom, 'Contents/MacOS/nwjs')
|
34
34
|
end
|
35
35
|
else
|
36
|
-
wavedrom = which(parent, 'WaveDromEditor'
|
36
|
+
wavedrom = which(parent, 'WaveDromEditor')
|
37
37
|
end
|
38
38
|
|
39
39
|
generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
|
data/lib/plantuml.jar
CHANGED
Binary file
|
data/spec/blockdiag_spec.rb
CHANGED
@@ -99,6 +99,36 @@ Doc Writer <doc@example.com>
|
|
99
99
|
expect(b.attributes['height']).to_not be_nil
|
100
100
|
end
|
101
101
|
|
102
|
+
it "should generate PDF files when format is set to 'pdf'" do
|
103
|
+
doc = <<-eos
|
104
|
+
= Hello, BlockDiag!
|
105
|
+
Doc Writer <doc@example.com>
|
106
|
+
|
107
|
+
== First Section
|
108
|
+
|
109
|
+
[blockdiag, format="pdf"]
|
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(/\.pdf/)
|
126
|
+
expect(File.exist?(target)).to be true
|
127
|
+
|
128
|
+
expect(b.attributes['width']).to be_nil
|
129
|
+
expect(b.attributes['height']).to be_nil
|
130
|
+
end
|
131
|
+
|
102
132
|
it "should raise an error when when format is set to an invalid value" do
|
103
133
|
doc = <<-eos
|
104
134
|
= Hello, BlockDiag!
|
data/spec/plantuml_spec.rb
CHANGED
@@ -107,6 +107,41 @@ plantuml::plantuml.txt[format="svg", subs=attributes+]
|
|
107
107
|
expect(content).to include('ChildClass')
|
108
108
|
end
|
109
109
|
|
110
|
+
it 'should support substitutions in the target attribute' do
|
111
|
+
code = <<-eos
|
112
|
+
class {parent-class}
|
113
|
+
class {child-class}
|
114
|
+
{parent-class} <|-- {child-class}
|
115
|
+
eos
|
116
|
+
|
117
|
+
File.write('plantuml.txt', code)
|
118
|
+
|
119
|
+
doc = <<-eos
|
120
|
+
= Hello, PlantUML!
|
121
|
+
Doc Writer <doc@example.com>
|
122
|
+
:file: plantuml
|
123
|
+
:parent-class: ParentClass
|
124
|
+
:child-class: ChildClass
|
125
|
+
|
126
|
+
== First Section
|
127
|
+
|
128
|
+
plantuml::{file}.txt[format="svg", subs=attributes+]
|
129
|
+
eos
|
130
|
+
|
131
|
+
d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
|
132
|
+
expect(d).to_not be_nil
|
133
|
+
|
134
|
+
b = d.find { |bl| bl.context == :image }
|
135
|
+
expect(b).to_not be_nil
|
136
|
+
|
137
|
+
target = b.attributes['target']
|
138
|
+
expect(File.exist?(target)).to be true
|
139
|
+
|
140
|
+
content = File.read(target)
|
141
|
+
expect(content).to include('ParentClass')
|
142
|
+
expect(content).to include('ChildClass')
|
143
|
+
end
|
144
|
+
|
110
145
|
it 'should resolve !include directives with relative paths' do
|
111
146
|
included = <<-eos
|
112
147
|
interface List
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-diagram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pepijn Van Eeckhoudt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- lib/asciidoctor-diagram/util/java.rb
|
112
112
|
- lib/asciidoctor-diagram/util/java_jruby.rb
|
113
113
|
- lib/asciidoctor-diagram/util/java_socket.rb
|
114
|
+
- lib/asciidoctor-diagram/util/pdf.rb
|
114
115
|
- lib/asciidoctor-diagram/util/platform.rb
|
115
116
|
- lib/asciidoctor-diagram/util/png.rb
|
116
117
|
- lib/asciidoctor-diagram/util/svg.rb
|