jekyll-diagrams 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -4
  3. data/.travis.yml +89 -24
  4. data/Dockerfile +25 -0
  5. data/README.md +68 -19
  6. data/Rakefile +13 -6
  7. data/lib/jekyll-diagrams/block.rb +3 -2
  8. data/lib/jekyll-diagrams/blockdiag.rb +3 -8
  9. data/lib/jekyll-diagrams/erd.rb +20 -18
  10. data/lib/jekyll-diagrams/graphviz.rb +6 -4
  11. data/lib/jekyll-diagrams/mermaid.rb +9 -12
  12. data/lib/jekyll-diagrams/nomnoml.rb +19 -0
  13. data/lib/jekyll-diagrams/plantuml.rb +4 -2
  14. data/lib/jekyll-diagrams/renderer.rb +16 -4
  15. data/lib/jekyll-diagrams/smcat.rb +19 -21
  16. data/lib/jekyll-diagrams/svgbob.rb +25 -0
  17. data/lib/jekyll-diagrams/syntrax.rb +18 -16
  18. data/lib/jekyll-diagrams/util.rb +19 -19
  19. data/lib/jekyll-diagrams/vega.rb +30 -0
  20. data/lib/jekyll-diagrams/version.rb +1 -1
  21. data/lib/jekyll-diagrams/wavedrom.rb +14 -12
  22. data/lib/jekyll-diagrams.rb +3 -0
  23. data/test/dummy_site/{_posts/2020-01-01-graphviz-test.md → apt/graphviz.md} +1 -4
  24. data/test/dummy_site/{_posts/2020-01-07-erd-test.md → cabal/erd.md} +1 -2
  25. data/test/dummy_site/cargo/svgbob.md +14 -0
  26. data/test/dummy_site/index.md +4 -0
  27. data/test/dummy_site/{_posts/2020-01-03-plantuml-test.md → java/plantuml.md} +1 -4
  28. data/test/dummy_site/{_posts/2020-01-04-mermaid-test.md → npm/mermaid.md} +1 -4
  29. data/test/dummy_site/npm/nomnoml.md +27 -0
  30. data/test/dummy_site/{_posts/2020-01-06-smcat-test.md → npm/smcat.md} +1 -4
  31. data/test/dummy_site/npm/vega.md +103 -0
  32. data/test/dummy_site/{_posts/2020-01-05-wavedrom-test.md → npm/wavedrom.md} +1 -4
  33. data/test/dummy_site/{_posts/2020-01-02-blockdiag-test.md → pip/blockdiag.md} +1 -4
  34. data/test/dummy_site/pip/syntrax.md +13 -0
  35. metadata +29 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45645fc482eb66caa1e9dcc420f1da9f500c5c3c4735df834f51a265b9ab5234
4
- data.tar.gz: 630469bb87099ce469e507f03e3b2567bd9e7eb6cc16b9d295427c39c3e8cd5a
3
+ metadata.gz: e3f1fe990807c62c25fe99620086be43c6ee2686466a343ca5ae3c46bc22a62b
4
+ data.tar.gz: be24cab35d4b8afdd58956532d200b9010d3e4ef33a1961e532b9d1a857eac41
5
5
  SHA512:
6
- metadata.gz: b1fe97c25a68ebe37dccc5e5583dcb6ac0768c76922e89d5a033c4205dcf5005aa8abe1e1cb7a2f0261046a0329dd87d24c3c92b20761b41b0fa5e96fc2e22c4
7
- data.tar.gz: bd1017c5fd734b0a080cec05a309e4c829475ec34644d76af6df934644dd920e1e3371543c36a4038f6fe185e3708d51d9e8fbc55ecbbfe9a31a8c66d3a8cded
6
+ metadata.gz: 2852b19ce85eef87ae1e362d63047aadf101f3867c8027650c49c3f9118533ba4615a36b1f748ea16cf373ab774729f04c8870c6a15d2f2268b447e926209901
7
+ data.tar.gz: 448d85033efb665594918b9ef20a0827de05407757afc3440311f43e45f4d184cae890f8bfc63fd900c3ee4e092e3ceb9557c42aac01263bdbc867bd1d659154
data/.gitignore CHANGED
@@ -1,5 +1,5 @@
1
+ .bundle
1
2
  .jekyll-cache
2
- Gemfile.lock
3
- /.bundle/
4
- /pkg/
5
- /test/dummy_site/_site/
3
+ _site
4
+ pkg
5
+ Gemfile.lock
data/.travis.yml CHANGED
@@ -1,25 +1,90 @@
1
1
  language: ruby
