jekyll-diagrams 0.10.0 → 0.11.0.pre
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/README.md +26 -411
- data/features/{blockdiag/block.feature → blockdiag_block.feature} +0 -0
- data/features/{graphviz/block.feature → graphviz_block.feature} +0 -0
- data/features/{graphviz/config.feature → graphviz_config.feature} +0 -0
- data/features/{mermaid/block.feature → mermaid_block.feature} +0 -0
- data/features/{nomnoml/block.feature → nomnoml_block.feature} +0 -0
- data/features/{plantuml/block.feature → plantuml_block.feature} +0 -0
- data/features/{smcat/block.feature → smcat_block.feature} +0 -0
- data/features/step_definitions/{jekyll-diagrams.rb → diagrams.rb} +0 -0
- data/features/support/env.rb +4 -1
- data/features/{syntrax/block.feature → syntrax_block.feature} +0 -0
- data/features/{vega/block.feature → vega_block.feature} +0 -0
- data/features/{wavedrom/block.feature → wavedrom_block.feature} +0 -0
- data/lib/jekyll-diagrams.rb +1 -38
- data/lib/jekyll_diagrams.rb +85 -0
- data/lib/jekyll_diagrams/version.rb +5 -0
- data/spec/{utils_spec.rb → jekyll_diagrams_spec.rb} +18 -70
- data/spec/spec_helper.rb +10 -8
- metadata +85 -129
- data/lib/jekyll-diagrams/basic_block.rb +0 -28
- data/lib/jekyll-diagrams/basic_renderer.rb +0 -38
- data/lib/jekyll-diagrams/blockdiag.rb +0 -12
- data/lib/jekyll-diagrams/blockdiag/block.rb +0 -9
- data/lib/jekyll-diagrams/blockdiag/renderer.rb +0 -40
- data/lib/jekyll-diagrams/erd.rb +0 -10
- data/lib/jekyll-diagrams/erd/block.rb +0 -8
- data/lib/jekyll-diagrams/erd/renderer.rb +0 -34
- data/lib/jekyll-diagrams/errors.rb +0 -24
- data/lib/jekyll-diagrams/graphviz.rb +0 -10
- data/lib/jekyll-diagrams/graphviz/block.rb +0 -8
- data/lib/jekyll-diagrams/graphviz/renderer.rb +0 -40
- data/lib/jekyll-diagrams/mermaid.rb +0 -10
- data/lib/jekyll-diagrams/mermaid/block.rb +0 -8
- data/lib/jekyll-diagrams/mermaid/renderer.rb +0 -29
- data/lib/jekyll-diagrams/nomnoml.rb +0 -10
- data/lib/jekyll-diagrams/nomnoml/block.rb +0 -8
- data/lib/jekyll-diagrams/nomnoml/renderer.rb +0 -19
- data/lib/jekyll-diagrams/plantuml.rb +0 -10
- data/lib/jekyll-diagrams/plantuml/block.rb +0 -8
- data/lib/jekyll-diagrams/plantuml/renderer.rb +0 -23
- data/lib/jekyll-diagrams/rendering.rb +0 -67
- data/lib/jekyll-diagrams/smcat.rb +0 -10
- data/lib/jekyll-diagrams/smcat/block.rb +0 -8
- data/lib/jekyll-diagrams/smcat/renderer.rb +0 -30
- data/lib/jekyll-diagrams/svgbob.rb +0 -10
- data/lib/jekyll-diagrams/svgbob/block.rb +0 -8
- data/lib/jekyll-diagrams/svgbob/renderer.rb +0 -25
- data/lib/jekyll-diagrams/syntrax.rb +0 -10
- data/lib/jekyll-diagrams/syntrax/block.rb +0 -8
- data/lib/jekyll-diagrams/syntrax/renderer.rb +0 -27
- data/lib/jekyll-diagrams/utils.rb +0 -85
- data/lib/jekyll-diagrams/vega.rb +0 -12
- data/lib/jekyll-diagrams/vega/block.rb +0 -9
- data/lib/jekyll-diagrams/vega/renderer.rb +0 -33
- data/lib/jekyll-diagrams/version.rb +0 -7
- data/lib/jekyll-diagrams/wavedrom.rb +0 -10
- data/lib/jekyll-diagrams/wavedrom/block.rb +0 -8
- data/lib/jekyll-diagrams/wavedrom/renderer.rb +0 -19
- data/spec/basic_block_spec.rb +0 -70
- data/spec/basic_renderer_spec.rb +0 -69
- data/spec/blockdiag_renderer_spec.rb +0 -43
- data/spec/erd_renderer_spec.rb +0 -43
- data/spec/graphviz_renderer_spec.rb +0 -19
- data/spec/jekyll-diagrams_spec.rb +0 -23
- data/spec/mermaid_renderer_spec.rb +0 -19
- data/spec/nomnoml_renderer_spec.rb +0 -19
- data/spec/plantuml_renderer_spec.rb +0 -20
- data/spec/rendering_spec.rb +0 -111
- data/spec/smcat_renderer_spec.rb +0 -19
- data/spec/svgbob_renderer_spec.rb +0 -27
- data/spec/syntrax_renderer_spec.rb +0 -19
- data/spec/vega_renderer_spec.rb +0 -19
- data/spec/wavedrom_renderer_spec.rb +0 -19
- data/vendor/mermaid_puppeteer_config.json +0 -3
- data/vendor/plantuml.1.2020.1.jar +0 -0
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Diagrams
|
5
|
-
class BasicBlock < Liquid::Block
|
6
|
-
def self.renderer
|
7
|
-
@renderer ||= const_get(renderer_name)
|
8
|
-
rescue NameError => error
|
9
|
-
raise Errors::RendererNotFoundError, error.message.split(' ').last
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.renderer_name
|
13
|
-
@renderer_name ||= name.sub(/Block$/, 'Renderer')
|
14
|
-
end
|
15
|
-
|
16
|
-
def render(context)
|
17
|
-
self.class.renderer.render(
|
18
|
-
context, super.to_s, {
|
19
|
-
diagram_name: self.class.name.split('::').last
|
20
|
-
.sub(/Block$/, '').downcase
|
21
|
-
}
|
22
|
-
)
|
23
|
-
rescue Errors::RendererNotFoundError => error
|
24
|
-
Utils.handle_error(context, error)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Diagrams
|
5
|
-
class BasicRenderer
|
6
|
-
include Rendering
|
7
|
-
|
8
|
-
def self.render(context, content, options = {})
|
9
|
-
new(context, content, options).render
|
10
|
-
end
|
11
|
-
|
12
|
-
def initialize(context, content, options = {})
|
13
|
-
@context = context
|
14
|
-
@content = content
|
15
|
-
@diagram = options.fetch(:diagram_name) do
|
16
|
-
self.class.name.split('::').last.sub(/Renderer$/, '').downcase
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def render
|
21
|
-
output = render_svg(@content, configuration)
|
22
|
-
Utils.wrap_class(output, @diagram)
|
23
|
-
rescue StandardError => error
|
24
|
-
Utils.wrap_class(Utils.handle_error(@context, error), @diagram)
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def configuration
|
30
|
-
Utils.config_for(@context, @diagram)
|
31
|
-
end
|
32
|
-
|
33
|
-
def render_svg(_code, _config)
|
34
|
-
raise NotImplementedError
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'blockdiag/renderer'
|
4
|
-
require_relative 'blockdiag/block'
|
5
|
-
|
6
|
-
module Jekyll
|
7
|
-
module Diagrams
|
8
|
-
%i[blockdiag seqdiag actdiag nwdiag rackdiag packetdiag].each do |name|
|
9
|
-
Liquid::Template.register_tag(name, const_get("#{name.capitalize}Block"))
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Diagrams
|
5
|
-
%i[blockdiag seqdiag actdiag nwdiag rackdiag packetdiag].each do |name|
|
6
|
-
renderer = Class.new(BasicRenderer) do
|
7
|
-
const_set :CONFIGURATIONS, %w[config font fontmap size].freeze
|
8
|
-
const_set :SWITCHES, {
|
9
|
-
'antialias' => false
|
10
|
-
}.freeze
|
11
|
-
|
12
|
-
def render_svg(code, config)
|
13
|
-
command = build_command(config)
|
14
|
-
|
15
|
-
render_with_tempfile(command, code) do |input, output|
|
16
|
-
"#{input} -o #{output}"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def build_command(config)
|
21
|
-
command = +"#{@diagram} -T svg --nodoctype"
|
22
|
-
|
23
|
-
switches = self.class.const_get(:SWITCHES)
|
24
|
-
|
25
|
-
switches.merge(config.slice(*switches.keys)).each do |switch, value|
|
26
|
-
command << " --#{switch}" if value != false
|
27
|
-
end
|
28
|
-
|
29
|
-
self.class.const_get(:CONFIGURATIONS).each do |conf|
|
30
|
-
command << " --#{conf}=#{config[conf]}" if config.key?(conf)
|
31
|
-
end
|
32
|
-
|
33
|
-
command
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
const_set "#{name.capitalize}Renderer", renderer
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
data/lib/jekyll-diagrams/erd.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Diagrams
|
5
|
-
class ErdRenderer < BasicRenderer
|
6
|
-
XML_REGEX = /^<\?xml(([^>]|\n)*>\n?){2}/.freeze
|
7
|
-
CONFIGURATIONS = %w[config edge].freeze
|
8
|
-
SWITCHES = {
|
9
|
-
'dot-entity' => false
|
10
|
-
}.freeze
|
11
|
-
|
12
|
-
def render_svg(code, config)
|
13
|
-
command = build_command(config)
|
14
|
-
|
15
|
-
svg = render_with_stdin_stdout(command, code)
|
16
|
-
svg.sub!(XML_REGEX, '')
|
17
|
-
end
|
18
|
-
|
19
|
-
def build_command(config)
|
20
|
-
command = +'erd --fmt=svg'
|
21
|
-
|
22
|
-
SWITCHES.merge(config.slice(*SWITCHES.keys)).each do |switch, value|
|
23
|
-
command << " --#{switch}" if value != false
|
24
|
-
end
|
25
|
-
|
26
|
-
CONFIGURATIONS.each do |conf|
|
27
|
-
command << " --#{conf}=#{config[conf]}" if config.key?(conf)
|
28
|
-
end
|
29
|
-
|
30
|
-
command
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Diagrams
|
5
|
-
module Errors
|
6
|
-
class BasicError < ::StandardError
|
7
|
-
def initialize(val)
|
8
|
-
# Jekyll::...::CommandNotFoundError -> 'CommandNotFoundError'
|
9
|
-
klass = self.class.name.split('::').last
|
10
|
-
# 'CommandNotFound' -> 'Command Not Found'
|
11
|
-
prefix = klass.sub(/Error$/, '').split(/(?=[A-Z])/).join(' ')
|
12
|
-
|
13
|
-
# "Command Not Found: raw message"
|
14
|
-
super("#{prefix}: #{val}")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
CommandNotFoundError = Class.new(BasicError)
|
19
|
-
RenderingFailedError = Class.new(BasicError)
|
20
|
-
RendererNotFoundError = Class.new(BasicError)
|
21
|
-
UnkownErrorModeError = Class.new(BasicError)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Diagrams
|
5
|
-
class GraphvizRenderer < BasicRenderer
|
6
|
-
XML_REGEX = /^<\?xml(([^>]|\n)*>\n?){2}/.freeze
|
7
|
-
CONFIGRATIONS = {
|
8
|
-
'K' => 'default_layout',
|
9
|
-
'G' => 'graph_attributes',
|
10
|
-
'N' => 'node_attributes',
|
11
|
-
'E' => 'edge_attributes'
|
12
|
-
}.freeze
|
13
|
-
|
14
|
-
def render_svg(code, config)
|
15
|
-
command = build_command(config)
|
16
|
-
|
17
|
-
svg = render_with_stdin_stdout(command, code).force_encoding(
|
18
|
-
config.fetch('encoding', 'utf-8')
|
19
|
-
)
|
20
|
-
|
21
|
-
svg.sub!(XML_REGEX, '')
|
22
|
-
end
|
23
|
-
|
24
|
-
def build_command(config)
|
25
|
-
command = +'dot -Tsvg'
|
26
|
-
|
27
|
-
CONFIGRATIONS.each do |prefix, conf|
|
28
|
-
next unless config.key?(conf)
|
29
|
-
|
30
|
-
command << Utils.normalized_attrs(
|
31
|
-
config[conf],
|
32
|
-
prefix: " -#{prefix}"
|
33
|
-
)
|
34
|
-
end
|
35
|
-
|
36
|
-
command
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Diagrams
|
5
|
-
class MermaidRenderer < BasicRenderer
|
6
|
-
CONFIGURATIONS = %w[theme width height backgroundColor
|
7
|
-
configFile cssFile scale].freeze
|
8
|
-
|
9
|
-
def render_svg(code, config)
|
10
|
-
command = build_command(config)
|
11
|
-
|
12
|
-
render_with_tempfile(command, code) do |input, output|
|
13
|
-
"--input #{input} --output #{output}"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def build_command(config)
|
18
|
-
command = +'mmdc --puppeteerConfigFile '
|
19
|
-
command << Utils.vendor_path('mermaid_puppeteer_config.json')
|
20
|
-
|
21
|
-
CONFIGURATIONS.each do |conf|
|
22
|
-
command << " --#{conf} #{config[conf]}" if config.key?(conf)
|
23
|
-
end
|
24
|
-
|
25
|
-
command
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Diagrams
|
5
|
-
class NomnomlRenderer < BasicRenderer
|
6
|
-
def render_svg(code, config)
|
7
|
-
command = build_command(config)
|
8
|
-
|
9
|
-
render_with_tempfile(command, code) do |input, output|
|
10
|
-
"#{input} #{output}"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def build_command(_config)
|
15
|
-
'nomnoml'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,23 +0,0 @@
|
|
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,67 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'open3'
|
4
|
-
require 'tempfile'
|
5
|
-
require 'tmpdir'
|
6
|
-
|
7
|
-
module Jekyll
|
8
|
-
module Diagrams
|
9
|
-
module Rendering
|
10
|
-
module_function
|
11
|
-
|
12
|
-
# Render SVG with stdin and stdout
|
13
|
-
#
|
14
|
-
# @param command Command to run
|
15
|
-
# @param content Content passed to command
|
16
|
-
# @return The SVG output
|
17
|
-
def render_with_stdin_stdout(command, content)
|
18
|
-
render_with_command(command, :stdout, stdin_data: content)
|
19
|
-
end
|
20
|
-
|
21
|
-
# Render SVG with tempfile
|
22
|
-
#
|
23
|
-
# @param command Command to run
|
24
|
-
# @param content Content passed to command
|
25
|
-
# @param block Result of block will append to command
|
26
|
-
# @return The SVG output
|
27
|
-
def render_with_tempfile(command, content)
|
28
|
-
Dir.mktmpdir('jekyll-diagrams-rendering') do |dir|
|
29
|
-
input = Tempfile.new('input', tmpdir: dir)
|
30
|
-
output = Tempfile.new(%w[output .svg], tmpdir: dir)
|
31
|
-
|
32
|
-
File.write(input.path, content)
|
33
|
-
|
34
|
-
extra = yield input.path, output.path
|
35
|
-
command = "#{command} #{extra}"
|
36
|
-
|
37
|
-
render_with_command(command, output.path)
|
38
|
-
ensure
|
39
|
-
input.close!
|
40
|
-
output.close!
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# Render SVG with command
|
45
|
-
#
|
46
|
-
# @param command Command to run
|
47
|
-
# @param output Output path, use :stdout for stdout
|
48
|
-
# @param options Extra options passed to Open3.captrue3
|
49
|
-
# @return The SVG output
|
50
|
-
def render_with_command(command, output = :stdout, **options)
|
51
|
-
begin
|
52
|
-
stdout, stderr, status = Open3.capture3(command, **options)
|
53
|
-
rescue Errno::ENOENT
|
54
|
-
raise Errors::CommandNotFoundError, command.split(' ')[0]
|
55
|
-
end
|
56
|
-
|
57
|
-
unless status.success?
|
58
|
-
raise Errors::RenderingFailedError, <<~MSG
|
59
|
-
#{command}: #{stderr.empty? ? stdout : stderr}
|
60
|
-
MSG
|
61
|
-
end
|
62
|
-
|
63
|
-
output == :stdout ? stdout : File.read(output)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|