jekyll-diagrams 0.9.3 → 0.10.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 +4 -4
- data/features/{blockdiag.feature → blockdiag/block.feature} +2 -2
- data/features/graphviz/block.feature +26 -0
- data/features/{graphviz.feature → graphviz/config.feature} +18 -31
- data/features/{mermaid.feature → mermaid/block.feature} +2 -2
- data/features/{nomnoml.feature → nomnoml/block.feature} +2 -2
- data/features/{plantuml.feature → plantuml/block.feature} +3 -12
- data/features/{smcat.feature → smcat/block.feature} +3 -3
- data/features/step_definitions/jekyll-diagrams.rb +5 -5
- data/features/support/env.rb +3 -9
- data/features/{syntrax.feature → syntrax/block.feature} +2 -2
- data/features/{vega.feature → vega/block.feature} +3 -3
- data/features/{wavedrom.feature → wavedrom/block.feature} +2 -2
- data/lib/jekyll-diagrams.rb +22 -61
- data/lib/jekyll-diagrams/basic_block.rb +28 -0
- data/lib/jekyll-diagrams/basic_renderer.rb +38 -0
- data/lib/jekyll-diagrams/blockdiag.rb +5 -31
- data/lib/jekyll-diagrams/blockdiag/block.rb +9 -0
- data/lib/jekyll-diagrams/blockdiag/renderer.rb +40 -0
- data/lib/jekyll-diagrams/erd.rb +4 -30
- data/lib/jekyll-diagrams/erd/block.rb +8 -0
- data/lib/jekyll-diagrams/erd/renderer.rb +34 -0
- data/lib/jekyll-diagrams/errors.rb +12 -13
- data/lib/jekyll-diagrams/graphviz.rb +4 -34
- data/lib/jekyll-diagrams/graphviz/block.rb +8 -0
- data/lib/jekyll-diagrams/graphviz/renderer.rb +40 -0
- data/lib/jekyll-diagrams/mermaid.rb +4 -25
- data/lib/jekyll-diagrams/mermaid/block.rb +8 -0
- data/lib/jekyll-diagrams/mermaid/renderer.rb +29 -0
- data/lib/jekyll-diagrams/nomnoml.rb +4 -15
- data/lib/jekyll-diagrams/nomnoml/block.rb +8 -0
- data/lib/jekyll-diagrams/nomnoml/renderer.rb +19 -0
- data/lib/jekyll-diagrams/plantuml.rb +4 -19
- data/lib/jekyll-diagrams/plantuml/block.rb +8 -0
- data/lib/jekyll-diagrams/plantuml/renderer.rb +23 -0
- data/lib/jekyll-diagrams/smcat.rb +4 -26
- data/lib/jekyll-diagrams/smcat/block.rb +8 -0
- data/lib/jekyll-diagrams/smcat/renderer.rb +30 -0
- data/lib/jekyll-diagrams/svgbob.rb +4 -21
- data/lib/jekyll-diagrams/svgbob/block.rb +8 -0
- data/lib/jekyll-diagrams/svgbob/renderer.rb +25 -0
- data/lib/jekyll-diagrams/syntrax.rb +4 -23
- data/lib/jekyll-diagrams/syntrax/block.rb +8 -0
- data/lib/jekyll-diagrams/syntrax/renderer.rb +27 -0
- data/lib/jekyll-diagrams/utils.rb +85 -0
- data/lib/jekyll-diagrams/vega.rb +5 -26
- data/lib/jekyll-diagrams/vega/block.rb +9 -0
- data/lib/jekyll-diagrams/vega/renderer.rb +33 -0
- data/lib/jekyll-diagrams/version.rb +1 -1
- data/lib/jekyll-diagrams/wavedrom.rb +4 -15
- data/lib/jekyll-diagrams/wavedrom/block.rb +8 -0
- data/lib/jekyll-diagrams/wavedrom/renderer.rb +19 -0
- data/spec/basic_block_spec.rb +70 -0
- data/spec/basic_renderer_spec.rb +69 -0
- data/spec/blockdiag_renderer_spec.rb +43 -0
- data/spec/erd_renderer_spec.rb +43 -0
- data/spec/graphviz_renderer_spec.rb +19 -0
- data/spec/jekyll-diagrams_spec.rb +23 -0
- data/spec/mermaid_renderer_spec.rb +19 -0
- data/spec/nomnoml_renderer_spec.rb +19 -0
- data/spec/plantuml_renderer_spec.rb +20 -0
- data/spec/rendering_spec.rb +111 -0
- data/spec/smcat_renderer_spec.rb +19 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/svgbob_renderer_spec.rb +27 -0
- data/spec/syntrax_renderer_spec.rb +19 -0
- data/spec/utils_spec.rb +163 -0
- data/spec/vega_renderer_spec.rb +19 -0
- data/spec/wavedrom_renderer_spec.rb +19 -0
- metadata +115 -95
- data/lib/jekyll-diagrams/block.rb +0 -51
- data/test/block_test.rb +0 -6
- data/test/blockdiag_test.rb +0 -28
- data/test/erd_test.rb +0 -25
- data/test/rendering_test.rb +0 -20
- data/test/svgbob_test.rb +0 -22
- data/test/test_helper.rb +0 -22
@@ -1,25 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'plantuml/renderer'
|
4
|
+
require_relative 'plantuml/block'
|
5
|
+
|
3
6
|
module Jekyll
|
4
7
|
module Diagrams
|
5
|
-
|
6
|
-
XML_REGEX = /^<\?xml([^>]|\n)*>\n?/.freeze
|
7
|
-
|
8
|
-
def render_svg(code, config)
|
9
|
-
command = build_command(config)
|
10
|
-
|
11
|
-
svg = render_with_stdin_stdout(command, code)
|
12
|
-
svg.sub!(XML_REGEX, '')
|
13
|
-
end
|
14
|
-
|
15
|
-
def build_command(_config)
|
16
|
-
jar = Diagrams.vendor_path('plantuml.1.2020.1.jar')
|
17
|
-
|
18
|
-
options = +Diagrams.run_jar(jar)
|
19
|
-
options << ' -tsvg -pipe'
|
20
|
-
end
|
21
|
-
end
|
8
|
+
Liquid::Template.register_tag(:plantuml, PlantUMLBlock)
|
22
9
|
end
|
23
10
|
end
|
24
|
-
|
25
|
-
Liquid::Template.register_tag(:plantuml, Jekyll::Diagrams::PlantUMLBlock)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Diagrams
|
5
|
+
class PlantUMLRenderer < BasicRenderer
|
6
|
+
XML_REGEX = /^<\?xml([^>]|\n)*>\n?/.freeze
|
7
|
+
|
8
|
+
def render_svg(code, config)
|
9
|
+
command = build_command(config)
|
10
|
+
|
11
|
+
svg = render_with_stdin_stdout(command, code)
|
12
|
+
svg.sub!(XML_REGEX, '')
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_command(_config)
|
16
|
+
jar = Utils.vendor_path('plantuml.1.2020.1.jar')
|
17
|
+
|
18
|
+
options = +Utils.run_jar(jar)
|
19
|
+
options << ' -tsvg -pipe'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,32 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'smcat/renderer'
|
4
|
+
require_relative 'smcat/block'
|
5
|
+
|
3
6
|
module Jekyll
|
4
7
|
module Diagrams
|
5
|
-
|
6
|
-
XML_REGEX = /^<\?xml(([^>]|\n)*>\n?){2}/.freeze
|
7
|
-
CONFIGURATIONS = %w[direction engine input-type].freeze
|
8
|
-
|
9
|
-
def render_svg(code, config)
|
10
|
-
command = build_command(config)
|
11
|
-
|
12
|
-
svg = render_with_tempfile(command, code) do |input, output|
|
13
|
-
"#{input} --output-to #{output}"
|
14
|
-
end
|
15
|
-
|
16
|
-
svg.sub!(XML_REGEX, '')
|
17
|
-
end
|
18
|
-
|
19
|
-
def build_command(config)
|
20
|
-
command = +'smcat'
|
21
|
-
|
22
|
-
CONFIGURATIONS.each do |conf|
|
23
|
-
command << " --#{conf} #{config[conf]}" if config.key?(conf)
|
24
|
-
end
|
25
|
-
|
26
|
-
command
|
27
|
-
end
|
28
|
-
end
|
8
|
+
Liquid::Template.register_tag(:smcat, SMCatBlock)
|
29
9
|
end
|
30
10
|
end
|
31
|
-
|
32
|
-
Liquid::Template.register_tag(:smcat, Jekyll::Diagrams::SMCatBlock)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Diagrams
|
5
|
+
class SMCatRenderer < BasicRenderer
|
6
|
+
XML_REGEX = /^<\?xml(([^>]|\n)*>\n?){2}/.freeze
|
7
|
+
CONFIGURATIONS = %w[direction engine input-type].freeze
|
8
|
+
|
9
|
+
def render_svg(code, config)
|
10
|
+
command = build_command(config)
|
11
|
+
|
12
|
+
svg = render_with_tempfile(command, code) do |input, output|
|
13
|
+
"#{input} --output-to #{output}"
|
14
|
+
end
|
15
|
+
|
16
|
+
svg.sub!(XML_REGEX, '')
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_command(config)
|
20
|
+
command = +'smcat'
|
21
|
+
|
22
|
+
CONFIGURATIONS.each do |conf|
|
23
|
+
command << " --#{conf} #{config[conf]}" if config.key?(conf)
|
24
|
+
end
|
25
|
+
|
26
|
+
command
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,27 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'svgbob/renderer'
|
4
|
+
require_relative 'svgbob/block'
|
5
|
+
|
3
6
|
module Jekyll
|
4
7
|
module Diagrams
|
5
|
-
|
6
|
-
CONFIGURATIONS = %w[font-family font-size scale stroke-width].freeze
|
7
|
-
|
8
|
-
def render_svg(code, config)
|
9
|
-
command = build_command(config)
|
10
|
-
|
11
|
-
render_with_stdin_stdout(command, code)
|
12
|
-
end
|
13
|
-
|
14
|
-
def build_command(config)
|
15
|
-
command = +'svgbob'
|
16
|
-
|
17
|
-
CONFIGURATIONS.each do |conf|
|
18
|
-
command << " --#{conf} #{config[conf]}" if config.key?(conf)
|
19
|
-
end
|
20
|
-
|
21
|
-
command
|
22
|
-
end
|
23
|
-
end
|
8
|
+
Liquid::Template.register_tag(:svgbob, SvgbobBlock)
|
24
9
|
end
|
25
10
|
end
|
26
|
-
|
27
|
-
Liquid::Template.register_tag(:svgbob, Jekyll::Diagrams::SvgbobBlock)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Diagrams
|
5
|
+
class SvgbobRenderer < BasicRenderer
|
6
|
+
CONFIGURATIONS = %w[font-family font-size scale stroke-width].freeze
|
7
|
+
|
8
|
+
def render_svg(code, config)
|
9
|
+
command = build_command(config)
|
10
|
+
|
11
|
+
render_with_stdin_stdout(command, code)
|
12
|
+
end
|
13
|
+
|
14
|
+
def build_command(config)
|
15
|
+
command = +'svgbob'
|
16
|
+
|
17
|
+
CONFIGURATIONS.each do |conf|
|
18
|
+
command << " --#{conf} #{config[conf]}" if config.key?(conf)
|
19
|
+
end
|
20
|
+
|
21
|
+
command
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,29 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'syntrax/renderer'
|
4
|
+
require_relative 'syntrax/block'
|
5
|
+
|
3
6
|
module Jekyll
|
4
7
|
module Diagrams
|
5
|
-
|
6
|
-
CONFIGURATIONS = %w[scale style].freeze
|
7
|
-
|
8
|
-
def render_svg(code, config)
|
9
|
-
command = build_command(config)
|
10
|
-
|
11
|
-
render_with_tempfile(command, code) do |input, output|
|
12
|
-
"--input #{input} --output #{output}"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def build_command(config)
|
17
|
-
command = +'syntrax'
|
18
|
-
|
19
|
-
CONFIGURATIONS.each do |conf|
|
20
|
-
command << " --#{conf} #{config[conf]}" if config.key?(conf)
|
21
|
-
end
|
22
|
-
|
23
|
-
command
|
24
|
-
end
|
25
|
-
end
|
8
|
+
Liquid::Template.register_tag(:syntrax, SyntraxBlock)
|
26
9
|
end
|
27
10
|
end
|
28
|
-
|
29
|
-
Liquid::Template.register_tag(:syntrax, Jekyll::Diagrams::SyntraxBlock)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Diagrams
|
5
|
+
class SyntraxRenderer < BasicRenderer
|
6
|
+
CONFIGURATIONS = %w[scale style].freeze
|
7
|
+
|
8
|
+
def render_svg(code, config)
|
9
|
+
command = build_command(config)
|
10
|
+
|
11
|
+
render_with_tempfile(command, code) do |input, output|
|
12
|
+
"--input #{input} --output #{output}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def build_command(config)
|
17
|
+
command = +'syntrax'
|
18
|
+
|
19
|
+
CONFIGURATIONS.each do |conf|
|
20
|
+
command << " --#{conf} #{config[conf]}" if config.key?(conf)
|
21
|
+
end
|
22
|
+
|
23
|
+
command
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Diagrams
|
5
|
+
module Utils
|
6
|
+
module_function
|
7
|
+
|
8
|
+
# Return configuration of Jekyll Diagrams
|
9
|
+
#
|
10
|
+
# @param context Liquid::Template
|
11
|
+
# @return Configuration
|
12
|
+
def configuration(context)
|
13
|
+
site_config = context.registers[:site].config
|
14
|
+
page_config = context.registers[:page]
|
15
|
+
|
16
|
+
site_config.merge(page_config)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param context Liquid::Template
|
20
|
+
def config_for(context, name)
|
21
|
+
configuration(context).dig(Diagrams.config_name, name) || {}
|
22
|
+
end
|
23
|
+
|
24
|
+
# Return error mode in user configuration
|
25
|
+
#
|
26
|
+
# @param context Liquid::Template
|
27
|
+
def error_mode(context)
|
28
|
+
key = 'error_mode'
|
29
|
+
config = configuration(context)
|
30
|
+
|
31
|
+
liquid_mode = config.dig('liquid', key)
|
32
|
+
custom_mode = config.dig(Diagrams.config_name, key)
|
33
|
+
|
34
|
+
(custom_mode || liquid_mode || Diagrams.default_error_mode).to_sym
|
35
|
+
end
|
36
|
+
|
37
|
+
def handle_error(context, error)
|
38
|
+
topic = Diagrams.logger_topic
|
39
|
+
mode = error_mode(context)
|
40
|
+
|
41
|
+
case mode
|
42
|
+
when :lax
|
43
|
+
''
|
44
|
+
when :warn
|
45
|
+
Jekyll.logger.warn topic, error
|
46
|
+
error
|
47
|
+
when :strict
|
48
|
+
Jekyll.logger.abort_with topic, error
|
49
|
+
else
|
50
|
+
raise Errors::UnkownErrorModeError, mode
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def vendor_path(file = '')
|
55
|
+
File.join(File.expand_path('../../vendor', __dir__), file)
|
56
|
+
end
|
57
|
+
|
58
|
+
def run_jar(jar)
|
59
|
+
"java -Djava.awt.headless=true -jar #{jar} "
|
60
|
+
end
|
61
|
+
|
62
|
+
def normalized_attrs(attrs, prefix:, sep: '=')
|
63
|
+
attrs =
|
64
|
+
case attrs
|
65
|
+
when String
|
66
|
+
attrs
|
67
|
+
when Array
|
68
|
+
attrs.join(prefix)
|
69
|
+
when Hash
|
70
|
+
attrs.map { |k, v| "#{k}#{sep}#{v}" }.join(prefix)
|
71
|
+
end
|
72
|
+
|
73
|
+
"#{prefix}#{attrs}"
|
74
|
+
end
|
75
|
+
|
76
|
+
def wrap_class(content, class_names)
|
77
|
+
<<~CONTENT
|
78
|
+
<div class='#{Diagrams.config_name} diagrams #{class_names}'>
|
79
|
+
#{content}
|
80
|
+
</div>
|
81
|
+
CONTENT
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/jekyll-diagrams/vega.rb
CHANGED
@@ -1,33 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'vega/renderer'
|
4
|
+
require_relative 'vega/block'
|
5
|
+
|
3
6
|
module Jekyll
|
4
7
|
module Diagrams
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def render_svg(code, config)
|
9
|
-
if block_name == 'vegalite'
|
10
|
-
code = render_with_stdin_stdout('vl2vg', code)
|
11
|
-
end
|
12
|
-
|
13
|
-
command = build_command(config)
|
14
|
-
|
15
|
-
render_with_stdin_stdout(command, code)
|
16
|
-
end
|
17
|
-
|
18
|
-
def build_command(config)
|
19
|
-
command = +'vg2svg'
|
20
|
-
|
21
|
-
CONFIGURATIONS.each do |conf|
|
22
|
-
command << " --#{conf} #{config[conf]}" if config.key?(conf)
|
23
|
-
end
|
24
|
-
|
25
|
-
command
|
26
|
-
end
|
8
|
+
%i[vega vegalite].each do |name|
|
9
|
+
Liquid::Template.register_tag(name, const_get("#{name.capitalize}Block"))
|
27
10
|
end
|
28
11
|
end
|
29
12
|
end
|
30
|
-
|
31
|
-
%i[vega vegalite].each do |tag|
|
32
|
-
Liquid::Template.register_tag(tag, Jekyll::Diagrams::VegaBlock)
|
33
|
-
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Diagrams
|
5
|
+
%i[vega vegalite].each do |name|
|
6
|
+
renderer = Class.new(BasicRenderer) do
|
7
|
+
const_set :CONFIGURATIONS, %w[scale].freeze
|
8
|
+
|
9
|
+
def render_svg(code, config)
|
10
|
+
if @block_name == 'vegalite'
|
11
|
+
code = render_with_stdin_stdout('vl2vg', code)
|
12
|
+
end
|
13
|
+
|
14
|
+
command = build_command(config)
|
15
|
+
|
16
|
+
render_with_stdin_stdout(command, code)
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_command(config)
|
20
|
+
command = +'vg2svg'
|
21
|
+
|
22
|
+
self.class.const_get(:CONFIGURATIONS).each do |conf|
|
23
|
+
command << " --#{conf} #{config[conf]}" if config.key?(conf)
|
24
|
+
end
|
25
|
+
|
26
|
+
command
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
const_set "#{name.capitalize}Renderer", renderer
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|