2
- cache: bundler
3
- rvm:
4
- - 2.4
5
- - 2.5
6
- - 2.6
7
- - 2.7
8
-
9
- addons:
10
- apt:
11
- packages:
12
- - cabal-install
13
- - default-jre
14
- - gnuplot
15
- - graphviz
16
- - npm
17
- - python3
18
- - python3-pip
19
- - python3-setuptools
20
-
21
- before_install:
22
- - sudo cabal update && sudo cabal install erd
23
- - sudo gem update --system && sudo gem install bundler
24
- - sudo npm install -g mermaid.cli state-machine-cat wavedrom-cli
25
- - sudo pip3 install blockdiag seqdiag actdiag nwdiag syntrax
2
+
3
+ dist: bionic
4
+
5
+ cache:
6
+ apt: true
7
+ bundler: true
8
+
9
+ jobs:
10
+ fast_finish: true
11
+ allow_failures:
12
+ - name: Cabal Packages
13
+ env: DIAGRAM=cabal
14
+ cache:
15
+ directories:
16
+ - "$HOME/.cabal"
17
+ addons:
18
+ apt:
19
+ update: true
20
+ packages:
21
+ - cabal-install
22
+ before_install:
23
+ - cabal update
24
+ - cabal install erd
25
+ include:
26
+ - name: Apt Packages
27
+ env: DIAGRAM=apt
28
+ addons:
29
+ apt:
30
+ update: true
31
+ packages:
32
+ - graphviz
33
+
34
+ - name: Cargo Packages
35
+ env: DIAGRAM=cargo
36
+ cache: cargo
37
+ addons:
38
+ apt:
39
+ update: true
40
+ packages:
41
+ - cargo
42
+ before_install:
43
+ - cargo install svgbob_cli
44
+
45
+ - name: Java Packages
46
+ env: DIAGRAM=java
47
+ addons:
48
+ apt:
49
+ update: true
50
+ packages:
51
+ - default-jre-headless
52
+
53
+ - name: Npm Packages
54
+ env: DIAGRAM=npm
55
+ cache: npm
56
+ addons:
57
+ apt:
58
+ update: true
59
+ packages:
60
+ - npm
61
+ before_install:
62
+ - npm install -g mermaid.cli nomnoml state-machine-cat
63
+ - npm install -g vega-cli vega-lite wavedrom-cli
64
+
65
+ - name: Pip Packages
66
+ env: DIAGRAM=pip
67
+ cache: pip
68
+ addons:
69
+ apt:
70
+ update: true
71
+ packages:
72
+ - libpython3-dev
73
+ - libpango1.0-dev
74
+ - python3-pip
75
+ - python3-setuptools
76
+ - python3-cairo
77
+ - python3-gi
78
+ before_install:
79
+ - pip3 install blockdiag seqdiag actdiag nwdiag syntrax
80
+
81
+ script: bundle exec rake 'dummy_site:build[$DIAGRAM]'
82
+
83
+ deploy:
84
+ provider: rubygems
85
+ api_key:
86
+ secure: b8mpSmo1IqW0DWhqwbZtrNWS/XIUGdLvtFuvBptdA979lpb9aDFfWaFgHnZ6IahP2djRT1yRx6fg/6cp2ZShC/FdpekeASEUn4KGz+1kNh/rfSYPQV5Cs7nkw9i2/WWmze4al5cS7IhnOr2vYXlGTZZeC6Lb+3eQHtVJYQpG3bGwg9ozyekYC2VWQdzFVAvLsjAGMEi2S5GQobbmfN5FvUZb4dnnl3crI+q0NoDkafpzZBcH8ITTZyttZDU26JIptXM5qRGZGGYSREzCc3frLpoIbAB1Vbz/A4+RF8wecsmBMOPNCPWWMvjtgkII5fHmDF/cXAnbktVzG3ECNIGmv7UPA64Mjgl9WZKZH1rujDievVz9aRryA8jIIBbbfqNZeQ+SwP3401vPLSW7yWWJdkPrFMe9+OpV47azmdTVG0PmIdPhkSOI4s3sR0BAFp6TPgaLEH1zrm3sPfLkkVD5XGfQTlI7KIS4e68qGHC2mO5LGXby8SMMp+5/+A5Pzo0dbtXtOJxNwI+iZEhNJh49Qgwc/Cd0cRbFXGWOBMNDozW95LlrDWw9rdwWE4HjuEWfwRbQGydymp+CskkKne7bz4F27UbHI0ougdekI+TaY5w6UL12rZhwbutxASLH0d+dT2OR+rC7prbJRjcwpxEFt/DwiGsVepgB8Uwge8CPSYI=
87
+ gem: jekyll-diagrams
88
+ on:
89
+ tags: true
90
+ repo: zhustec/jekyll-diagrams
data/Dockerfile ADDED
@@ -0,0 +1,25 @@
1
+ FROM ubuntu:bionic
2
+
3
+ RUN set -eux; \
4
+ apt-get update; \
5
+ apt-get install -y --no-install-recommends build-essential cabal-install \
6
+ cargo default-jre-headless git graphviz libpango1.0-dev \
7
+ libpython3-dev npm python3-pip python3-cairo python3-gi \
8
+ python3-setuptools ruby ruby-dev
9
+
10
+ RUN set -eux; \
11
+ gem update -N --system; \
12
+ gem install -N bundler; \
13
+ npm install -g --silent mermaid.cli nomnoml state-machine-cat wavedrom-cli; \
14
+ pip3 install blockdiag seqdiag actdiag nwdiag syntrax
15
+
16
+ WORKDIR /opt/jekyll-diagrams
17
+
18
+ COPY . .
19
+
20
+ # RUN set -eux; \
21
+ # apt-get install -y --no-install-recommends cabal-install; \
22
+ # cabal update; \
23
+ # cabal install erd
24
+
25
+ # RUN bundle install
data/README.md CHANGED
@@ -7,19 +7,33 @@
7
7
 
8
8
  Jekyll Diagrams is a jekyll plugins for creating amazing diagrams, including:
9
9
 
