jekyll-diagrams 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 939c351c21994ececde693c60b108ddd81d8fd98f3dacc11a7722b8972f294bf
4
- data.tar.gz: cb597bafa191ce822a239ab565718ae4efce683204bd45a39ed4e61f656e6b91
3
+ metadata.gz: 50b1e58e8ce58f22fef54776c2413abafc5ee1ee16b8ceecd84cf64b8bdfb25c
4
+ data.tar.gz: e440f946189747d473e4d0cca362a4732b7d1e2fcac94c91d8f0c63e1aaf416b
5
5
  SHA512:
6
- metadata.gz: f19c1dd680ffdd9f11af3ea082e38759d120b63d163ecd9bba19ab27cfd185c08eca82ee036ae9f675597ccd58db60eabecac8abb9d0dfdf7f78b312ecc1e6fa
7
- data.tar.gz: f6675947274f26d32558e06446ed3617fda8c183287aa54df9835df9446fccdcbb1d8eb7fa3126751ba70192f0e5de1b3b4362ccbf46fe4bb60eebe17a4130c4
6
+ metadata.gz: f62eab1353bd18378dc8b53ade153079fa4b9d99f032a81f5a7130fc15e86fb2727495eaff9e780d48fb8dfb4fc009c6d0d5ecdb1f226e65356da3546d7a615a
7
+ data.tar.gz: 48ab6a18cf4f93ac5ad50368674c2fb06a0b5ad134f51cadaa46355683751e79dad0e1edf8db60e2a66842c750a7352e49539842cd1ce826f8274be0dc943275
data/.travis.yml CHANGED
@@ -10,11 +10,15 @@ addons:
10
10
  apt:
11
11
  packages:
12
12
  - default-jre
13
+ - gnuplot
13
14
  - graphviz
15
+ - node
16
+ - npm
14
17
  - python3
15
18
  - python3-pip
16
19
  - python3-setuptools
17
20
 
18
21
  before_install:
19
22
  - sudo pip3 install blockdiag seqdiag actdiag nwdiag
20
- - gem update --system && gem install bundler
23
+ - gem update --system && gem install bundler
24
+ - npm install -g wavedrom-cli mermaid.cli
data/README.md CHANGED
@@ -1,15 +1,19 @@
1
1
  # Jekyll Diagrams
2
2
 
