jekyll-diagrams 0.9.3 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e747a50f5b7243d7385068b039987f6a562423a2de58c5fca5a6ba2b0e3f5fcd
|
4
|
+
data.tar.gz: 2d2e9080efbefdea34b81df49e7b47c01ebdc753571317754ae1bfb4e28a6e0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dce4156ef2128881613b401747c9a32c17e0ac56f420e6359f32cb6c39478a5a39d807b2ed615e27f00b4ce0f357a2d3a444f50651247684f990769d0fc5a78e
|
7
|
+
data.tar.gz: 7d987eb136d804ce0023abe94f6acf48557063c96f9e94e11e082b65a3075d1f5fdd40d784fc682d1928bd63bc95a02fd041c8f5f782bf40303b8544bbef6edf
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Feature: Graphviz Block
|
2
|
+
|
3
|
+
|
4
|
+
Background: I have a file with Graghviz
|
5
|
+
Given I have a file named 'graphviz.md' with:
|
6
|
+
"""
|
7
|
+
---
|
8
|
+
---
|
9
|
+
|
10
|
+
{% graphviz %}
|
11
|
+
digraph {
|
12
|
+
A -> B;
|
13
|
+
}
|
14
|
+
{% endgraphviz %}
|
15
|
+
"""
|
16
|
+
|
17
|
+
Scenario: Basic Rendering
|
18
|
+
When I run jekyll build
|
19
|
+
Then the file '_site/graphviz.html' should exist
|
20
|
+
And I should see svg output in '_site/graphviz.html'
|
21
|
+
|
22
|
+
Scenario: It Remove XML Heading
|
23
|
+
When I run jekyll build
|
24
|
+
Then the file '_site/graphviz.html' should exist
|
25
|
+
And I should not see '<\?xml' in '_site/graphviz.html'
|
26
|
+
And I should not see '<!DOCTYPE' in '_site/graphviz.html'
|
@@ -1,8 +1,18 @@
|
|
1
|
-
Feature: Graphviz
|
1
|
+
Feature: Graphviz Configuration
|
2
2
|
|
3
3
|
|
4
|
-
|
5
|
-
Given I have a file '
|
4
|
+
Scenario: Global Configuration
|
5
|
+
Given I have a file named '_config.yml' with:
|
6
|
+
"""
|
7
|
+
jekyll-diagrams:
|
8
|
+
graphviz:
|
9
|
+
graph_attributes: bgcolor=red
|
10
|
+
edge_attributes:
|
11
|
+
- color=green
|
12
|
+
node_attributes:
|
13
|
+
color: blue
|
14
|
+
"""
|
15
|
+
And I have a file named 'graphviz.md' with:
|
6
16
|
"""
|
7
17
|
---
|
8
18
|
---
|
@@ -13,29 +23,6 @@ Feature: Graphviz
|
|
13
23
|
}
|
14
24
|
{% endgraphviz %}
|
15
25
|
"""
|
16
|
-
|
17
|
-
Scenario: Basic Rendering
|
18
|
-
When I run jekyll build
|
19
|
-
Then the file '_site/graphviz.html' should exist
|
20
|
-
And I should see svg output in '_site/graphviz.html'
|
21
|
-
|
22
|
-
Scenario: Remove XML Heading
|
23
|
-
When I run jekyll build
|
24
|
-
Then the file '_site/graphviz.html' should exist
|
25
|
-
And I should not see '<\?xml' in '_site/graphviz.html'
|
26
|
-
And I should not see '<!DOCTYPE' in '_site/graphviz.html'
|
27
|
-
|
28
|
-
Scenario: Global Configugration
|
29
|
-
Given I have a file '_config.yml' with content:
|
30
|
-
"""
|
31
|
-
jekyll-diagrams:
|
32
|
-
graphviz:
|
33
|
-
graph_attributes: bgcolor=red
|
34
|
-
edge_attributes:
|
35
|
-
- color=green
|
36
|
-
node_attributes:
|
37
|
-
color: blue
|
38
|
-
"""
|
39
26
|
When I run jekyll build
|
40
27
|
Then the file '_site/graphviz.html' should exist
|
41
28
|
# Graph
|
@@ -45,15 +32,15 @@ Feature: Graphviz
|
|
45
32
|
# Node
|
46
33
|
And I should see '<ellipse .*? stroke="#0000ff"' in '_site/graphviz.html'
|
47
34
|
|
48
|
-
Scenario: Page
|
49
|
-
Given I have a file '_config.yml' with
|
35
|
+
Scenario: Page Configuration Will Overwite Site Configuration
|
36
|
+
Given I have a file named '_config.yml' with:
|
50
37
|
"""
|
51
38
|
jekyll-diagrams:
|
52
39
|
graphviz:
|
53
40
|
edge_attributes:
|
54
|
-
color:
|
41
|
+
color: green
|
55
42
|
"""
|
56
|
-
And I have a file 'graphviz.md' with
|
43
|
+
And I have a file named 'graphviz.md' with:
|
57
44
|
"""
|
58
45
|
---
|
59
46
|
jekyll-diagrams:
|
@@ -71,4 +58,4 @@ Feature: Graphviz
|
|
71
58
|
When I run jekyll build
|
72
59
|
Then the file '_site/graphviz.html' should exist
|
73
60
|
And I should see '<path .*? stroke="#ff0000"' in '_site/graphviz.html'
|
74
|
-
And I should not see '<path .*? stroke="#
|
61
|
+
And I should not see '<path .*? stroke="#00ff00"' in '_site/graphviz.html'
|
@@ -1,8 +1,8 @@
|
|
1
|
-
Feature: PlantUML
|
1
|
+
Feature: PlantUML Block
|
2
2
|
|
3
3
|
|
4
4
|
Background: I have a file with PlantUML
|
5
|
-
Given I have a file 'plantuml.md' with
|
5
|
+
Given I have a file named 'plantuml.md' with:
|
6
6
|
"""
|
7
7
|
---
|
8
8
|
---
|
@@ -13,20 +13,11 @@ Feature: PlantUML
|
|
13
13
|
"""
|
14
14
|
|
15
15
|
Scenario: Basic Rendering
|
16
|
-
Given I have a file 'plantuml.md' with content:
|
17
|
-
"""
|
18
|
-
---
|
19
|
-
---
|
20
|
-
|
21
|
-
{% plantuml %}
|
22
|
-
Bob->Alice : hello
|
23
|
-
{% endplantuml %}
|
24
|
-
"""
|
25
16
|
When I run jekyll build
|
26
17
|
Then the file '_site/plantuml.html' should exist
|
27
18
|
And I should see svg output in '_site/plantuml.html'
|
28
19
|
|
29
|
-
Scenario: Remove XML Heading
|
20
|
+
Scenario: It Remove XML Heading
|
30
21
|
When I run jekyll build
|
31
22
|
Then the file '_site/plantuml.html' should exist
|
32
23
|
And I should not see '<\?xml' in '_site/plantuml.html'
|
@@ -1,8 +1,8 @@
|
|
1
|
-
Feature: SMCat
|
1
|
+
Feature: SMCat Block
|
2
2
|
|
3
3
|
|
4
4
|
Background: I have a file with SMCat
|
5
|
-
Given I have a file 'smcat.md' with
|
5
|
+
Given I have a file named 'smcat.md' with:
|
6
6
|
"""
|
7
7
|
---
|
8
8
|
---
|
@@ -17,7 +17,7 @@ Feature: SMCat
|
|
17
17
|
Then the file '_site/smcat.html' should exist
|
18
18
|
And I should see svg output in '_site/smcat.html'
|
19
19
|
|
20
|
-
Scenario: Remove XML Heading
|
20
|
+
Scenario: It Remove XML Heading
|
21
21
|
When I run jekyll build
|
22
22
|
Then the file '_site/smcat.html' should exist
|
23
23
|
And I should not see '<\?xml' in '_site/smcat.html'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
Given('I have a file {string} with
|
3
|
+
Given('I have a file named {string} with:') do |file, content|
|
4
4
|
File.write(file, content)
|
5
5
|
end
|
6
6
|
|
@@ -9,17 +9,17 @@ When('I run jekyll build') do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
Then('the file {string} should exist') do |file|
|
12
|
-
|
12
|
+
expect(File.exist?(file)).to be true
|
13
13
|
end
|
14
14
|
|
15
15
|
Then('I should see svg output in {string}') do |file|
|
16
|
-
|
16
|
+
expect(File.read(file)).to match %r{<svg(.|\r|\n)*?>(.|\r|\n)*</svg>}
|
17
17
|
end
|
18
18
|
|
19
19
|
Then('I should see {string} in {string}') do |pattern, file|
|
20
|
-
|
20
|
+
expect(File.read(file)).to match Regexp.new(pattern)
|
21
21
|
end
|
22
22
|
|
23
23
|
Then('I should not see {string} in {string}') do |pattern, file|
|
24
|
-
|
24
|
+
expect(File.read(file)).not_to match Regexp.new(pattern)
|
25
25
|
end
|
data/features/support/env.rb
CHANGED
@@ -3,13 +3,8 @@
|
|
3
3
|
lib = File.expand_path('../lib', __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
require 'coveralls'
|
9
|
-
Coveralls.wear!
|
10
|
-
end
|
11
|
-
|
12
|
-
require 'minitest'
|
6
|
+
require 'simplecov'
|
7
|
+
require 'rspec'
|
13
8
|
require 'tmpdir'
|
14
9
|
require 'jekyll-diagrams'
|
15
10
|
|
@@ -31,8 +26,7 @@ end
|
|
31
26
|
def run_jekyll
|
32
27
|
options = Jekyll.configuration(
|
33
28
|
source: TEST_DIR,
|
34
|
-
quiet: true
|
35
|
-
liquid: { 'error_mode' => 'strict' }
|
29
|
+
quiet: true
|
36
30
|
)
|
37
31
|
|
38
32
|
Jekyll::Site.new(options).process
|
@@ -1,8 +1,8 @@
|
|
1
|
-
Feature: Vega
|
1
|
+
Feature: Vega Block
|
2
2
|
|
3
3
|
|
4
4
|
Scenario: Basic Vega Rendering
|
5
|
-
Given I have a file 'vega.md' with
|
5
|
+
Given I have a file named 'vega.md' with:
|
6
6
|
"""
|
7
7
|
---
|
8
8
|
---
|
@@ -23,7 +23,7 @@ Feature: Vega
|
|
23
23
|
And I should see svg output in '_site/vega.html'
|
24
24
|
|
25
25
|
Scenario: Basic Vegalite Rendering
|
26
|
-
Given I have a file 'vegalite.md' with
|
26
|
+
Given I have a file named 'vegalite.md' with:
|
27
27
|
"""
|
28
28
|
---
|
29
29
|
---
|
data/lib/jekyll-diagrams.rb
CHANGED
@@ -2,69 +2,12 @@
|
|
2
2
|
|
3
3
|
require 'jekyll'
|
4
4
|
|
5
|
-
module Jekyll
|
6
|
-
module Diagrams
|
7
|
-
class << self
|
8
|
-
# Return configuration of Jekyll Diagrams
|
9
|
-
#
|
10
|
-
# @param context [Liquid::Context, :registers] Parsed context
|
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
|
-
def config_for(context, name)
|
20
|
-
configuration(context).dig(config_name, name) || {}
|
21
|
-
end
|
22
|
-
|
23
|
-
def error_mode(context)
|
24
|
-
liquid_mode = configuration(context).dig('liquid', 'error_mode')
|
25
|
-
custom_mode = configuration(context).dig(config_name, 'error_mode')
|
26
|
-
|
27
|
-
(custom_mode || liquid_mode || :warn).to_sym
|
28
|
-
end
|
29
|
-
|
30
|
-
# Return file path under vendor path
|
31
|
-
#
|
32
|
-
# @param file [String] If not given, return directory path
|
33
|
-
def vendor_path(file = '')
|
34
|
-
File.join(File.expand_path('../vendor', __dir__), file)
|
35
|
-
end
|
36
|
-
|
37
|
-
# @param jar [String] Jar path to run
|
38
|
-
def run_jar(jar)
|
39
|
-
"java -Djava.awt.headless=true -jar #{jar} "
|
40
|
-
end
|
41
|
-
|
42
|
-
def normalized_attrs(attrs, prefix:, sep: '=')
|
43
|
-
attrs =
|
44
|
-
case attrs
|
45
|
-
when String
|
46
|
-
attrs
|
47
|
-
when Array
|
48
|
-
attrs.join(prefix)
|
49
|
-
when Hash
|
50
|
-
attrs.map { |k, v| "#{k}#{sep}#{v}" }.join(prefix)
|
51
|
-
end
|
52
|
-
|
53
|
-
"#{prefix}#{attrs}"
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def config_name
|
59
|
-
'jekyll-diagrams'
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
5
|
require_relative 'jekyll-diagrams/errors'
|
6
|
+
require_relative 'jekyll-diagrams/utils'
|
66
7
|
require_relative 'jekyll-diagrams/rendering'
|
67
|
-
|
8
|
+
|
9
|
+
require_relative 'jekyll-diagrams/basic_renderer'
|
10
|
+
require_relative 'jekyll-diagrams/basic_block'
|
68
11
|
|
69
12
|
require_relative 'jekyll-diagrams/blockdiag'
|
70
13
|
require_relative 'jekyll-diagrams/erd'
|
@@ -77,3 +20,21 @@ require_relative 'jekyll-diagrams/svgbob'
|
|
77
20
|
require_relative 'jekyll-diagrams/syntrax'
|
78
21
|
require_relative 'jekyll-diagrams/vega'
|
79
22
|
require_relative 'jekyll-diagrams/wavedrom'
|
23
|
+
|
24
|
+
module Jekyll
|
25
|
+
module Diagrams
|
26
|
+
class << self
|
27
|
+
def config_name
|
28
|
+
'jekyll-diagrams'
|
29
|
+
end
|
30
|
+
|
31
|
+
def logger_topic
|
32
|
+
'Jekyll Diagrams:'
|
33
|
+
end
|
34
|
+
|
35
|
+
def default_error_mode
|
36
|
+
:warn
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,28 @@
|
|
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
|
@@ -0,0 +1,38 @@
|
|
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
|