10
- - [**Blockdiag**](#blockdiag)
11
- - [**Erd**](#erd)
12
- - [**Graphviz**](#graphviz)
13
- - [**Mermaid**](#mermaid)
14
- - [**PlantUML**](#plantUML)
15
- - [**State Machine Cat**](#state-machine-cat)
16
- - [**Syntrax**](#syntrax)
10
+ - [Installation](#installation)
11
+ - [Configuration](#configuration)
12
+ - [Usage](#usage)
13
+ - [Blockdiag](#blockdiag)
14
+ - [Erd](#erd)
15
+ - [Graphviz](#graphviz)
16
+ - [Mermaid](#mermaid)
17
+ - [Nomnoml](#nomnoml)
18
+ - [PlantUML](#plantuml)
19
+ - [State Machine Cat](#state-machine-cat)
20
+ - [Svgbob](#svgbob)
21
+ - [Syntrax](#syntrax)
22
+ - [Vega](#vega)
23
+ - [Wavedrom](#wavedrom)
24
+ - [Contributing](#contributing)
25
+ - [License](#license)
17
26
 
18
27
  ## Installation
19
28
 
20
- ### When using bundler
29
+ Add the following to your site's `_config.yml`:
21
30
 
22
- Add these lines to your application's `Gemfile` file:
31
+ ```yaml
32
+ plugins:
33
+ - jekyll-diagrams
34
+ ```
35
+
36
+ And the following to your site's `Gemfile`:
23
37
 
24
38
  ```ruby
25
39
  group :jekyll_plugins do
@@ -27,23 +41,23 @@ group :jekyll_plugins do
27
41
  end
28
42
  ```
29
43
 
30
- And then execute:
44
+ Finally run:
31
45
 
32
46
  ```bash
33
- $ bundle
47
+ $ bundle install
34
48
  ```
35
49
 
36
- ### Or installing manually
50
+ ## Configuration
37
51
 
38
- ```bash
39
- $ gem install jekyll-diagrams
40
- ```
41
-
42
- And then add this line to your application's `_config.yml` file:
52
+ All configurations are at `_config.yml` file under `jekyll-diagrams`, e.g:
43
53
 
44
54
  ```yaml
45
- plugins:
46
- - jekyll-diagrams
55
+ jekyll-diagrams:
56
+ graphviz:
57
+ # configurations for graphviz
58
+ blockdiag:
59
+ # configurations for blockdiag
60
+ # and so on
47
61
  ```
48
62
 
49
63
  ## Usage
@@ -210,6 +224,35 @@ jekyll-diagrams:
210
224
  - `height`: Height of the page. (default: 600)
211
225
  - `backgroundColor`: Background color. Example: transparent, red, '#F0F0F0'. (default: white)
212
226
 
227
+ ### Nomnoml
228
+
229
+ #### Examples
230
+
231
+ ```text
232
+ {% nomnoml %}
233
+ [Pirate|eyeCount: Int|raid();pillage()|
234
+ [beard]--[parrot]
235
+ [beard]-:>[foul mouth]
236
+ ]
237
+
238
+ [<abstract>Marauder]<:--[Pirate]
239
+ [Pirate]- 0..7[mischief]
240
+ [jollyness]->[Pirate]
241
+ [jollyness]->[rum]
242
+ [jollyness]->[singing]
243
+ [Pirate]-> *[rum|tastiness: Int|swig()]
244
+ [Pirate]->[singing]
245
+ [singing]<->[rum]
246
+
247
+ [<start>st]->[<state>plunder]
248
+ [plunder]->[<choice>more loot]
249
+ [more loot]->[st]
250
+ [more loot] no ->[<end>e]
251
+
252
+ [<actor>Sailor] - [<usecase>shiver me;timbers]
253
+ {% endnomnoml %}
254
+ ```
255
+
213
256
  ### PlantUML
214
257
 
215
258
  #### Prerequisites
@@ -273,6 +316,8 @@ jekyll-diagrams:
273
316
  - `engine`: `dot|circo|fdp|neato|osage|twopi` (Default: `dot`)
274
317
  - `direction`: `top-down|bottom-top|left-right|right-left` (Default: `top-down`)
275
318
 
319
+ ### Svgbob
320
+
276
321
  ### Syntrax
277
322
 
278
323
  #### Prerequisites
@@ -303,6 +348,10 @@ jekyll-diagrams:
303
348
  transparent: 'Transparent background'
304
349
  ```
305
350
 
351
+ ### Vega
352
+
353
+ ### Wavedrom
354
+
306
355
  ## Contributing
307
356
 
308
357
  Bug reports and pull requests are welcome on GitHub at https://github.com/zhustec/jekyll-diagrams. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
data/Rakefile CHANGED
@@ -9,13 +9,20 @@ end
9
9
 
10
10
  task default: :test
11
11
 
12
- desc 'Run dummy site'
13
- task :dummy_site do
14
- dummy_site_path = File.expand_path('test/dummy_site', __dir__)
12
+ namespace :dummy_site do
13
+ DUMMY_SITE_PATH = File.expand_path('test/dummy_site', __dir__)
14
+ DIAGRAMS = %w(apt cabal cargo java npm pip)
15
15
 
16
- Dir.chdir(dummy_site_path) do
17
- puts "Current directory: #{Dir.pwd}"
16
+ %w(build serve).each do |action|
17
+ desc "#{action.capitalize} the dummy site"
18
+ task action.to_sym, :diagram do |t, args|
19
+ args.with_defaults(diagram: '')
20
+ diagram = args[:diagram]
21
+ path = File.join(DUMMY_SITE_PATH, diagram)
18
22
 
19
- %x(bundle exec jekyll serve --trace)
23
+ Dir.chdir(DUMMY_SITE_PATH) do
24
+ %x(bundle install && bundle exec jekyll #{action} --config _config.yml -s #{path})
25
+ end
26
+ end
20
27
  end
21
28
  end
@@ -2,6 +2,7 @@ module Jekyll
2
2
  module Diagrams
3
3
  class Block < Liquid::Block
4
4
  include Renderer
5
+ include Util
5
6
 
6
7
  def render(context)
7
8
  svg = render_svg(super.to_s, read_config(context))
@@ -13,9 +14,9 @@ module Jekyll
13
14
  end
14
15
 
15
16
  def read_config(context)
16
- Util.config_for(context, block_name)
17
+ config_for(context, block_name)
17
18
  end
18
-
19
+
19
20
  def wrap_class(content)
20
21
  "<div class='jekyll-diagrams diagrams #{block_name}'>#{content}</div>"
21
22
  end
@@ -1,23 +1,18 @@
1
- require 'open3'
2
- require 'tempfile'
3
-
4
1
  module Jekyll
5
2
  module Diagrams
6
3
  class BlockdiagBlock < Block
7
- CONFIGURATIONS = %w(config font fontmap size).freeze
4
+ CONFIGURATIONS = %w( config font fontmap size ).freeze
8
5
 
9
6
  def render_svg(code, config)
10
7
  command = build_command(config)
11
-
8
+
12
9
  render_with_tempfile(command, code) do |command, input, output|
13
10
  "#{command} #{input} -o #{output}"
14
11
  end
15
12
  end
16
13
 
17
14
  def read_config(context)
18
- Util.config_for(context, 'blockdiag').merge(
19
- Util.config_for(context, block_name)
20
- )
15
+ config_for(context, 'blockdiag').merge(config_for(context, block_name))
21
16
  end
22
17
 
23
18
  def build_command(config)
@@ -1,25 +1,27 @@
1
1
  module Jekyll
2
- module Diagrams
3
- class ErdBlock < Block
4
- CONFIGURATIONS = %w(config edge).freeze
5
-
6
- def render_svg(code, config)
7
- svg = render_with_stdin_stdout(build_command(config), code)
8
- svg.sub!(/^<\?xml(([^>]|\n)*>\n?){2}/, '')
9
- end
10
-
11
- def build_command(config)
12
- command = 'erd --fmt=svg'
13
- command << ' --dot-entity' if config.has_key?('dot-entity')
2
+ module Diagrams
3
+ class ErdBlock < Block
4
+ CONFIGURATIONS = %w( config edge ).freeze
5
+
6
+ def render_svg(code, config)
7
+ command = build_command(config)
8
+
9
+ svg = render_with_stdin_stdout(command, code)
10
+ svg.sub!(/^<\?xml(([^>]|\n)*>\n?){2}/, '')
11
+ end
14
12
 
15
- CONFIGURATIONS.each do |conf|
16
- command << " --#{conf}=#{config[conf]}" if config.has_key?(conf)
17
- end
13
+ def build_command(config)
14
+ command = 'erd --fmt=svg'
15
+ command << ' --dot-entity' if config.has_key?('dot-entity')
18
16
 
19
- command
17
+ CONFIGURATIONS.each do |conf|
18
+ command << " --#{conf}=#{config[conf]}" if config.has_key?(conf)
20
19
  end
20
+
21
+ command
21
22
  end
22
23
  end
23
24
  end
24
-
25
- Liquid::Template.register_tag(:erd, Jekyll::Diagrams::ErdBlock)
25
+ end
26
+
27
+ Liquid::Template.register_tag(:erd, Jekyll::Diagrams::ErdBlock)
@@ -7,9 +7,11 @@ module Jekyll
7
7
  'N' => 'node_attribute',
8
8
  'E' => 'edge_attribute'
9
9
  }.freeze
10
-
10
+
11
11
  def render_svg(code, config)
12
- svg = render_with_stdin_stdout(build_command(config), code)
12
+ command = build_command(config)
13
+
14
+ svg = render_with_stdin_stdout(command, code)
13
15
  svg.sub!(/^<\?xml(([^>]|\n)*>\n?){2}/, '')
14
16
  end
15
17
 
@@ -18,9 +20,9 @@ module Jekyll
18
20
 
19
21
  CONFIGRATIONS.each do |prefix, conf|
20
22
  next unless config.has_key?(conf)
21
-
23
+
22
24
  attrs = config[conf]
23
-
25
+
24
26
  attrs = case attrs
25
27
  when String
26
28
  attrs
@@ -1,26 +1,23 @@
1
1
  module Jekyll
2
2
  module Diagrams
3
3
  class MermaidBlock < Block
4
- CONFIGURATIONS = {
5
- 'theme' => 'default',
6
- 'width' => 800,
7
- 'height' => 600,
8
- 'backgroundColor' => 'white'
9
- }.freeze
4
+ CONFIGURATIONS = %w( backgroundColor height theme width).freeze
10
5
 
11
6
  def render_svg(code, config)
12
- render_with_tempfile(build_command(config), code) do |command, input, output|
7
+ command = build_command(config)
8
+
9
+ render_with_tempfile(command, code) do |command, input, output|
13
10
  "#{command} --input #{input} --output #{output}"
14
11
  end
15
12
  end
16
-
13
+
17
14
  def build_command(config)
18
15
  command = 'mmdc'
19
16
  command << ' --transparent' if config.has_key?('transparent')
20
- command << " --puppeteerConfigFile #{Util.vendor_path('mermaid_puppeteer_config.json')}"
17
+ command << " --puppeteerConfigFile #{vendor_path('mermaid_puppeteer_config.json')}"
21
18
 
22
- CONFIGURATIONS.merge(config).each do |conf, value|
23
- command << " --#{conf} #{value}"
19
+ CONFIGURATIONS.each do |conf|
20
+ command << " --#{conf} #{config[conf]}" if config.has_key?(conf)
24
21
  end
25
22
 
26
23
  command
@@ -28,5 +25,5 @@ module Jekyll
28
25
  end
29
26
  end
30
27
  end
31
-
28
+
32
29
  Liquid::Template.register_tag(:mermaid, Jekyll::Diagrams::MermaidBlock)
@@ -0,0 +1,19 @@
1
+ module Jekyll
2
+ module Diagrams
3
+ class NomnomlBlock < Block
4
+ def render_svg(code, config)
5
+ command = build_command(config)
6
+
7
+ render_with_stdout(command, code) do |command, input|
8
+ "#{command} #{input}"
9
+ end
10
+ end
11
+
12
+ def build_command(config)
13
+ 'nomnoml'
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ Liquid::Template.register_tag(:nomnoml, Jekyll::Diagrams::NomnomlBlock)
@@ -2,7 +2,9 @@ module Jekyll
2
2
  module Diagrams
3
3
  class PlantUMLBlock < Block
4
4
  def render_svg(code, config)
5
- svg = render_with_stdin_stdout(build_command(config), code)
5
+ command = build_command(config)
6
+
7
+ svg = render_with_stdin_stdout(command, code)
6
8
  svg.sub!(/^<\?xml([^>]|\n)*>\n?/, '')
7
9
  end
8
10
 
@@ -10,7 +12,7 @@ module Jekyll
10
12
  options = 'java'
11
13
  options << ' -Djava.awt.headless=true'
12
14
  options << ' -jar '
13
- options << Util.vendor_path('plantuml.1.2020.1.jar')
15
+ options << vendor_path('plantuml.1.2020.1.jar')
14
16
  options << ' -tsvg -pipe'
15
17
  end
16
18
  end
@@ -4,6 +4,8 @@ require 'tempfile'
4
4
  module Jekyll
5
5
  module Diagrams
6
6
  module Renderer
7
+ extend self
8
+
7
9
  def render_with_stdin_stdout(command, content)
8
10
  command = yield command if block_given?
9
11
 
@@ -13,19 +15,29 @@ module Jekyll
13
15
  def render_with_stdin(command, content)
14
16
  Tempfile.open(['jekyll_diagrams_output', ".svg"]) do |output|
15
17
  output.close
16
- command = yield command, output.path
18
+ command = yield command, output.path if block_given?
17
19
 
18
20
  render_with_command(command, output.path, stdin_data: content)
19
21
  end
20
22
  end
21
23
 
24
+ def render_with_stdout(command, content)
25
+ Tempfile.open('jekyll_diagrams_input') do |input|
26
+ File.write(input.path, content)
27
+
28
+ command = yield command, input.path if block_given?
29
+
30
+ render_with_command(command, :stdout)
31
+ end
32
+ end
33
+
22
34
  def render_with_tempfile(command, content)
23
35
  Tempfile.open('jekyll_diagrams_input') do |input|
24
36
  File.write(input.path, content)
25
-
37
+
26
38
  Tempfile.open(['jekyll_diagrams_output', ".svg"]) do |output|
27
39
  output.close
28
- command = yield command, input.path, output.path
40
+ command = yield command, input.path, output.path if block_given?
29
41
 
30
42
  render_with_command(command, output.path)
31
43
  end
@@ -39,7 +51,7 @@ module Jekyll
39
51
  raise "#{command} failed: #{stdout.empty? ? stderr : stdout}"
40
52
  end
41
53
 
42
- output == :stdout ? stdout : File.read(output)
54
+ output == :stdout ? stdout : File.read(output)
43
55
  end
44
56
  end
45
57
  end
@@ -1,31 +1,29 @@
1
1
  module Jekyll
2
- module Diagrams
3
- class SMCatBlock < Block
4
- CONFIGURATIONS = {
5
- 'input-type' => 'smcat',
6
- 'engine' => 'dot',
7
- 'direction' => 'top-down'
8
- }.freeze
2
+ module Diagrams
3
+ class SMCatBlock < Block
4
+ CONFIGURATIONS = %w( direction engine input-type ).freeze
9
5
 
10
- def render_svg(code, config)
11
- svg = render_with_tempfile(build_command(config), code) do |command, input, output|
12
- "#{command} #{input} --output-to #{output}"
13
- end
6
+ def render_svg(code, config)
7
+ command = build_command(config)
14
8
 
15
- svg.sub!(/^<\?xml(([^>]|\n)*>\n?){2}/, '')
9
+ svg = render_with_stdout(command, code) do |command, input|
10
+ "#{command} #{input} -"
16
11
  end
17
-
18
- def build_command(config)
19
- command = 'smcat'
20
12
 
21
- CONFIGURATIONS.merge(config).each do |conf, value|
22
- command << " --#{conf} #{value}"
23
- end
13
+ svg.sub!(/^<\?xml(([^>]|\n)*>\n?){2}/, '')
14
+ end
15
+
16
+ def build_command(config)
17
+ command = 'smcat'
24
18
 
25
- command
19
+ CONFIGURATIONS.each do |conf|
20
+ command << " --#{conf} #{config[conf]}" if config.has_key?(conf)
26
21
  end
22
+
23
+ command
27
24
  end
28
25
  end
29
26
  end
30
-
31
- Liquid::Template.register_tag(:smcat, Jekyll::Diagrams::SMCatBlock)
27
+ end
28
+
29
+ Liquid::Template.register_tag(:smcat, Jekyll::Diagrams::SMCatBlock)
@@ -0,0 +1,25 @@
1
+ module Jekyll
2
+ module Diagrams
3
+ class SvgbobBlock < Block
4
+ CONFIGURATIONS = %w( font-family font-size scale stroke-width ).freeze
5
+
6
+ def render_svg(code, config)
7
+ command = build_command(config)
8
+
9
+ render_with_stdin_stdout(command, code)
10
+ end
11
+
12
+ def build_command(config)
13
+ command = 'svgbob'
14
+
15
+ CONFIGURATIONS.each do |conf|
16
+ command << " --#{conf} #{config[conf]}" if config.has_key?(conf)
17
+ end
18
+
19
+ command
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ Liquid::Template.register_tag(:svgbob, Jekyll::Diagrams::SvgbobBlock)
@@ -1,25 +1,27 @@
1
1
  module Jekyll
2
- module Diagrams
3
- class SyntraxBlock < Block
4
- CONFIGURATIONS = %w(scale style).freeze
2
+ module Diagrams
3
+ class SyntraxBlock < Block
4
+ CONFIGURATIONS = %w( scale style ).freeze
5
5
 
6
- def render_svg(code, config)
7
- render_with_tempfile(build_command(config), code) do |command, input, output|
8
- "#{command} --input #{input} --output #{output}"
9
- end
6
+ def render_svg(code, config)
7
+ command = build_command(config)
8
+
9
+ render_with_tempfile(command, code) do |command, input, output|
10
+ "#{command} --input #{input} --output #{output}"
10
11
  end
11
-
12
- def build_command(config)
13
- command = 'syntrax'
12
+ end
14
13
 
15
- CONFIGURATIONS.each do |conf|
16
- command << " --#{conf} #{config[conf]}" if config.has_key?(conf)
17
- end
14
+ def build_command(config)
15
+ command = 'syntrax'
18
16
 
19
- command
17
+ CONFIGURATIONS.each do |conf|
18
+ command << " --#{conf} #{config[conf]}" if config.has_key?(conf)
20
19
  end
20
+
21
+ command
21
22
  end
22
23
  end
23
24
  end
24
-
25
- Liquid::Template.register_tag(:syntrax, Jekyll::Diagrams::SyntraxBlock)
25
+ end
26
+
27
+ Liquid::Template.register_tag(:syntrax, Jekyll::Diagrams::SyntraxBlock)
@@ -1,27 +1,27 @@
1
1
  module Jekyll
2
2
  module Diagrams
3
3
  module Util
4
- class << self
5
- def diagrams_config(context)
6
- site_config = context.registers[:site].config
7
- new_config = site_config.fetch('jekyll-diagrams', {})
8
- old_config = site_config.fetch('diagrams', {})
9
-
10
- return new_config if old_config.empty?
11
-
12
- Jekyll.warn "Configuration `diagram` in _config.yml will be depreated"
13
- Jekyll.warn " Rename it to `jekyll-diagram` instead."
4
+ extend self
14
5
 
15
- old_config.merge(new_config)
16
- end
17
-
18
- def config_for(context, name)
19
- diagrams_config(context).fetch(name, {})
20
- end
6
+ def diagrams_config(context)
7
+ site_config = context.registers[:site].config
8
+ new_config = site_config.fetch('jekyll-diagrams', {})
9
+ old_config = site_config.fetch('diagrams', {})
21
10
 
22
- def vendor_path(file = '')
23
- File.join(File.expand_path('../../vendor', __dir__), file)
24
- end
11
+ return new_config if old_config.empty?
12
+
13
+ Jekyll.warn "Configuration `diagram` in _config.yml will be depreated"
14
+ Jekyll.warn " Rename it to `jekyll-diagram` instead."
15
+
16
+ old_config.merge(new_config)
17
+ end
18
+
19
+ def config_for(context, name)
20
+ diagrams_config(context).fetch(name, {})
21
+ end
22
+
23
+ def vendor_path(file = '')
24
+ File.join(File.expand_path('../../vendor', __dir__), file)
25
25
  end
26
26
  end
27
27
  end
@@ -0,0 +1,30 @@
1
+ module Jekyll
2
+ module Diagrams
3
+ class VegaBlock < Block
4
+ CONFIGURATIONS = %w( scale )
5
+
6
+ def render_svg(code, config)
7
+ command = build_command(config)
8
+
9
+ render_with_stdin_stdout(command, code)
10
+ end
11
+
12
+ def build_command(config)
13
+ command = case block_name
14
+ when 'vega'
15
+ 'vg2svg'
16
+ when 'vegalite'
17
+ 'vl2svg'
18
+ end
19
+
20
+ CONFIGURATIONS.each do |conf|
21
+ command << " --#{conf} #{config[conf]}" if config.has_key?(conf)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ %i(vega vegalite).each do |tag|
29
+ Liquid::Template.register_tag(tag, Jekyll::Diagrams::VegaBlock)
30
+ end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Diagrams
3
- VERSION = '0.7.1'
3
+ VERSION = '0.8.0'
4
4
  end
5
5
  end
@@ -1,17 +1,19 @@
1
1
  module Jekyll
2
- module Diagrams
3
- class WavedromBlock < Block
4
- def render_svg(code, config)
5
- render_with_tempfile(build_command(config), code) do |command, input, output|
6
- "#{command} --input #{input} --svg #{output}"
7
- end
8
- end
9
-
10
- def build_command(config)
11
- 'wavedrom-cli'
2
+ module Diagrams
3
+ class WavedromBlock < Block
4
+ def render_svg(code, config)
5
+ command = build_command(config)
6
+
7
+ render_with_tempfile(command, code) do |command, input, output|
8
+ "#{command} --input #{input} --svg #{output}"
12
9
  end
13
10
  end
11
+
12
+ def build_command(config)
13
+ 'wavedrom-cli'
14
+ end
14
15
  end
15
16
  end
16
-
17
- Liquid::Template.register_tag(:wavedrom, Jekyll::Diagrams::WavedromBlock)
17
+ end
18
+
19
+ Liquid::Template.register_tag(:wavedrom, Jekyll::Diagrams::WavedromBlock)
@@ -6,6 +6,9 @@ require_relative 'jekyll-diagrams/blockdiag'
6
6
  require_relative 'jekyll-diagrams/erd'
7
7
  require_relative 'jekyll-diagrams/graphviz'
8
8
  require_relative 'jekyll-diagrams/mermaid'
9
+ require_relative 'jekyll-diagrams/nomnoml'
9
10
  require_relative 'jekyll-diagrams/plantuml'
11
+ require_relative 'jekyll-diagrams/svgbob'
10
12
  require_relative 'jekyll-diagrams/smcat'
13
+ require_relative 'jekyll-diagrams/vega'
11
14
  require_relative 'jekyll-diagrams/wavedrom'
@@ -1,11 +1,8 @@
1
1
  ---
2
- layout: post
2
+ layout: home
3
3
  title: Graphviz Test
4
- date: 2020-01-01 00:00:00 +0800
5
4
  ---
6
5
 
7
- # Graphviz Test
8
-
9
6
  {% graphviz %}
10
7
  digraph {
11
8
  node [shape=circle, style=filled];
@@ -1,7 +1,6 @@
1
1
  ---
2
- layout: post
2
+ layout: home
3
3
  title: Erd Test
4
- date: 2020-01-07 00:00:00 +0800
5
4
  ---
6
5
 
7
6
  # Erd Test
@@ -0,0 +1,14 @@
1
+ ---
2
+ layout: home
3
+ title: Svgbob Test
4
+ ---
5
+
6
+ {% svgbob %}
7
+ .---.
8
+ /-o-/--
9
+ .-/ / /->
10
+ ( * \/
11
+ '-. \
12
+ \ /
13
+ '
14
+ {% endsvgbob %}
@@ -1,3 +1,7 @@
1
1
  ---
2
2
  layout: home
3
3
  ---
4
+
5
+ {% for page in site.pages %}
6
+ - [**{{ page.title }}**]({{ page.url }})
7
+ {% endfor %}
@@ -1,11 +1,8 @@
1
1
  ---
2
- layout: post
2
+ layout: home
3
3
  title: PlantUML Test
4
- date: 2020-01-03 00:00:00 +0800
5
4
  ---
6
5
 
7
- # PlantUML Test
8
-
9
6
  {% plantuml %}
10
7
  @startuml
11
8
  actor Foo1
@@ -1,11 +1,8 @@
1
1
  ---
2
- layout: post
2
+ layout: home
3
3
  title: Mermaid Test
4
- date: 2020-01-04 00:00:00 +0800
5
4
  ---
6
5
 
7
- # Mermaid Test
8
-
9
6
  {% mermaid %}
10
7
  graph TB
11
8
  c1-->a2
@@ -0,0 +1,27 @@
1
+ ---
2
+ layout: home
3
+ title: Nomnoml Test
4
+ ---
5
+
6
+ {% nomnoml %}
7
+ [Pirate|eyeCount: Int|raid();pillage()|
8
+ [beard]--[parrot]
9
+ [beard]-:>[foul mouth]
10
+ ]
11
+
12
+ [<abstract>Marauder]<:--[Pirate]
13
+ [Pirate]- 0..7[mischief]
14
+ [jollyness]->[Pirate]
15
+ [jollyness]->[rum]
16
+ [jollyness]->[singing]
17
+ [Pirate]-> *[rum|tastiness: Int|swig()]
18
+ [Pirate]->[singing]
19
+ [singing]<->[rum]
20
+
21
+ [<start>st]->[<state>plunder]
22
+ [plunder]->[<choice>more loot]
23
+ [more loot]->[st]
24
+ [more loot] no ->[<end>e]
25
+
26
+ [<actor>Sailor] - [<usecase>shiver me;timbers]
27
+ {% endnomnoml %}
@@ -1,11 +1,8 @@
1
1
  ---
2
- layout: post
2
+ layout: home
3
3
  title: State Machine Cat Test
4
- date: 2020-01-06 00:00:00 +0800
5
4
  ---
6
5
 
7
- # State Machine Cat Test
8
-
9
6
  {% smcat %}
10
7
  initial,
11
8
  doing: entry/ write unit test
@@ -0,0 +1,103 @@
1
+ ---
2
+ layout: home
3
+ title: Vega Test
4
+ ---
5
+
6
+ {% vega %}
7
+ {
8
+ "$schema": "https://vega.github.io/schema/vega/v5.json",
9
+ "description": "A basic bar chart example, with value labels shown upon mouse hover.",
10
+ "width": 400,
11
+ "height": 200,
12
+ "padding": 5,
13
+
14
+ "data": [
15
+ {
16
+ "name": "table",
17
+ "values": [
18
+ {"category": "A", "amount": 28},
19
+ {"category": "B", "amount": 55},
20
+ {"category": "C", "amount": 43},
21
+ {"category": "D", "amount": 91},
22
+ {"category": "E", "amount": 81},
23
+ {"category": "F", "amount": 53},
24
+ {"category": "G", "amount": 19},
25
+ {"category": "H", "amount": 87}
26
+ ]
27
+ }
28
+ ],
29
+
30
+ "signals": [
31
+ {
32
+ "name": "tooltip",
33
+ "value": {},
34
+ "on": [
35
+ {"events": "rect:mouseover", "update": "datum"},
36
+ {"events": "rect:mouseout", "update": "{}"}
37
+ ]
38
+ }
39
+ ],
40
+
41
+ "scales": [
42
+ {
43
+ "name": "xscale",
44
+ "type": "band",
45
+ "domain": {"data": "table", "field": "category"},
46
+ "range": "width",
47
+ "padding": 0.05,
48
+ "round": true
49
+ },
50
+ {
51
+ "name": "yscale",
52
+ "domain": {"data": "table", "field": "amount"},
53
+ "nice": true,
54
+ "range": "height"
55
+ }
56
+ ],
57
+
58
+ "axes": [
59
+ { "orient": "bottom", "scale": "xscale" },
60
+ { "orient": "left", "scale": "yscale" }
61
+ ],
62
+
63
+ "marks": [
64
+ {
65
+ "type": "rect",
66
+ "from": {"data":"table"},
67
+ "encode": {
68
+ "enter": {
69
+ "x": {"scale": "xscale", "field": "category"},
70
+ "width": {"scale": "xscale", "band": 1},
71
+ "y": {"scale": "yscale", "field": "amount"},
72
+ "y2": {"scale": "yscale", "value": 0}
73
+ },
74
+ "update": {
75
+ "fill": {"value": "steelblue"}
76
+ },
77
+ "hover": {
78
+ "fill": {"value": "red"}
79
+ }
80
+ }
81
+ },
82
+ {
83
+ "type": "text",
84
+ "encode": {
85
+ "enter": {
86
+ "align": {"value": "center"},
87
+ "baseline": {"value": "bottom"},
88
+ "fill": {"value": "#333"}
89
+ },
90
+ "update": {
91
+ "x": {"scale": "xscale", "signal": "tooltip.category", "band": 0.5},
92
+ "y": {"scale": "yscale", "signal": "tooltip.amount", "offset": -2},
93
+ "text": {"signal": "tooltip.amount"},
94
+ "fillOpacity": [
95
+ {"test": "datum === tooltip", "value": 0},
96
+ {"value": 1}
97
+ ]
98
+ }
99
+ }
100
+ }
101
+ ]
102
+ }
103
+ {% endvega %}
@@ -1,11 +1,8 @@
1
1
  ---
2
- layout: post
2
+ layout: home
3
3
  title: Wavedrom Test
4
- date: 2020-01-05 00:00:00 +0800
5
4
  ---
6
5
 
7
- # Wavedrom Test
8
-
9
6
  {% wavedrom %}
10
7
  {signal: [
11
8
  {name: 'clk', wave: 'p.....|...'},
@@ -1,11 +1,8 @@
1
1
  ---
2
- layout: post
2
+ layout: home
3
3
  title: Blockdiag Test
4
- date: 2020-01-02 00:00:00 +0800
5
4
  ---
6
5
 
7
- # Blockdiag Test
8
-
9
6
  ## Blockdiag
10
7
 
11
8
  {% blockdiag %}
@@ -0,0 +1,13 @@
1
+ ---
2
+ layout: home
3
+ title: Syntrax Test
4
+ ---
5
+
6
+ {% syntrax %}
7
+ indentstack(10,
8
+ line(opt('-'), choice('0', line('1-9', loop(None, '0-9'))),
9
+ opt('.', loop('0-9', None))),
10
+
11
+ line(opt(choice('e', 'E'), choice(None, '+', '-'), loop('0-9', None)))
12
+ )
13
+ {% endsyntrax %}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-diagrams
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhustec
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-29 00:00:00.000000000 Z
11
+ date: 2020-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -81,6 +81,7 @@ extra_rdoc_files: []
81
81
  files:
82
82
  - ".gitignore"
83
83
  - ".travis.yml"
84
+ - Dockerfile
84
85
  - Gemfile
85
86
  - LICENSE
86
87
  - README.md
@@ -92,23 +93,30 @@ files:
92
93
  - lib/jekyll-diagrams/erd.rb
93
94
  - lib/jekyll-diagrams/graphviz.rb
94
95
  - lib/jekyll-diagrams/mermaid.rb
96
+ - lib/jekyll-diagrams/nomnoml.rb
95
97
  - lib/jekyll-diagrams/plantuml.rb
96
98
  - lib/jekyll-diagrams/renderer.rb
97
99
  - lib/jekyll-diagrams/smcat.rb
100
+ - lib/jekyll-diagrams/svgbob.rb
98
101
  - lib/jekyll-diagrams/syntrax.rb
99
102
  - lib/jekyll-diagrams/util.rb
103
+ - lib/jekyll-diagrams/vega.rb
100
104
  - lib/jekyll-diagrams/version.rb
101
105
  - lib/jekyll-diagrams/wavedrom.rb
102
106
  - test/dummy_site/Gemfile
103
107
  - test/dummy_site/_config.yml
104
- - test/dummy_site/_posts/2020-01-01-graphviz-test.md
105
- - test/dummy_site/_posts/2020-01-02-blockdiag-test.md
106
- - test/dummy_site/_posts/2020-01-03-plantuml-test.md
107
- - test/dummy_site/_posts/2020-01-04-mermaid-test.md
108
- - test/dummy_site/_posts/2020-01-05-wavedrom-test.md
109
- - test/dummy_site/_posts/2020-01-06-smcat-test.md
110
- - test/dummy_site/_posts/2020-01-07-erd-test.md
108
+ - test/dummy_site/apt/graphviz.md
109
+ - test/dummy_site/cabal/erd.md
110
+ - test/dummy_site/cargo/svgbob.md
111
111
  - test/dummy_site/index.md
112
+ - test/dummy_site/java/plantuml.md
113
+ - test/dummy_site/npm/mermaid.md
114
+ - test/dummy_site/npm/nomnoml.md
115
+ - test/dummy_site/npm/smcat.md
116
+ - test/dummy_site/npm/vega.md
117
+ - test/dummy_site/npm/wavedrom.md
118
+ - test/dummy_site/pip/blockdiag.md
119
+ - test/dummy_site/pip/syntrax.md
112
120
  - test/test_helper.rb
113
121
  - vendor/mermaid_puppeteer_config.json
114
122
  - vendor/plantuml.1.2020.1.jar
@@ -131,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
139
  - !ruby/object:Gem::Version
132
140
  version: '0'
133
141
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 2.7.6.2
142
+ rubygems_version: 3.0.6
136
143
  signing_key:
137
144
  specification_version: 4
138
145
  summary: Jekyll plugins for diagrams support, including Graphviz, Blockdiag, PlantUML
@@ -140,12 +147,16 @@ summary: Jekyll plugins for diagrams support, including Graphviz, Blockdiag, Pla
140
147
  test_files:
141
148
  - test/dummy_site/Gemfile
142
149
  - test/dummy_site/_config.yml
143
- - test/dummy_site/_posts/2020-01-01-graphviz-test.md
144
- - test/dummy_site/_posts/2020-01-02-blockdiag-test.md
145
- - test/dummy_site/_posts/2020-01-03-plantuml-test.md
146
- - test/dummy_site/_posts/2020-01-04-mermaid-test.md
147
- - test/dummy_site/_posts/2020-01-05-wavedrom-test.md
148
- - test/dummy_site/_posts/2020-01-06-smcat-test.md
149
- - test/dummy_site/_posts/2020-01-07-erd-test.md
150
+ - test/dummy_site/apt/graphviz.md
151
+ - test/dummy_site/cabal/erd.md
152
+ - test/dummy_site/cargo/svgbob.md
150
153
  - test/dummy_site/index.md
154
+ - test/dummy_site/java/plantuml.md
155
+ - test/dummy_site/npm/mermaid.md
156
+ - test/dummy_site/npm/nomnoml.md
157
+ - test/dummy_site/npm/smcat.md
158
+ - test/dummy_site/npm/vega.md
159
+ - test/dummy_site/npm/wavedrom.md
160
+ - test/dummy_site/pip/blockdiag.md
161
+ - test/dummy_site/pip/syntrax.md
151
162
  - test/test_helper.rb