3
- [![Travis](https://img.shields.io/travis/zhustec/jekyll-diagrams.svg?style=flat-square)](https://travis-ci.com/zhustec/jekyll-diagrams)
4
3
  [![Gem](https://img.shields.io/gem/v/jekyll-diagrams.svg?style=flat-square)](https://rubygems.org/gems/jekyll-diagrams)
4
+ [![Travis](https://img.shields.io/travis/zhustec/jekyll-diagrams.svg?style=flat-square)](https://travis-ci.com/zhustec/jekyll-diagrams)
5
5
  [![Depfu](https://img.shields.io/depfu/zhustec/jekyll-diagrams.svg?style=flat-square)](https://depfu.com/repos/zhustec/jekyll-diagrams)
6
6
  [![license](https://img.shields.io/github/license/zhustec/jekyll-diagrams.svg?style=flat-square)](https://github.com/zhustec/jekyll-diagrams/blob/master/LICENSE)
7
7
 
8
8
  Jekyll Diagrams is a jekyll plugins for creating amazing diagrams, including:
9
9
 
10
+ - Blockdiag(Blockdia, Seqdiag, Actdiag, Nwdiag, Rackdiag and Packatdiag)
11
+ - Erd
10
12
  - Graphviz
11
- - Blockdiag, Seqdiag, Actdiag and Nwdiag
13
+ - Mermaid
12
14
  - PlantUML
15
+ - State Machine cat
16
+ - Syntrax
13
17
 
14
18
  ## Installation
15
19
 
@@ -44,47 +48,6 @@ plugins:
44
48
 
45
49
  ## Usage
46
50
 
47
- ### Graphviz
48
-
49
- You need first install graphviz with package manager on your system. Then you can use `graphviz` Liquid Tag to create amazing Graphviz images!
50
-
51
- ```text
52
- {% graphviz %}
53
- digraph {
54
- node [shape=circle, style=filled];
55
- S [fillcolor=green];
56
- A [fillcolor=yellow];
57
- B [fillcolor=yellow];
58
- C [fillcolor=yellow];
59
- D [shape=doublecircle, fillcolor=green];
60
- S -> A [label=a];
61
- S -> B [label=b];
62
- A -> D [label=c];
63
- B -> D [label=d];
64
- }
65
- {% endgraphviz %}
66
- ```
67
-
68
- #### Configuration
69
-
70
- A simple configuration example is shown below:
71
-
72
- ```yaml
73
- jekyll-diagrams:
74
- graphviz:
75
- default_layout: dot
76
- graph_attribute: color=red
77
- node_attribute:
78
- - color=blue
79
- - fillcolor=red
80
- edge_attribute:
81
- color: red
82
- fillcolor: blue
83
- ```
84
-
85
- - `default_layout`: Change the default layout here.
86
- - `graph/node/edge_attribute`: Default graph/node/edge attribute, can be String(when just one attribute), Array or Hash.
87
-
88
51
  ### Blockdiag
89
52
 
90
53
  Blockdiag contains:
@@ -96,7 +59,16 @@ Blockdiag contains:
96
59
  * `rackdiag` : generates rack structure diagram
97
60
  * `packetdiag` : generates packet header diagram
98
61
 
99
- You need first install it and set path properly to make sure your system can find it. Then you can use `blockdiag`, `seqdiag`, `actdiag`, `nwdiag`, `rackdiag`, `packetdiag` Liquid Tag.
62
+ #### Prerequisites
63
+
64
+ - Install it via pip or other methods
65
+ - Set path properly, make sure your system can find it
66
+
67
+ ```bash
68
+ $ pip install blockdiag seqdiag actiag nwdiag
69
+ ```
70
+
71
+ #### Examples
100
72
 
101
73
  ```text
102
74
  {% blockdiag %}
@@ -122,7 +94,7 @@ seqdiag {
122
94
  {% endseqdiag %}
123
95
  ```
124
96
 
125
- #### Configuration
97
+ #### Configurations
126
98
 
127
99
  ```yaml
128
100
  jekyll-diagrams:
@@ -134,8 +106,116 @@ jekyll-diagrams:
134
106
  size: 320x400
135
107
  ```
136
108
 
109
+ ### Erd
110
+
111
+ #### Prerequisites
112
+
113
+ - Install Graphviz
114
+ - [**Install Erd**](https://github.com/BurntSushi/erd#installation)
115
+
116
+ #### Examples
117
+
118
+ ```text
119
+ {% erd %}
120
+ [Person]
121
+ *name
122
+ height
123
+ weight
124
+ `birth date`
125
+ +birth_place_id
126
+
127
+ [`Birth Place`]
128
+ *id
129
+ `birth city`
130
+ 'birth state'
131
+ "birth country"
132
+
133
+ Person *--1 `Birth Place`
134
+ {% enderd %}
135
+ ```
136
+
137
+ #### Configurations
138
+
139
+ ```yaml
140
+ jekyll-diagrams:
141
+ erd:
142
+ config: path_to_config_file
143
+ edge: 'one type of edge: compound, noedge, ortho, poly, spline'
144
+ ```
145
+
146
+ ### Graphviz
147
+
148
+ #### Prerequisites
149
+
150
+ - Install it.
151
+
152
+ #### Examples
153
+
154
+ ```text
155
+ {% graphviz %}
156
+ digraph {
157
+ node [shape=circle, style=filled];
158
+ S [fillcolor=green];
159
+ A [fillcolor=yellow];
160
+ B [fillcolor=yellow];
161
+ C [fillcolor=yellow];
162
+ D [shape=doublecircle, fillcolor=green];
163
+ S -> A [label=a];
164
+ S -> B [label=b];
165
+ A -> D [label=c];
166
+ B -> D [label=d];
167
+ }
168
+ {% endgraphviz %}
169
+ ```
170
+
171
+ #### Configurations
172
+
173
+ ```yaml
174
+ jekyll-diagrams:
175
+ graphviz:
176
+ default_layout: dot
177
+ graph_attribute: color=red
178
+ node_attribute:
179
+ - color=blue
180
+ - fillcolor=red
181
+ edge_attribute:
182
+ color: red
183
+ fillcolor: blue
184
+ ```
185
+
186
+ - `default_layout`: Change the default layout here.
187
+ - `graph/node/edge_attribute`: Default graph/node/edge attribute, can be String(when just one attribute), Array or Hash.
188
+
189
+ ### Mermaid
190
+
191
+ #### Prerequisites
192
+
193
+ - [**Install mermaid.cli**](https://github.com/mermaidjs/mermaid.cli#mermaidcli)
194
+
195
+ #### Configurations
196
+
197
+ ```yaml
198
+ jekyll-diagrams:
199
+ mermaid:
200
+ theme: default,
201
+ width: 800,
202
+ height: 600,
203
+ backgroundColor: white
204
+ ```
205
+
206
+ - `theme`: Theme of the chart, could be default, forest, dark or neutral. (default: default)
207
+ - `width`: Width of the page. (default: 800)
208
+ - `height`: Height of the page. (default: 600)
209
+ - `backgroundColor`: Background color. Example: transparent, red, '#F0F0F0'. (default: white)
210
+
137
211
  ### PlantUML
138
212
 
213
+ #### Prerequisites
214
+
215
+ - Java Runtime
216
+
217
+ #### Examples
218
+
139
219
  ```text
140
220
  {% plantuml %}
141
221
  @startuml
@@ -149,6 +229,77 @@ Car -- Person : < owns
149
229
  {% endplantuml %}
150
230
  ```
151
231
 
232
+ ### State Machine cat
233
+
234
+ #### Prerequisites
235
+
236
+ - Nodejs Runtime
237
+ - Install it `npm install [-g] state-machine-cat`
238
+ - Set path
239
+
240
+ #### Examples
241
+
242
+ ```text
243
+ {% smcat %}
244
+ initial,
245
+ "tape player off",
246
+ "tape player on" {
247
+ stopped => playing : play;
248
+ playing => stopped : stop;
249
+ playing => paused : pause;
250
+ paused => playing : pause;
251
+ paused => stopped : stop;
252
+ };
253
+
254
+ initial => "tape player off";
255
+ "tape player off" => stopped : power;
256
+ "tape player on" => "tape player off" : power;
257
+ {% endsmcat %}
258
+ ```
259
+
260
+ #### Configuration
261
+
262
+ ```yaml
263
+ jekyll-diagrams:
264
+ smcat:
265
+ input-type: smcat
266
+ engine: dot
267
+ direction: top-down
268
+ ```
269
+
270
+ - `input-type`: smcat|scxml|json (default: "smcat")
271
+ - `engine`: dot|circo|fdp|neato|osage|twopi (default: "dot")
272
+ - `direction`: top-down|bottom-top|left-right|right-left (default: "top-down")
273
+
274
+ ### Syntrax
275
+
276
+ #### Prerequisites
277
+
278
+ - [Install it with Pango and PangoCairo](https://kevinpt.github.io/syntrax/#requirements)
279
+
280
+ #### Examples
281
+
282
+ ```text
283
+ {% syntrax %}
284
+ indentstack(10,
285
+ line(opt('-'), choice('0', line('1-9', loop(None, '0-9'))),
286
+ opt('.', loop('0-9', None))),
287
+
288
+ line(opt(choice('e', 'E'), choice(None, '+', '-'), loop('0-9', None)))
289
+ )
290
+ {% endsyntrax %}
291
+ ```
292
+
293
+ #### Configurations
294
+
295
+ ```yaml
296
+ jekyll-diagrams:
297
+ syntrax:
298
+ scale: 'Scale image'
299
+ style: 'Style config file'
300
+ transparent: 'Transparent background'
301
+ ```
302
+
152
303
  ## Contributing
153
304
 
154
305
  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.
@@ -17,7 +17,7 @@ module Jekyll
17
17
  end
18
18
 
19
19
  def wrap_class(content)
20
- "<div class='diagrams #{block_name}'>#{content}</div>"
20
+ "<div class='jekyll-diagrams diagrams #{block_name}'>#{content}</div>"
21
21
  end
22
22
  end
23
23
  end
@@ -7,7 +7,7 @@ module Jekyll
7
7
  def render_svg(code, config)
8
8
  command = build_command(config)
9
9
 
10
- render_with_tempfile(command, code, :svg) do |command, input, output|
10
+ render_with_tempfile(command, code) do |command, input, output|
11
11
  "#{command} #{input} -o #{output}"
12
12
  end
13
13
  end
@@ -18,16 +18,10 @@ module Jekyll
18
18
 
19
19
  def build_command(config)
20
20
  command = "#{block_name} -Tsvg --nodoctype"
21
+ command << ' --antialias' if config.has_key?('antialias')
21
22
 
22
- antialias = config.fetch('antialias', false)
23
-
24
- if antialias && antialias != 'false'
25
- command << ' --antialias'
26
- end
27
-
28
- %w(config font fontmap size).each do |key|
29
- value = config.fetch(key, nil)
30
- command << " --#{key}=#{value}" if value
23
+ %w(config font fontmap size).each do |conf|
24
+ command << " --#{conf}=#{config[conf]}" if config.has_key?(conf)
31
25
  end
32
26
 
33
27
  command
@@ -0,0 +1,21 @@
1
+ module Jekyll
2
+ module Diagrams
3
+ class ErdBlock < Block
4
+ def render_svg(code, config)
5
+ render_with_stdin_stdout(build_command(config), code)
6
+ end
7
+
8
+ def build_command(config)
9
+ command = 'erd --fmt=svg'
10
+
11
+ %w(config edge).each do |conf|
12
+ command << " --#{conf}=#{config[conf]}" if config.has_key?(conf)
13
+ end
14
+
15
+ command
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ Liquid::Template.register_tag(:erb, Jekyll::Diagrams::ErdBlock)
@@ -0,0 +1,31 @@
1
+ module Jekyll
2
+ module Diagrams
3
+ class MermaidBlock < Block
4
+ CONFIGURATIONS = {
5
+ 'theme' => 'default',
6
+ 'width' => 800,
7
+ 'height' => 600,
8
+ 'backgroundColor' => 'white'
9
+ }.freeze
10
+
11
+ def render_svg(code, config)
12
+ render_with_tempfile(build_command(config), code) do |command, input, output|
13
+ "#{command} --input #{input} --output #{output}"
14
+ end
15
+ end
16
+
17
+ def build_command(config)
18
+ command = 'mmdc'
19
+ command << ' --transparent' if config.has_key?('transparent')
20
+
21
+ CONFIGURATIONS.merge(config).each do |conf, value|
22
+ command << " --#{conf} #{value}"
23
+ end
24
+
25
+ command
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ Liquid::Template.register_tag(:mermaid, Jekyll::Diagrams::MermaidBlock)
@@ -10,8 +10,8 @@ module Jekyll
10
10
  render_with_command(command, :stdout, stdin_data: content, binmode: true)
11
11
  end
12
12
 
13
- def render_with_stdin(command, content, format)
14
- Tempfile.open(['jekyll_diagrams_output', ".#{format}"]) do |output|
13
+ def render_with_stdin(command, content)
14
+ Tempfile.open(['jekyll_diagrams_output', ".svg"]) do |output|
15
15
  output.close
16
16
  command = yield command, output.path
17
17
 
@@ -19,11 +19,11 @@ module Jekyll
19
19
  end
20
20
  end
21
21
 
22
- def render_with_tempfile(command, content, format)
22
+ def render_with_tempfile(command, content)
23
23
  Tempfile.open('jekyll_diagrams_input') do |input|
24
24
  File.write(input.path, content)
25
25
 
26
- Tempfile.open(['jekyll_diagrams_output', ".#{format}"]) do |output|
26
+ Tempfile.open(['jekyll_diagrams_output', ".svg"]) do |output|
27
27
  output.close
28
28
  command = yield command, input.path, output.path
29
29
 
@@ -0,0 +1,31 @@
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
9
+
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
14
+
15
+ svg.sub!(/^<\?xml(([^>]|\n)*>\n?){4}/, '')
16
+ end
17
+
18
+ def build_command(config)
19
+ command = 'smcat'
20
+
21
+ CONFIGURATIONS.merge(config).each do |conf, value|
22
+ command << " --#{conf} #{value}"
23
+ end
24
+
25
+ command
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ Liquid::Template.register_tag(:smcat, Jekyll::Diagrams::SMCatBlock)
@@ -0,0 +1,23 @@
1
+ module Jekyll
2
+ module Diagrams
3
+ class SyntraxBlock < Block
4
+ def render_svg(code, config)
5
+ render_with_tempfile(build_command(config), code) do |command, input, output|
6
+ "#{command} --input #{input} --output #{output}"
7
+ end
8
+ end
9
+
10
+ def build_command(config)
11
+ command = 'syntrax'
12
+
13
+ %w(scale style).each do |conf|
14
+ command << " --#{conf} #{config[conf]}" if config.has_key?(conf)
15
+ end
16
+
17
+ command
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ Liquid::Template.register_tag(:syntrax, Jekyll::Diagrams::SyntraxBlock)
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Diagrams
3
- VERSION = '0.6.0'
3
+ VERSION = '0.7.0'
4
4
  end
5
5
  end
@@ -0,0 +1,17 @@
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'
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ Liquid::Template.register_tag(:wavedrom, Jekyll::Diagrams::WavedromBlock)
@@ -1,6 +1,11 @@
1
1
  require_relative 'jekyll-diagrams/util'
2
2
  require_relative 'jekyll-diagrams/renderer'
3
3
  require_relative 'jekyll-diagrams/block'
4
+
4
5
  require_relative 'jekyll-diagrams/blockdiag'
6
+ require_relative 'jekyll-diagrams/erd'
5
7
  require_relative 'jekyll-diagrams/graphviz'
6
- require_relative 'jekyll-diagrams/plantuml'
8
+ require_relative 'jekyll-diagrams/mermaid'
9
+ require_relative 'jekyll-diagrams/plantuml'
10
+ require_relative 'jekyll-diagrams/smcat'
11
+ require_relative 'jekyll-diagrams/wavedrom'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-diagrams
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhustec
@@ -89,11 +89,16 @@ files:
89
89
  - lib/jekyll-diagrams.rb
90
90
  - lib/jekyll-diagrams/block.rb
91
91
  - lib/jekyll-diagrams/blockdiag.rb
92
+ - lib/jekyll-diagrams/erd.rb
92
93
  - lib/jekyll-diagrams/graphviz.rb
94
+ - lib/jekyll-diagrams/mermaid.rb
93
95
  - lib/jekyll-diagrams/plantuml.rb
94
96
  - lib/jekyll-diagrams/renderer.rb
97
+ - lib/jekyll-diagrams/smcat.rb
98
+ - lib/jekyll-diagrams/syntrax.rb
95
99
  - lib/jekyll-diagrams/util.rb
96
100
  - lib/jekyll-diagrams/version.rb
101
+ - lib/jekyll-diagrams/wavedrom.rb
97
102
  - test/test_helper.rb
98
103
  - vendor/plantuml.1.2020.1.jar
99
104
  homepage: https://github.com/zhustec/jekyll-diagrams