asciidoctor-diagram 1.5.19 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.adoc +10 -0
- data/README.adoc +22 -9
- data/examples/features.adoc +2 -2
- data/lib/asciidoctor-diagram.rb +1 -0
- data/lib/asciidoctor-diagram/a2s/converter.rb +55 -0
- data/lib/asciidoctor-diagram/a2s/extension.rb +6 -52
- data/lib/asciidoctor-diagram/blockdiag/converter.rb +37 -0
- data/lib/asciidoctor-diagram/blockdiag/extension.rb +9 -116
- data/lib/asciidoctor-diagram/bpmn.rb +7 -0
- data/lib/asciidoctor-diagram/bpmn/converter.rb +62 -0
- data/lib/asciidoctor-diagram/bpmn/extension.rb +14 -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 -71
- data/lib/asciidoctor-diagram/erd/converter.rb +31 -0
- data/lib/asciidoctor-diagram/erd/extension.rb +6 -35
- data/lib/asciidoctor-diagram/gnuplot/converter.rb +63 -0
- data/lib/asciidoctor-diagram/gnuplot/extension.rb +6 -62
- data/lib/asciidoctor-diagram/graphviz/converter.rb +32 -0
- data/lib/asciidoctor-diagram/graphviz/extension.rb +6 -35
- 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 +6 -53
- data/lib/asciidoctor-diagram/meme/converter.rb +122 -0
- data/lib/asciidoctor-diagram/meme/extension.rb +5 -107
- data/lib/asciidoctor-diagram/mermaid/converter.rb +178 -0
- data/lib/asciidoctor-diagram/mermaid/extension.rb +6 -159
- data/lib/asciidoctor-diagram/msc/converter.rb +35 -0
- data/lib/asciidoctor-diagram/msc/extension.rb +6 -36
- data/lib/asciidoctor-diagram/nomnoml/converter.rb +25 -0
- data/lib/asciidoctor-diagram/nomnoml/extension.rb +6 -28
- data/lib/asciidoctor-diagram/plantuml/converter.rb +115 -0
- data/lib/asciidoctor-diagram/plantuml/extension.rb +10 -119
- data/lib/asciidoctor-diagram/shaape/converter.rb +25 -0
- data/lib/asciidoctor-diagram/shaape/extension.rb +6 -28
- data/lib/asciidoctor-diagram/smcat/converter.rb +44 -0
- data/lib/asciidoctor-diagram/smcat/extension.rb +6 -42
- data/lib/asciidoctor-diagram/svgbob/converter.rb +25 -0
- data/lib/asciidoctor-diagram/svgbob/extension.rb +6 -28
- data/lib/asciidoctor-diagram/syntrax/converter.rb +55 -0
- data/lib/asciidoctor-diagram/syntrax/extension.rb +6 -51
- data/lib/asciidoctor-diagram/tikz/converter.rb +56 -0
- data/lib/asciidoctor-diagram/tikz/extension.rb +6 -60
- data/lib/asciidoctor-diagram/umlet/converter.rb +24 -0
- data/lib/asciidoctor-diagram/umlet/extension.rb +6 -28
- data/lib/asciidoctor-diagram/util/java.rb +1 -1
- data/lib/asciidoctor-diagram/util/java_socket.rb +7 -9
- data/lib/asciidoctor-diagram/util/which.rb +0 -29
- data/lib/asciidoctor-diagram/vega/converter.rb +47 -0
- data/lib/asciidoctor-diagram/vega/extension.rb +6 -44
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/lib/asciidoctor-diagram/wavedrom/converter.rb +50 -0
- data/lib/asciidoctor-diagram/wavedrom/extension.rb +6 -54
- data/lib/ditaa-1.3.14.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/bpmn-example.xml +44 -0
- data/spec/bpmn_spec.rb +96 -0
- data/spec/mermaid_spec.rb +33 -1
- data/spec/plantuml_spec.rb +89 -0
- metadata +37 -8
- data/lib/asciidoctor-diagram/extensions.rb +0 -568
- data/lib/ditaa-1.3.13.jar +0 -0
- data/lib/plantuml-1.3.13.jar +0 -0
- data/lib/server-1.3.13.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d37e7e92d9ff0bcae6607a862a17d8d642a54ad482f896a671c698993c22ad18
|
4
|
+
data.tar.gz: 9da43fb78ccd16a79e341c662f0e6dae0fdb2edf4bd9697005f4321c8e518fe0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5366ef0c9961283fa4df0dd1b59774237dfc78923160e705d739d856f7b8dd64dc0edd4b93bc7cc139e413481dd597a384b952e52483a36a672e3f47eed30e2f
|
7
|
+
data.tar.gz: b2828d5e8987b2f27f2c1c55a0bd80eae39b7c2015c09c9899cf5ad1ce0e264cef2af7782a402225ceea81027f65ef12480a8882af90e0dd4571e98fb1571c5c
|
data/CHANGELOG.adoc
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
= Asciidoctor-diagram Changelog
|
2
2
|
|
3
|
+
== 2.0.0
|
4
|
+
|
5
|
+
Enhancements::
|
6
|
+
* Cleaned up internals of the extension
|
7
|
+
* Add support for BPMN (@gtudan)
|
8
|
+
* Update PlantUML to v1.2019.12
|
9
|
+
* #231 Improve PlantUML error reporting
|
10
|
+
* #247 Add support for document-level `diagram-svg-type` and block-level `svg-type` attributes to control SVG interactivity
|
11
|
+
* #250 Add support for Mermaid's `puppeteerConfig` option (@ldz-w)
|
12
|
+
|
3
13
|
== 1.5.19
|
4
14
|
|
5
15
|
Bug Fixes::
|
data/README.adoc
CHANGED
@@ -18,6 +18,7 @@ ifndef::env-site[:status:]
|
|
18
18
|
:uri-asciidoctor-api: http://asciidoctor.org/docs/user-manual/#api
|
19
19
|
:uri-asciidoctor-extensions: http://asciidoctor.org/docs/user-manual/#extension-points
|
20
20
|
:uri-blockdiag: http://blockdiag.com
|
21
|
+
:uri-bpmn: https://github.com/gtudan/bpmn-js-cmd
|
21
22
|
:uri-ditaa: http://ditaa.sourceforge.net/
|
22
23
|
:uri-dot: https://graphviz.gitlab.io/_pages/doc/info/lang.html
|
23
24
|
:uri-erd: https://github.com/BurntSushi/erd
|
@@ -121,6 +122,7 @@ The following diagram types and output formats are available:
|
|
121
122
|
|{uri-a2s}[a2s] | | | |{check}|
|
122
123
|
|{uri-actdiag}[actdiag] | |{check}|{check}|{check}|
|
123
124
|
|{uri-blockdiag}[blockdiag] | |{check}|{check}|{check}|
|
125
|
+
|{uri-bpmn}[bpmn] | |{check}|{check}|{check}|
|
124
126
|
|{uri-ditaa}[ditaa] | | |{check}|{check}|
|
125
127
|
|{uri-erd}[erd] | | |{check}|{check}|
|
126
128
|
|{uri-gnuplot}[gnuplot] |{check}| |{check}|{check}|{check}
|
@@ -299,6 +301,7 @@ The following table lists the tools that are required for each diagram type, the
|
|
299
301
|
|a2s |{uri-a2s}[AsciiToSvg] |`a2s`
|
300
302
|
|actdiag |{uri-actdiag}[ActDiag] |`actdiag`
|
301
303
|
|blockdiag |{uri-blockdiag}[BlockDiag] |`blockdiag`
|
304
|
+
|bpmn |{uri-bpmn}[bpmn-js-cmd] |`bpmn`
|
302
305
|
|ditaa |{uri-java}[Java] |`java`
|
303
306
|
|erd |{uri-erd}[Erd] |`erd`
|
304
307
|
|gnuplot |{uri-gnuplot}[Gnuplot] |`gnuplot`
|
@@ -383,6 +386,15 @@ The attribute name at the block level should be prefixed with the name of the di
|
|
383
386
|
|fontpath |unspecified |The path to the font that should be used by blockdiag
|
384
387
|
|===
|
385
388
|
|
389
|
+
==== BPMN
|
390
|
+
|
391
|
+
[cols=">,<,<",options="header"]
|
392
|
+
|===
|
393
|
+
|Name |Default value |Description
|
394
|
+
|height |786 |The target height of the diagram. Does not apply for output type `svg`.
|
395
|
+
|width |1024 |The target width of the diagram. Does not apply for output type `svg`.
|
396
|
+
|===
|
397
|
+
|
386
398
|
==== Ditaa
|
387
399
|
|
388
400
|
[cols=">,<,<",options="header"]
|
@@ -438,15 +450,16 @@ The attribute name at the block level should be prefixed with the name of the di
|
|
438
450
|
|
439
451
|
[cols=">,<,<",options="header"]
|
440
452
|
|===
|
441
|
-
|Name
|
442
|
-
|background
|
443
|
-
|css
|
444
|
-
|config
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
453
|
+
|Name |Default value |Description
|
454
|
+
|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.
|
455
|
+
|css |unspecified |Path to a CSS file to pass to mermaid.
|
456
|
+
|config |unspecified |Path to a JSON config file to pass to mermaid.
|
457
|
+
|ganttConfig |unspecified |Path to a gantt config file to pass to mermaid.
|
458
|
+
|puppeteerConfig |unspecified |Path to a puppeteer config file to pass to mermaid.
|
459
|
+
|sequenceConfig |unspecified |Path to a sequence config file to pass to mermaid.
|
460
|
+
|theme |unspecified |Theme of the chart, could be default, forest, dark or neutral.
|
461
|
+
|width |unspecified |Width of the page.
|
462
|
+
|height |unspecified |Height of the page.
|
450
463
|
|===
|
451
464
|
|
452
465
|
==== Msc
|
data/examples/features.adoc
CHANGED
@@ -160,5 +160,5 @@ Instead the name of the generated image is derived from the target propery of th
|
|
160
160
|
The previous example in block macro form would look something like this with the text from the block located in a file called `activity_diagram.txt` instead of inline in the document.
|
161
161
|
|
162
162
|
----
|
163
|
-
plantuml
|
164
|
-
----
|
163
|
+
plantuml::activity_diagram.txt[format="svg", align="center"]
|
164
|
+
----
|
data/lib/asciidoctor-diagram.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative 'asciidoctor-diagram/a2s'
|
2
2
|
require_relative 'asciidoctor-diagram/blockdiag'
|
3
|
+
require_relative 'asciidoctor-diagram/bpmn'
|
3
4
|
require_relative 'asciidoctor-diagram/ditaa'
|
4
5
|
require_relative 'asciidoctor-diagram/erd'
|
5
6
|
require_relative 'asciidoctor-diagram/gnuplot'
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative '../diagram_converter'
|
2
|
+
require_relative '../util/cli_generator'
|
3
|
+
require_relative '../util/platform'
|
4
|
+
|
5
|
+
module Asciidoctor
|
6
|
+
module Diagram
|
7
|
+
# @private
|
8
|
+
class AsciiToSvgConverter
|
9
|
+
include DiagramConverter
|
10
|
+
include CliGenerator
|
11
|
+
|
12
|
+
def supported_formats
|
13
|
+
[:svg]
|
14
|
+
end
|
15
|
+
|
16
|
+
def collect_options(source, name)
|
17
|
+
options = {}
|
18
|
+
options[:sx] = source.attr('scalex', nil, name)
|
19
|
+
options[:sy] = source.attr('scaley', nil, name)
|
20
|
+
options[:scale] = source.attr('scale', nil, name)
|
21
|
+
options[:noblur] = source.attr('noblur', nil, name) == 'true'
|
22
|
+
options[:font] = source.attr('fontfamily', nil, name)
|
23
|
+
options
|
24
|
+
end
|
25
|
+
|
26
|
+
def convert(source, format, options)
|
27
|
+
sx = options[:sx]
|
28
|
+
sy = options[:sy]
|
29
|
+
scale = options[:scale]
|
30
|
+
noblur = options[:noblur]
|
31
|
+
font = options[:font]
|
32
|
+
|
33
|
+
generate_stdin(source.find_command('a2s'), format.to_s, source.to_s) do |tool_path, output_path|
|
34
|
+
args = [tool_path, '-o', Platform.native_path(output_path)]
|
35
|
+
|
36
|
+
if sx && sy
|
37
|
+
args << '-s' << "#{sx},#{sy}"
|
38
|
+
elsif scale
|
39
|
+
args << '-s' << "#{scale},#{scale}"
|
40
|
+
end
|
41
|
+
|
42
|
+
if noblur
|
43
|
+
args << '-b'
|
44
|
+
end
|
45
|
+
|
46
|
+
if font
|
47
|
+
args << '-f' << font
|
48
|
+
end
|
49
|
+
|
50
|
+
args
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,60 +1,14 @@
|
|
1
|
-
require_relative '
|
2
|
-
require_relative '../
|
3
|
-
require_relative '../util/platform'
|
4
|
-
require_relative '../util/which'
|
1
|
+
require_relative 'converter'
|
2
|
+
require_relative '../diagram_processor'
|
5
3
|
|
6
4
|
module Asciidoctor
|
7
5
|
module Diagram
|
8
|
-
|
9
|
-
|
10
|
-
include CliGenerator
|
11
|
-
include Which
|
12
|
-
|
13
|
-
def self.included(mod)
|
14
|
-
[:svg].each do |f|
|
15
|
-
mod.register_format(f, :image) do |parent, source|
|
16
|
-
a2s(parent, source, f)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def a2s(parent, source, format)
|
22
|
-
inherit_prefix = name
|
23
|
-
|
24
|
-
sx = source.attr('scalex', nil, inherit_prefix)
|
25
|
-
sy = source.attr('scaley', nil, inherit_prefix)
|
26
|
-
scale = source.attr('scale', nil, inherit_prefix)
|
27
|
-
noblur = source.attr('noblur', 'false', inherit_prefix) == 'true'
|
28
|
-
font = source.attr('fontfamily', nil, inherit_prefix)
|
29
|
-
|
30
|
-
generate_stdin(which(parent, 'a2s'), format.to_s, source.to_s) do |tool_path, output_path|
|
31
|
-
args = [tool_path, '-o', Platform.native_path(output_path)]
|
32
|
-
|
33
|
-
if sx && sy
|
34
|
-
args << '-s' << "#{sx},#{sy}"
|
35
|
-
elsif scale
|
36
|
-
args << '-s' << "#{scale},#{scale}"
|
37
|
-
end
|
38
|
-
|
39
|
-
if noblur
|
40
|
-
args << '-b'
|
41
|
-
end
|
42
|
-
|
43
|
-
if font
|
44
|
-
args << '-f' << font
|
45
|
-
end
|
46
|
-
|
47
|
-
args
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
class AsciiToSvgBlockProcessor < Extensions::DiagramBlockProcessor
|
53
|
-
include AsciiToSvg
|
6
|
+
class AsciiToSvgBlockProcessor < DiagramBlockProcessor
|
7
|
+
use_converter AsciiToSvgConverter
|
54
8
|
end
|
55
9
|
|
56
|
-
class AsciiToSvgBlockMacroProcessor <
|
57
|
-
|
10
|
+
class AsciiToSvgBlockMacroProcessor < DiagramBlockMacroProcessor
|
11
|
+
use_converter AsciiToSvgConverter
|
58
12
|
end
|
59
13
|
end
|
60
14
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative '../diagram_converter'
|
2
|
+
require_relative '../util/cli_generator'
|
3
|
+
require_relative '../util/platform'
|
4
|
+
|
5
|
+
module Asciidoctor
|
6
|
+
module Diagram
|
7
|
+
['BlockDiag', 'SeqDiag', 'ActDiag', 'NwDiag', 'RackDiag', 'PacketDiag'].each do |name|
|
8
|
+
converter = Class.new do
|
9
|
+
include DiagramConverter
|
10
|
+
include CliGenerator
|
11
|
+
|
12
|
+
def supported_formats
|
13
|
+
[:png, :pdf, :svg]
|
14
|
+
end
|
15
|
+
|
16
|
+
def convert(source, format, options)
|
17
|
+
# On Debian based systems the Python 3.x packages python3-(act|block|nw|seq)diag executables with
|
18
|
+
# a '3' suffix.
|
19
|
+
cmd_name = self.class.const_get(:TOOL)
|
20
|
+
alt_cmd_name = "#{cmd_name}3"
|
21
|
+
|
22
|
+
font_path = source.attr('fontpath', nil, cmd_name)
|
23
|
+
|
24
|
+
generate_stdin(source.find_command(cmd_name, :alt_cmds => [alt_cmd_name]), format.to_s, source.to_s) do |tool_path, output_path|
|
25
|
+
args = [tool_path, '-a', '-o', Platform.native_path(output_path), "-T#{format.to_s}"]
|
26
|
+
args << "-f#{Platform.native_path(font_path)}" if font_path
|
27
|
+
args << '-'
|
28
|
+
args
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
converter.const_set(:TOOL, name.downcase)
|
33
|
+
|
34
|
+
::Asciidoctor::Diagram.const_set("#{name}Converter", converter)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,125 +1,18 @@
|
|
1
|
-
require_relative '../
|
2
|
-
require_relative '
|
3
|
-
require_relative '../util/platform'
|
4
|
-
require_relative '../util/which'
|
1
|
+
require_relative '../diagram_processor'
|
2
|
+
require_relative 'converter'
|
5
3
|
|
6
4
|
module Asciidoctor
|
7
5
|
module Diagram
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# # Supports PNG and SVG output.
|
12
|
-
# class BlockDiagBlockProcessor < API::DiagramBlockProcessor; end
|
13
|
-
#
|
14
|
-
# # Block macro processor converts blockdiag source files into images.
|
15
|
-
# #
|
16
|
-
# # Supports PNG and SVG output.
|
17
|
-
# class BlockDiagBlockMacroProcessor < DiagramBlockMacroProcessor; end
|
18
|
-
|
19
|
-
# @!parse
|
20
|
-
# # Block processor converts seqdiag code into images.
|
21
|
-
# #
|
22
|
-
# # Supports PNG and SVG output.
|
23
|
-
# class SeqDiagBlockProcessor < API::DiagramBlockProcessor; end
|
24
|
-
#
|
25
|
-
# # Block macro processor converts seqdiag source files into images.
|
26
|
-
# #
|
27
|
-
# # Supports PNG and SVG output.
|
28
|
-
# class SeqDiagBlockMacroProcessor < API::DiagramBlockMacroProcessor; end
|
29
|
-
|
30
|
-
# @!parse
|
31
|
-
# # Block processor converts actdiag code into images.
|
32
|
-
# #
|
33
|
-
# # Supports PNG and SVG output.
|
34
|
-
# class ActDiagBlockProcessor < API::DiagramBlockProcessor; end
|
35
|
-
#
|
36
|
-
# # Block macro processor converts actdiag source files into images.
|
37
|
-
# #
|
38
|
-
# # Supports PNG and SVG output.
|
39
|
-
# class ActDiagBlockMacroProcessor < API::DiagramBlockMacroProcessor; end
|
40
|
-
|
41
|
-
# @!parse
|
42
|
-
# # Block processor converts nwdiag code into images.
|
43
|
-
# #
|
44
|
-
# # Supports PNG and SVG output.
|
45
|
-
# class NwDiagBlockProcessor < API::DiagramBlockProcessor; end
|
46
|
-
#
|
47
|
-
# # Block macro processor converts nwdiag source files into images.
|
48
|
-
# #
|
49
|
-
# # Supports PNG and SVG output.
|
50
|
-
# class NwDiagBlockMacroProcessor < API::DiagramBlockMacroProcessor; end
|
51
|
-
|
52
|
-
# @!parse
|
53
|
-
# # Block processor converts rackdiag code into images.
|
54
|
-
# #
|
55
|
-
# # Supports PNG and SVG output.
|
56
|
-
# class RackDiagBlockProcessor < API::DiagramBlockProcessor; end
|
57
|
-
#
|
58
|
-
# # Block macro processor converts rackdiag source files into images.
|
59
|
-
# #
|
60
|
-
# # Supports PNG and SVG output.
|
61
|
-
# class RackDiagBlockMacroProcessor < API::DiagramBlockMacroProcessor; end
|
62
|
-
|
63
|
-
# @!parse
|
64
|
-
# # Block processor converts packetdiag code into images.
|
65
|
-
# #
|
66
|
-
# # Supports PNG and SVG output.
|
67
|
-
# class PacketDiagBlockProcessor < API::DiagramBlockProcessor; end
|
68
|
-
#
|
69
|
-
# # Block macro processor converts packetdiag source files into images.
|
70
|
-
# #
|
71
|
-
# # Supports PNG and SVG output.
|
72
|
-
# class PacketDiagBlockMacroProcessor < API::DiagramBlockMacroProcessor; end
|
73
|
-
|
74
|
-
# @private
|
75
|
-
module BlockDiag
|
76
|
-
def self.define_processors(name)
|
77
|
-
init = Proc.new do
|
78
|
-
include ::Asciidoctor::Diagram::BlockDiag
|
79
|
-
|
80
|
-
[:png, :pdf, :svg].each do |f|
|
81
|
-
register_format(f, :image) do |p, c|
|
82
|
-
blockdiag(name, p, c, f)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
block = Class.new(Extensions::DiagramBlockProcessor) do
|
88
|
-
self.instance_eval(&init)
|
89
|
-
end
|
90
|
-
::Asciidoctor::Diagram.const_set("#{name}BlockProcessor", block)
|
91
|
-
|
92
|
-
block_macro = Class.new(Extensions::DiagramBlockMacroProcessor) do
|
93
|
-
self.instance_eval(&init)
|
94
|
-
end
|
95
|
-
|
96
|
-
::Asciidoctor::Diagram.const_set("#{name}BlockMacroProcessor", block_macro)
|
6
|
+
['BlockDiag', 'SeqDiag', 'ActDiag', 'NwDiag', 'RackDiag', 'PacketDiag'].each do |tool|
|
7
|
+
block = Class.new(DiagramBlockProcessor) do
|
8
|
+
use_converter ::Asciidoctor::Diagram.const_get("#{tool}Converter")
|
97
9
|
end
|
10
|
+
::Asciidoctor::Diagram.const_set("#{tool}BlockProcessor", block)
|
98
11
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
def blockdiag(tool, parent, source, format)
|
103
|
-
inherit_prefix = name
|
104
|
-
cmd_name = tool.downcase
|
105
|
-
|
106
|
-
# On Debian based systems the Python 3.x packages python3-(act|block|nw|seq)diag executables with
|
107
|
-
# a '3' suffix.
|
108
|
-
alt_cmd_name = "#{tool.downcase}3"
|
109
|
-
|
110
|
-
font_path = source.attr('fontpath', nil, inherit_prefix)
|
111
|
-
|
112
|
-
generate_stdin(which(parent, cmd_name, :alt_cmds => [alt_cmd_name]), format.to_s, source.to_s) do |tool_path, output_path|
|
113
|
-
args = [tool_path, '-a', '-o', Platform.native_path(output_path), "-T#{format.to_s}"]
|
114
|
-
args << "-f#{Platform.native_path(font_path)}" if font_path
|
115
|
-
args << '-'
|
116
|
-
args
|
117
|
-
end
|
12
|
+
block_macro = Class.new(DiagramBlockMacroProcessor) do
|
13
|
+
use_converter ::Asciidoctor::Diagram.const_get("#{tool}Converter")
|
118
14
|
end
|
119
|
-
|
120
|
-
|
121
|
-
['BlockDiag', 'SeqDiag', 'ActDiag', 'NwDiag', 'RackDiag', 'PacketDiag'].each do |tool|
|
122
|
-
BlockDiag.define_processors(tool)
|
15
|
+
::Asciidoctor::Diagram.const_set("#{tool}BlockMacroProcessor", block_macro)
|
123
16
|
end
|
124
17
|
end
|
125
18
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative '../diagram_converter'
|
2
|
+
require_relative '../util/cli'
|
3
|
+
require_relative '../util/cli_generator'
|
4
|
+
require_relative '../util/platform'
|
5
|
+
|
6
|
+
module Asciidoctor
|
7
|
+
module Diagram
|
8
|
+
# @private
|
9
|
+
class BpmnConverter
|
10
|
+
include DiagramConverter
|
11
|
+
include CliGenerator
|
12
|
+
|
13
|
+
|
14
|
+
def supported_formats
|
15
|
+
[:png, :svg, :pdf, :jpeg]
|
16
|
+
end
|
17
|
+
|
18
|
+
def collect_options(source, name)
|
19
|
+
options = {}
|
20
|
+
|
21
|
+
options[:width] = source.attr('width', nil, name)
|
22
|
+
options[:height] = source.attr('height', nil, name)
|
23
|
+
|
24
|
+
options
|
25
|
+
end
|
26
|
+
|
27
|
+
def convert(source, format, options)
|
28
|
+
opts = {}
|
29
|
+
|
30
|
+
opts[:width] = options[:width]
|
31
|
+
|
32
|
+
bpmnjs = source.find_command('bpmn-js', :raise_on_error => false)
|
33
|
+
opts[:height] = options[:height]
|
34
|
+
opts[:theme] = options[:theme]
|
35
|
+
config = options[:config]
|
36
|
+
if config
|
37
|
+
opts[:config] = source.resolve_path(config)
|
38
|
+
end
|
39
|
+
run_bpmnjs(bpmnjs, source, format, opts)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def run_bpmnjs(bpmnjs, source, format, options = {})
|
45
|
+
generate_file(bpmnjs, 'bpmn', format.to_s, source.to_s) do |tool_path, input_path, output_path|
|
46
|
+
args = [tool_path, Platform.native_path(input_path), '-o', Platform.native_path(output_path), '-t', format.to_s]
|
47
|
+
|
48
|
+
|
49
|
+
if options[:width]
|
50
|
+
args << '--width' << options[:width]
|
51
|
+
end
|
52
|
+
|
53
|
+
if options[:height]
|
54
|
+
args << '--height' << options[:height]
|
55
|
+
end
|
56
|
+
|
57
|
+
args
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|