asciidoctor-diagram 2.2.7 → 2.2.9
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 +4 -4
- data/CHANGELOG.adoc +20 -0
- data/README.adoc +3 -3
- data/docs/modules/ROOT/pages/index.adoc +1 -1
- data/docs/modules/ROOT/partials/advanced.adoc +19 -4
- data/docs/modules/ROOT/partials/create_diagram.adoc +1 -0
- data/docs/modules/ROOT/partials/uris.adoc +3 -1
- data/lib/asciidoctor-diagram/d2/converter.rb +12 -4
- data/lib/asciidoctor-diagram/dbml/converter.rb +22 -0
- data/lib/asciidoctor-diagram/dbml/extension.rb +18 -0
- data/lib/asciidoctor-diagram/dbml.rb +8 -0
- data/lib/asciidoctor-diagram/diagram_processor.rb +8 -0
- data/lib/asciidoctor-diagram/diagram_source.rb +10 -2
- data/lib/asciidoctor-diagram/ditaa/converter.rb +9 -3
- data/lib/asciidoctor-diagram/ditaa/ditaa-2.0.0.jar +0 -0
- data/lib/asciidoctor-diagram/plantuml/converter.rb +8 -3
- data/lib/asciidoctor-diagram/plantuml/plantuml-2.0.0.jar +0 -0
- data/lib/asciidoctor-diagram/structurizr/converter.rb +67 -0
- data/lib/asciidoctor-diagram/structurizr/extension.rb +52 -0
- data/lib/asciidoctor-diagram/structurizr/renderers.rb +58 -0
- data/lib/asciidoctor-diagram/structurizr/structurizr-2.0.1.jar +0 -0
- data/lib/asciidoctor-diagram/structurizr.rb +7 -0
- data/lib/asciidoctor-diagram/syntrax/converter.rb +64 -17
- data/lib/asciidoctor-diagram/syntrax/syntrax-2.0.2.jar +0 -0
- data/lib/asciidoctor-diagram/util/cli.rb +10 -2
- data/lib/asciidoctor-diagram/util/cli_generator.rb +1 -0
- data/lib/asciidoctor-diagram/util/server-2.0.0.jar +0 -0
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/lib/asciidoctor-diagram.rb +2 -0
- data/spec/a2s_spec.rb +1 -1
- data/spec/barcode_spec.rb +1 -1
- data/spec/blockdiag_spec.rb +1 -1
- data/spec/bpmn_spec.rb +1 -1
- data/spec/bytefield_spec.rb +1 -1
- data/spec/d2_spec.rb +51 -1
- data/spec/dbml_spec.rb +32 -0
- data/spec/diagrams_spec.rb +1 -1
- data/spec/ditaa_spec.rb +1 -1
- data/spec/dpic_spec.rb +1 -1
- data/spec/erd_spec.rb +1 -1
- data/spec/gnuplot_spec.rb +1 -1
- data/spec/graphviz_py_spec.rb +1 -1
- data/spec/graphviz_spec.rb +1 -1
- data/spec/lilypond_spec.rb +1 -1
- data/spec/meme_spec.rb +1 -1
- data/spec/mermaid_spec.rb +1 -1
- data/spec/msc_spec.rb +1 -1
- data/spec/nomnoml_spec.rb +1 -1
- data/spec/pikchr_spec.rb +1 -1
- data/spec/plantuml_spec.rb +2 -2
- data/spec/shaape_spec.rb +1 -1
- data/spec/shared_examples.rb +5 -3
- data/spec/smcat_spec.rb +1 -1
- data/spec/structurizr_spec.rb +41 -0
- data/spec/svgbob_spec.rb +1 -1
- data/spec/symbolator_spec.rb +1 -1
- data/spec/syntrax_spec.rb +1 -1
- data/spec/{test_helper.rb → test_helper_methods.rb} +2 -0
- data/spec/tikz_spec.rb +1 -1
- data/spec/umlet_spec.rb +1 -1
- data/spec/vega_spec.rb +1 -1
- data/spec/wavedrom_spec.rb +1 -1
- metadata +27 -9
- data/lib/asciidoctor-diagram/ditaa/ditaa-1.3.21.jar +0 -0
- data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.24.jar +0 -0
- data/lib/asciidoctor-diagram/util/server-1.3.21.jar +0 -0
@@ -9,6 +9,21 @@ module Asciidoctor
|
|
9
9
|
include DiagramConverter
|
10
10
|
include CliGenerator
|
11
11
|
|
12
|
+
CLASSPATH_ENV = 'DIAGRAM_JSYNTRAX_CLASSPATH'
|
13
|
+
CLI_HOME_ENV = 'DIAGRAM_JSYNTRAX_HOME'
|
14
|
+
JSYNTRAX_JARS = if ENV.has_key?(CLASSPATH_ENV)
|
15
|
+
ENV[CLASSPATH_ENV].split(File::PATH_SEPARATOR)
|
16
|
+
elsif ENV.has_key?(CLI_HOME_ENV)
|
17
|
+
lib_dir = File.expand_path('lib', ENV[CLI_HOME_ENV])
|
18
|
+
Dir.children(lib_dir).select { |c| c.end_with? '.jar' }.map { |c| File.expand_path(c, lib_dir) }
|
19
|
+
else
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
|
23
|
+
if JSYNTRAX_JARS
|
24
|
+
Java.classpath.concat Dir[File.join(File.dirname(__FILE__), '*.jar')]
|
25
|
+
Java.classpath.concat JSYNTRAX_JARS
|
26
|
+
end
|
12
27
|
|
13
28
|
def supported_formats
|
14
29
|
[:png, :svg]
|
@@ -24,30 +39,62 @@ module Asciidoctor
|
|
24
39
|
end
|
25
40
|
|
26
41
|
def convert(source, format, options)
|
27
|
-
|
28
|
-
|
42
|
+
shared_args = []
|
43
|
+
title = options[:heading]
|
44
|
+
if title
|
45
|
+
shared_args << '--title' << title
|
46
|
+
end
|
29
47
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
48
|
+
scale = options[:scale]
|
49
|
+
if scale
|
50
|
+
shared_args << '--scale' << scale
|
51
|
+
end
|
34
52
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
53
|
+
transparent = options[:transparent]
|
54
|
+
if transparent == 'true'
|
55
|
+
shared_args << '--transparent'
|
56
|
+
end
|
57
|
+
style = options[:style]
|
58
|
+
if style
|
59
|
+
shared_args << '--style' << style
|
60
|
+
end
|
39
61
|
|
40
|
-
|
41
|
-
|
42
|
-
|
62
|
+
if JSYNTRAX_JARS
|
63
|
+
Java.load
|
64
|
+
|
65
|
+
options_string = shared_args.join(' ')
|
66
|
+
|
67
|
+
case format
|
68
|
+
when :png
|
69
|
+
mime_type = 'image/png'
|
70
|
+
when :svg
|
71
|
+
mime_type = 'image/svg+xml'
|
72
|
+
else
|
73
|
+
raise "Unsupported format: #{format}"
|
43
74
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
75
|
+
|
76
|
+
headers = {
|
77
|
+
'Accept' => mime_type,
|
78
|
+
'X-Options' => options_string
|
79
|
+
}
|
80
|
+
|
81
|
+
response = Java.send_request(
|
82
|
+
:url => '/syntrax',
|
83
|
+
:body => source.to_s,
|
84
|
+
:headers => headers
|
85
|
+
)
|
86
|
+
|
87
|
+
unless response[:code] == 200
|
88
|
+
raise Java.create_error("JSyntrax code generation failed", response)
|
47
89
|
end
|
48
90
|
|
49
|
-
|
91
|
+
response[:body]
|
92
|
+
else
|
93
|
+
generate_file(source.find_command('syntrax'), 'spec', format.to_s, source.to_s) do |tool_path, input_path, output_path|
|
94
|
+
[tool_path, '-i', Platform.native_path(input_path), '-o', Platform.native_path(output_path)] + shared_args
|
95
|
+
end
|
50
96
|
end
|
97
|
+
|
51
98
|
end
|
52
99
|
|
53
100
|
def native_scaling?
|
Binary file
|
@@ -9,8 +9,13 @@ module Asciidoctor
|
|
9
9
|
require_relative 'java'
|
10
10
|
|
11
11
|
def self.run(*args)
|
12
|
-
|
13
|
-
|
12
|
+
if args.last.is_a? Hash
|
13
|
+
opts = args.pop.dup
|
14
|
+
else
|
15
|
+
opts = {}
|
16
|
+
end
|
17
|
+
|
18
|
+
in_data = opts[:stdin_data]
|
14
19
|
|
15
20
|
if Hash === args.first
|
16
21
|
env = args.shift.dup
|
@@ -19,6 +24,9 @@ module Asciidoctor
|
|
19
24
|
end
|
20
25
|
|
21
26
|
pb = java.lang.ProcessBuilder.new(*args)
|
27
|
+
|
28
|
+
pb.directory(java.io.File.new(opts[:chdir] || Dir.pwd))
|
29
|
+
|
22
30
|
env.each_pair do |key, value|
|
23
31
|
pb.environment.put(key, value)
|
24
32
|
end
|
Binary file
|
data/lib/asciidoctor-diagram.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative 'asciidoctor-diagram/blockdiag'
|
|
4
4
|
require_relative 'asciidoctor-diagram/bpmn'
|
5
5
|
require_relative 'asciidoctor-diagram/bytefield'
|
6
6
|
require_relative 'asciidoctor-diagram/d2'
|
7
|
+
require_relative 'asciidoctor-diagram/dbml'
|
7
8
|
require_relative 'asciidoctor-diagram/diagrams'
|
8
9
|
require_relative 'asciidoctor-diagram/ditaa'
|
9
10
|
require_relative 'asciidoctor-diagram/dpic'
|
@@ -21,6 +22,7 @@ require_relative 'asciidoctor-diagram/plantuml'
|
|
21
22
|
require_relative 'asciidoctor-diagram/salt'
|
22
23
|
require_relative 'asciidoctor-diagram/shaape'
|
23
24
|
require_relative 'asciidoctor-diagram/smcat'
|
25
|
+
require_relative 'asciidoctor-diagram/structurizr'
|
24
26
|
require_relative 'asciidoctor-diagram/svgbob'
|
25
27
|
require_relative 'asciidoctor-diagram/symbolator'
|
26
28
|
require_relative 'asciidoctor-diagram/syntrax'
|
data/spec/a2s_spec.rb
CHANGED
data/spec/barcode_spec.rb
CHANGED
data/spec/blockdiag_spec.rb
CHANGED
data/spec/bpmn_spec.rb
CHANGED
data/spec/bytefield_spec.rb
CHANGED
data/spec/d2_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'test_helper_methods'
|
2
2
|
|
3
3
|
D2_CODE = <<-eos
|
4
4
|
# Actors
|
@@ -34,4 +34,54 @@ end
|
|
34
34
|
|
35
35
|
describe Asciidoctor::Diagram::D2BlockProcessor, :broken_on_windows do
|
36
36
|
include_examples "block", :d2, D2_CODE, [:svg]
|
37
|
+
|
38
|
+
it "should not use sketch mode by default" do
|
39
|
+
doc = <<-eos
|
40
|
+
= Hello, D2!
|
41
|
+
Doc Writer <doc@example.com>
|
42
|
+
|
43
|
+
== First Section
|
44
|
+
|
45
|
+
[d2]
|
46
|
+
----
|
47
|
+
#{D2_CODE}
|
48
|
+
----
|
49
|
+
eos
|
50
|
+
|
51
|
+
d = load_asciidoc doc
|
52
|
+
expect(d).to_not be_nil
|
53
|
+
|
54
|
+
b = d.find { |bl| bl.context == :image }
|
55
|
+
expect(b).to_not be_nil
|
56
|
+
target = b.attributes['target']
|
57
|
+
expect(target).to match(/\.svg$/)
|
58
|
+
expect(File.exist?(target)).to be true
|
59
|
+
svg = File.read(target, :encoding => Encoding::UTF_8)
|
60
|
+
expect(svg).to_not match(/class='.*?sketch-overlay-B5.*?'/)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should support sketch mode" do
|
64
|
+
doc = <<-eos
|
65
|
+
= Hello, D2!
|
66
|
+
Doc Writer <doc@example.com>
|
67
|
+
|
68
|
+
== First Section
|
69
|
+
|
70
|
+
[d2, foobar, svg, sketch]
|
71
|
+
----
|
72
|
+
#{D2_CODE}
|
73
|
+
----
|
74
|
+
eos
|
75
|
+
|
76
|
+
d = load_asciidoc doc
|
77
|
+
expect(d).to_not be_nil
|
78
|
+
|
79
|
+
b = d.find { |bl| bl.context == :image }
|
80
|
+
expect(b).to_not be_nil
|
81
|
+
target = b.attributes['target']
|
82
|
+
expect(target).to match(/\.svg$/)
|
83
|
+
expect(File.exist?(target)).to be true
|
84
|
+
svg = File.read(target, :encoding => Encoding::UTF_8)
|
85
|
+
expect(svg).to match(/class='.*?sketch-overlay-B5.*?'/)
|
86
|
+
end
|
37
87
|
end
|
data/spec/dbml_spec.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'test_helper_methods'
|
2
|
+
|
3
|
+
DBML_CODE = <<-eos
|
4
|
+
Table users {
|
5
|
+
id integer
|
6
|
+
username varchar
|
7
|
+
role varchar
|
8
|
+
created_at timestamp
|
9
|
+
}
|
10
|
+
|
11
|
+
Table posts {
|
12
|
+
id integer [primary key]
|
13
|
+
title varchar
|
14
|
+
body text [note: 'Content of the post']
|
15
|
+
user_id integer
|
16
|
+
created_at timestamp
|
17
|
+
}
|
18
|
+
|
19
|
+
Ref: posts.user_id > users.id
|
20
|
+
eos
|
21
|
+
|
22
|
+
describe Asciidoctor::Diagram::DbmlInlineMacroProcessor, :broken_on_windows do
|
23
|
+
include_examples "inline_macro", :dbml, DBML_CODE, [:svg]
|
24
|
+
end
|
25
|
+
|
26
|
+
describe Asciidoctor::Diagram::DbmlBlockMacroProcessor, :broken_on_windows do
|
27
|
+
include_examples "block_macro", :dbml, DBML_CODE, [:svg]
|
28
|
+
end
|
29
|
+
|
30
|
+
describe Asciidoctor::Diagram::DbmlBlockProcessor, :broken_on_windows do
|
31
|
+
include_examples "block", :dbml, DBML_CODE, [:svg]
|
32
|
+
end
|
data/spec/diagrams_spec.rb
CHANGED
data/spec/ditaa_spec.rb
CHANGED
data/spec/dpic_spec.rb
CHANGED
data/spec/erd_spec.rb
CHANGED
data/spec/gnuplot_spec.rb
CHANGED
data/spec/graphviz_py_spec.rb
CHANGED
data/spec/graphviz_spec.rb
CHANGED
data/spec/lilypond_spec.rb
CHANGED
data/spec/meme_spec.rb
CHANGED
data/spec/mermaid_spec.rb
CHANGED
data/spec/msc_spec.rb
CHANGED
data/spec/nomnoml_spec.rb
CHANGED
data/spec/pikchr_spec.rb
CHANGED
data/spec/plantuml_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'test_helper_methods'
|
2
2
|
|
3
3
|
PLANTUML_CODE = <<-eos
|
4
4
|
User -> (Start)
|
@@ -278,7 +278,7 @@ Foo1 -> Foo2 : To boundary
|
|
278
278
|
expect(File.exist?(target)).to be true
|
279
279
|
|
280
280
|
svg = File.read(target, :encoding => Encoding::UTF_8)
|
281
|
-
expect(svg).to match(/<[^<]+
|
281
|
+
expect(svg).to match(/<[^<]+ stop-color=["']#7C9AB9["']/)
|
282
282
|
end
|
283
283
|
|
284
284
|
it 'should use plantuml include dir when specified as a document attribute' do
|
data/spec/shaape_spec.rb
CHANGED
data/spec/shared_examples.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
require 'rspec'
|
2
|
+
require_relative 'test_helper_methods'
|
2
3
|
|
3
4
|
RSpec.shared_examples "block_macro" do |name, code, formats|
|
4
5
|
formats.each do |format|
|
@@ -497,6 +498,7 @@ Doc Writer <doc@example.com>
|
|
497
498
|
|
498
499
|
[#{name}, format="foobar"]
|
499
500
|
----
|
501
|
+
#{code}
|
500
502
|
----
|
501
503
|
eos
|
502
504
|
|
@@ -757,8 +759,8 @@ Doc Writer <doc@example.com>
|
|
757
759
|
scaled_image = d.find { |bl| bl.context == :image }
|
758
760
|
|
759
761
|
unless formats[0] == :pdf
|
760
|
-
expect(scaled_image.attributes['width']).to be_within(
|
761
|
-
expect(scaled_image.attributes['height']).to be_within(
|
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)
|
762
764
|
end
|
763
765
|
end
|
764
766
|
end
|
data/spec/smcat_spec.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative 'test_helper_methods'
|
2
|
+
|
3
|
+
STRUCTURIZR_CODE = <<-eos
|
4
|
+
workspace {
|
5
|
+
|
6
|
+
model {
|
7
|
+
user = person "User"
|
8
|
+
softwareSystem = softwareSystem "Software System" {
|
9
|
+
webapp = container "Web Application" {
|
10
|
+
user -> this "Uses"
|
11
|
+
}
|
12
|
+
container "Database" {
|
13
|
+
webapp -> this "Reads from and writes to"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
views {
|
19
|
+
systemContext softwareSystem {
|
20
|
+
include *
|
21
|
+
autolayout lr
|
22
|
+
}
|
23
|
+
|
24
|
+
container softwareSystem {
|
25
|
+
include *
|
26
|
+
autolayout lr
|
27
|
+
}
|
28
|
+
|
29
|
+
theme default
|
30
|
+
}
|
31
|
+
|
32
|
+
}
|
33
|
+
eos
|
34
|
+
|
35
|
+
describe Asciidoctor::Diagram::StructurizrBlockMacroProcessor, :broken_on_windows, :broken_on_github do
|
36
|
+
include_examples "block_macro", :structurizr, STRUCTURIZR_CODE, [:png, :png]
|
37
|
+
end
|
38
|
+
|
39
|
+
describe Asciidoctor::Diagram::StructurizrBlockProcessor, :broken_on_windows, :broken_on_github do
|
40
|
+
include_examples "block", :structurizr, STRUCTURIZR_CODE, [:png, :png]
|
41
|
+
end
|
data/spec/svgbob_spec.rb
CHANGED
data/spec/symbolator_spec.rb
CHANGED
data/spec/syntrax_spec.rb
CHANGED
data/spec/tikz_spec.rb
CHANGED
data/spec/umlet_spec.rb
CHANGED
data/spec/vega_spec.rb
CHANGED
data/spec/wavedrom_spec.rb
CHANGED