asciidoctor-diagram 2.0.2 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +78 -1
  3. data/README.adoc +25 -507
  4. data/Rakefile +1 -1
  5. data/docs/antora.yml +3 -0
  6. data/{images → docs/modules/ROOT/images}/asciidoctor-diagram-classes.png +0 -0
  7. data/docs/modules/ROOT/images/asciidoctor-diagram-process.png +0 -0
  8. data/docs/modules/ROOT/pages/index.adoc +21 -0
  9. data/docs/modules/ROOT/partials/advanced.adoc +319 -0
  10. data/docs/modules/ROOT/partials/create_diagram.adoc +132 -0
  11. data/docs/modules/ROOT/partials/generate.adoc +15 -0
  12. data/docs/modules/ROOT/partials/installation.adoc +19 -0
  13. data/docs/modules/ROOT/partials/uris.adoc +40 -0
  14. data/examples/features.adoc +1 -1
  15. data/lib/asciidoctor-diagram.rb +4 -0
  16. data/lib/asciidoctor-diagram/a2s/converter.rb +10 -6
  17. data/lib/asciidoctor-diagram/blockdiag/converter.rb +1 -1
  18. data/lib/asciidoctor-diagram/bpmn/converter.rb +3 -3
  19. data/lib/asciidoctor-diagram/diagram_converter.rb +9 -1
  20. data/lib/asciidoctor-diagram/diagram_processor.rb +92 -48
  21. data/lib/asciidoctor-diagram/diagram_source.rb +71 -24
  22. data/lib/asciidoctor-diagram/diagrams.rb +7 -0
  23. data/lib/asciidoctor-diagram/diagrams/converter.rb +49 -0
  24. data/lib/asciidoctor-diagram/diagrams/extension.rb +14 -0
  25. data/lib/asciidoctor-diagram/ditaa/converter.rb +20 -7
  26. data/lib/asciidoctor-diagram/ditaa/ditaa-1.3.20.jar +0 -0
  27. data/lib/asciidoctor-diagram/dpic.rb +7 -0
  28. data/lib/asciidoctor-diagram/dpic/converter.rb +30 -0
  29. data/lib/asciidoctor-diagram/dpic/extension.rb +14 -0
  30. data/lib/asciidoctor-diagram/gnuplot/converter.rb +8 -8
  31. data/lib/asciidoctor-diagram/graphviz/converter.rb +2 -2
  32. data/lib/asciidoctor-diagram/http/converter.rb +52 -14
  33. data/lib/asciidoctor-diagram/http/server.rb +11 -6
  34. data/lib/asciidoctor-diagram/lilypond/converter.rb +13 -3
  35. data/lib/asciidoctor-diagram/meme/converter.rb +22 -16
  36. data/lib/asciidoctor-diagram/mermaid/converter.rb +45 -14
  37. data/lib/asciidoctor-diagram/msc/converter.rb +2 -2
  38. data/lib/asciidoctor-diagram/pikchr.rb +7 -0
  39. data/lib/asciidoctor-diagram/pikchr/converter.rb +33 -0
  40. data/lib/asciidoctor-diagram/pikchr/extension.rb +14 -0
  41. data/lib/asciidoctor-diagram/plantuml/converter.rb +68 -43
  42. data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.20.jar +0 -0
  43. data/lib/asciidoctor-diagram/smcat/converter.rb +3 -3
  44. data/lib/asciidoctor-diagram/svgbob/converter.rb +6 -2
  45. data/lib/asciidoctor-diagram/symbolator.rb +7 -0
  46. data/lib/asciidoctor-diagram/symbolator/converter.rb +23 -0
  47. data/lib/asciidoctor-diagram/symbolator/extension.rb +14 -0
  48. data/lib/asciidoctor-diagram/syntrax/converter.rb +9 -6
  49. data/lib/asciidoctor-diagram/tikz/converter.rb +20 -1
  50. data/lib/asciidoctor-diagram/umlet/converter.rb +11 -2
  51. data/lib/asciidoctor-diagram/util/cli.rb +16 -1
  52. data/lib/asciidoctor-diagram/util/cli_generator.rb +30 -8
  53. data/lib/asciidoctor-diagram/util/gif.rb +2 -2
  54. data/lib/asciidoctor-diagram/util/java.rb +118 -3
  55. data/lib/asciidoctor-diagram/util/java_jruby.rb +4 -1
  56. data/lib/asciidoctor-diagram/util/java_socket.rb +8 -109
  57. data/lib/asciidoctor-diagram/util/pdf.rb +2 -2
  58. data/lib/asciidoctor-diagram/util/png.rb +2 -2
  59. data/lib/{server-1.3.15.jar → asciidoctor-diagram/util/server-1.3.20.jar} +0 -0
  60. data/lib/asciidoctor-diagram/util/svg.rb +66 -18
  61. data/lib/asciidoctor-diagram/vega/converter.rb +2 -2
  62. data/lib/asciidoctor-diagram/version.rb +1 -1
  63. data/spec/a2s_spec.rb +6 -144
  64. data/spec/blockdiag_spec.rb +6 -204
  65. data/spec/bpmn_spec.rb +52 -92
  66. data/spec/bytefield_spec.rb +6 -144
  67. data/spec/diagrams_spec.rb +23 -0
  68. data/spec/ditaa_spec.rb +6 -144
  69. data/spec/dpic_spec.rb +19 -0
  70. data/spec/erd_spec.rb +6 -203
  71. data/spec/gnuplot_spec.rb +10 -263
  72. data/spec/graphviz_spec.rb +6 -145
  73. data/spec/lilypond_spec.rb +6 -144
  74. data/spec/mermaid_spec.rb +69 -211
  75. data/spec/msc_spec.rb +6 -203
  76. data/spec/nomnoml_spec.rb +7 -145
  77. data/spec/pikchr_spec.rb +69 -0
  78. data/spec/plantuml_spec.rb +63 -553
  79. data/spec/shaape_spec.rb +12 -224
  80. data/spec/shared_examples.rb +603 -0
  81. data/spec/smcat_spec.rb +6 -144
  82. data/spec/svgbob_spec.rb +6 -144
  83. data/spec/symbolator_spec.rb +23 -0
  84. data/spec/syntrax_spec.rb +7 -217
  85. data/spec/test_helper.rb +4 -29
  86. data/spec/tikz_spec.rb +68 -18
  87. data/spec/umlet_spec.rb +3 -59
  88. data/spec/vega_spec.rb +6 -119
  89. data/spec/wavedrom_spec.rb +3 -200
  90. metadata +82 -18
  91. data/README_zh-CN.adoc +0 -336
  92. data/images/asciidoctor-diagram-process.png +0 -0
  93. data/lib/batik-all-1.10.jar +0 -0
  94. data/lib/ditaa-1.3.15.jar +0 -0
  95. data/lib/ditaamini-0.12.jar +0 -0
  96. data/lib/jlatexmath-minimal-1.0.5.jar +0 -0
  97. data/lib/plantuml-1.3.15.jar +0 -0
  98. data/lib/plantuml.jar +0 -0
  99. data/spec/bpmn-example.xml +0 -44
data/spec/msc_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- code = <<-eos
3
+ MSC_CODE = <<-eos
4
4
  # MSC for some fictional process
5
5
  msc {
6
6
  hscale = "2";
@@ -24,207 +24,10 @@ msc {
24
24
  }
25
25
  eos
26
26
 
27
- describe Asciidoctor::Diagram::MscBlockMacroProcessor, :broken_on_windows do
28
- it "should generate PNG images when format is set to 'png'" do
29
- File.write('msc.txt', code)
30
-
31
- doc = <<-eos
32
- = Hello, Msc!
33
- Doc Writer <doc@example.com>
34
-
35
- == First Section
36
-
37
- msc::msc.txt[format="png"]
38
- eos
39
-
40
- d = load_asciidoc doc
41
- expect(d).to_not be_nil
42
-
43
- b = d.find { |bl| bl.context == :image }
44
- expect(b).to_not be_nil
45
-
46
- expect(b.content_model).to eq :empty
47
-
48
- target = b.attributes['target']
49
- expect(target).to_not be_nil
50
- expect(target).to match(/\.png$/)
51
- expect(File.exist?(target)).to be true
52
-
53
- expect(b.attributes['width']).to_not be_nil
54
- expect(b.attributes['height']).to_not be_nil
55
- end
56
-
57
- it "should generate SVG images when format is set to 'svg'" do
58
- File.write('msc.txt', code)
59
-
60
- doc = <<-eos
61
- = Hello, Msc!
62
- Doc Writer <doc@example.com>
63
-
64
- == First Section
65
-
66
- msc::msc.txt[format="svg"]
67
- eos
68
-
69
- d = load_asciidoc doc
70
- expect(d).to_not be_nil
71
-
72
- b = d.find { |bl| bl.context == :image }
73
- expect(b).to_not be_nil
74
-
75
- expect(b.content_model).to eq :empty
76
-
77
- target = b.attributes['target']
78
- expect(target).to_not be_nil
79
- expect(target).to match(/\.svg/)
80
- expect(File.exist?(target)).to be true
81
-
82
- expect(b.attributes['width']).to_not be_nil
83
- expect(b.attributes['height']).to_not be_nil
84
- end
27
+ describe Asciidoctor::Diagram::MscBlockMacroProcessor do
28
+ include_examples "block_macro", :msc, MSC_CODE, [:png, :svg]
85
29
  end
86
30
 
87
- describe Asciidoctor::Diagram::MscBlockProcessor, :broken_on_windows do
88
- it "should generate PNG images when format is set to 'png'" do
89
- doc = <<-eos
90
- = Hello, Msc!
91
- Doc Writer <doc@example.com>
92
-
93
- == First Section
94
-
95
- [msc, format="png"]
96
- ----
97
- #{code}
98
- ----
99
- eos
100
-
101
- d = load_asciidoc doc
102
- expect(d).to_not be_nil
103
-
104
- b = d.find { |bl| bl.context == :image }
105
- expect(b).to_not be_nil
106
-
107
- expect(b.content_model).to eq :empty
108
-
109
- target = b.attributes['target']
110
- expect(target).to_not be_nil
111
- expect(target).to match(/\.png$/)
112
- expect(File.exist?(target)).to be true
113
-
114
- expect(b.attributes['width']).to_not be_nil
115
- expect(b.attributes['height']).to_not be_nil
116
- end
117
-
118
- it "should generate SVG images when format is set to 'svg'" do
119
- doc = <<-eos
120
- = Hello, Msc!
121
- Doc Writer <doc@example.com>
122
-
123
- == First Section
124
-
125
- [msc, format="svg"]
126
- ----
127
- #{code}
128
- ----
129
- eos
130
-
131
- d = load_asciidoc doc
132
- expect(d).to_not be_nil
133
-
134
- b = d.find { |bl| bl.context == :image }
135
- expect(b).to_not be_nil
136
-
137
- expect(b.content_model).to eq :empty
138
-
139
- target = b.attributes['target']
140
- expect(target).to_not be_nil
141
- expect(target).to match(/\.svg/)
142
- expect(File.exist?(target)).to be true
143
-
144
- expect(b.attributes['width']).to_not be_nil
145
- expect(b.attributes['height']).to_not be_nil
146
- end
147
-
148
- it "should raise an error when when format is set to an invalid value" do
149
- doc = <<-eos
150
- = Hello, Msc!
151
- Doc Writer <doc@example.com>
152
-
153
- == First Section
154
-
155
- [msc, format="foobar"]
156
- ----
157
- ----
158
- eos
159
-
160
- expect { load_asciidoc doc }.to raise_error(/support.*format/i)
161
- end
162
-
163
- it "should not regenerate images when source has not changed" do
164
- File.write('msc.txt', code)
165
-
166
- doc = <<-eos
167
- = Hello, Msc!
168
- Doc Writer <doc@example.com>
169
-
170
- == First Section
171
-
172
- msc::msc.txt
173
-
174
- [msc, format="png"]
175
- ----
176
- #{code}
177
- ----
178
- eos
179
-
180
- d = load_asciidoc doc
181
- b = d.find { |bl| bl.context == :image }
182
- expect(b).to_not be_nil
183
- target = b.attributes['target']
184
- mtime1 = File.mtime(target)
185
-
186
- sleep 1
187
-
188
- d = load_asciidoc doc
189
-
190
- mtime2 = File.mtime(target)
191
-
192
- expect(mtime2).to eq mtime1
193
- end
194
-
195
- it "should handle two block macros with the same source" do
196
- File.write('msc.txt', code)
197
-
198
- doc = <<-eos
199
- = Hello, Msc!
200
- Doc Writer <doc@example.com>
201
-
202
- == First Section
203
-
204
- msc::msc.txt[]
205
- msc::msc.txt[]
206
- eos
207
-
208
- load_asciidoc doc
209
- expect(File.exist?('msc.png')).to be true
210
- end
211
-
212
- it "should respect target attribute in block macros" do
213
- File.write('msc.txt', code)
214
-
215
- doc = <<-eos
216
- = Hello, Msc!
217
- Doc Writer <doc@example.com>
218
-
219
- == First Section
220
-
221
- msc::msc.txt["foobar"]
222
- msc::msc.txt["foobaz"]
223
- eos
224
-
225
- load_asciidoc doc
226
- expect(File.exist?('foobar.png')).to be true
227
- expect(File.exist?('foobaz.png')).to be true
228
- expect(File.exist?('msc.png')).to be false
229
- end
230
- end
31
+ describe Asciidoctor::Diagram::MscBlockProcessor do
32
+ include_examples "block", :msc, MSC_CODE, [:png, :svg]
33
+ end
data/spec/nomnoml_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- code = <<-eos
4
- [Pirate|eyeCount: Int|raid();pillage()|
3
+ NOMNOML_CODE = <<-eos
4
+ [Pirate
5
5
  [beard]--[parrot]
6
6
  [beard]-:>[foul mouth]
7
7
  ]
@@ -11,7 +11,7 @@ code = <<-eos
11
11
  [jollyness]->[Pirate]
12
12
  [jollyness]->[rum]
13
13
  [jollyness]->[singing]
14
- [Pirate]-> *[rum|tastiness: Int|swig()]
14
+ [Pirate]-> *[rum]
15
15
  [Pirate]->[singing]
16
16
  [singing]<->[rum]
17
17
 
@@ -24,147 +24,9 @@ code = <<-eos
24
24
  eos
25
25
 
26
26
  describe Asciidoctor::Diagram::NomnomlBlockMacroProcessor do
27
- it "should generate SVG images when format is set to 'svg'" do
28
- File.write('nomnoml.txt', code)
29
-
30
- doc = <<-eos
31
- = Hello, Nomnoml!
32
- Doc Writer <doc@example.com>
33
-
34
- == First Section
35
-
36
- nomnoml::nomnoml.txt[format="svg"]
37
- eos
38
-
39
- d = load_asciidoc doc
40
- expect(d).to_not be_nil
41
-
42
- b = d.find { |bl| bl.context == :image }
43
- expect(b).to_not be_nil
44
-
45
- expect(b.content_model).to eq :empty
46
-
47
- target = b.attributes['target']
48
- expect(target).to_not be_nil
49
- expect(target).to match(/\.svg/)
50
- expect(File.exist?(target)).to be true
51
-
52
- expect(b.attributes['width']).to_not be_nil
53
- expect(b.attributes['height']).to_not be_nil
54
- end
27
+ include_examples "block_macro", :nomnoml, NOMNOML_CODE, [:svg]
55
28
  end
56
29
 
57
- describe Asciidoctor::Diagram::NomnomlBlockProcessor, :broken_on_windows do
58
- it "should generate SVG images when format is set to 'svg'" do
59
- doc = <<-eos
60
- = Hello, Nomnoml!
61
- Doc Writer <doc@example.com>
62
-
63
- == First Section
64
-
65
- [nomnoml, format="svg"]
66
- ----
67
- #{code}
68
- ----
69
- eos
70
-
71
- d = load_asciidoc doc
72
- expect(d).to_not be_nil
73
-
74
- b = d.find { |bl| bl.context == :image }
75
- expect(b).to_not be_nil
76
-
77
- expect(b.content_model).to eq :empty
78
-
79
- target = b.attributes['target']
80
- expect(target).to_not be_nil
81
- expect(target).to match(/\.svg/)
82
- expect(File.exist?(target)).to be true
83
-
84
- expect(b.attributes['width']).to_not be_nil
85
- expect(b.attributes['height']).to_not be_nil
86
- end
87
-
88
- it "should raise an error when when format is set to an invalid value" do
89
- doc = <<-eos
90
- = Hello, Nomnoml!
91
- Doc Writer <doc@example.com>
92
-
93
- == First Section
94
-
95
- [nomnoml, format="foobar"]
96
- ----
97
- ----
98
- eos
99
-
100
- expect { load_asciidoc doc }.to raise_error(/support.*format/i)
101
- end
102
-
103
- it "should not regenerate images when source has not changed" do
104
- File.write('nomnoml.txt', code)
105
-
106
- doc = <<-eos
107
- = Hello, Nomnoml!
108
- Doc Writer <doc@example.com>
109
-
110
- == First Section
111
-
112
- nomnoml::nomnoml.txt
113
-
114
- [nomnoml, format="svg"]
115
- ----
116
- #{code}
117
- ----
118
- eos
119
-
120
- d = load_asciidoc doc
121
- b = d.find { |bl| bl.context == :image }
122
- expect(b).to_not be_nil
123
- target = b.attributes['target']
124
- mtime1 = File.mtime(target)
125
-
126
- sleep 1
127
-
128
- d = load_asciidoc doc
129
-
130
- mtime2 = File.mtime(target)
131
-
132
- expect(mtime2).to eq mtime1
133
- end
134
-
135
- it "should handle two block macros with the same source" do
136
- File.write('nomnoml.txt', code)
137
-
138
- doc = <<-eos
139
- = Hello, Nomnoml!
140
- Doc Writer <doc@example.com>
141
-
142
- == First Section
143
-
144
- nomnoml::nomnoml.txt[]
145
- nomnoml::nomnoml.txt[]
146
- eos
147
-
148
- load_asciidoc doc
149
- expect(File.exist?('nomnoml.svg')).to be true
150
- end
151
-
152
- it "should respect target attribute in block macros" do
153
- File.write('nomnoml.txt', code)
154
-
155
- doc = <<-eos
156
- = Hello, Nomnoml!
157
- Doc Writer <doc@example.com>
158
-
159
- == First Section
160
-
161
- nomnoml::nomnoml.txt["foobar"]
162
- nomnoml::nomnoml.txt["foobaz"]
163
- eos
164
-
165
- load_asciidoc doc
166
- expect(File.exist?('foobar.svg')).to be true
167
- expect(File.exist?('foobaz.svg')).to be true
168
- expect(File.exist?('nomnoml.svg')).to be false
169
- end
170
- end
30
+ describe Asciidoctor::Diagram::NomnomlBlockProcessor do
31
+ include_examples "block", :nomnoml, NOMNOML_CODE, [:svg]
32
+ end
@@ -0,0 +1,69 @@
1
+ require_relative 'test_helper'
2
+
3
+ PIKCHR_CODE = <<-eos
4
+ # Change from the original:
5
+ # * Expand the macro by hand, as Pikchr does not support
6
+ # macros
7
+ #
8
+ #define ndblock {
9
+ # box wid boxwid/2 ht boxht/2
10
+ # down; box same with .t at bottom of last box; box same
11
+ #}
12
+ boxht = .2; boxwid = .3; circlerad = .3; dx = 0.05
13
+ down; box; box; box; box ht 3*boxht "." "." "."
14
+ L: box; box; box invis wid 2*boxwid "hashtab:" with .e at 1st box .w
15
+ right
16
+ Start: box wid .5 with .sw at 1st box.ne + (.4,.2) "..."
17
+ N1: box wid .2 "n1"; D1: box wid .3 "d1"
18
+ N3: box wid .4 "n3"; D3: box wid .3 "d3"
19
+ box wid .4 "..."
20
+ N2: box wid .5 "n2"; D2: box wid .2 "d2"
21
+ arrow right from 2nd box
22
+ #ndblock
23
+ box wid boxwid/2 ht boxht/2
24
+ down; box same with .t at bottom of last box; box same
25
+ spline -> right .2 from 3rd last box then to N1.sw + (dx,0)
26
+ spline -> right .3 from 2nd last box then to D1.sw + (dx,0)
27
+ arrow right from last box
28
+ #ndblock
29
+ box wid boxwid/2 ht boxht/2
30
+ down; box same with .t at bottom of last box; box same
31
+ spline -> right .2 from 3rd last box to N2.sw-(dx,.2) to N2.sw+(dx,0)
32
+ spline -> right .3 from 2nd last box to D2.sw-(dx,.2) to D2.sw+(dx,0)
33
+ arrow right 2*linewid from L
34
+ #ndblock
35
+ box wid boxwid/2 ht boxht/2
36
+ down; box same with .t at bottom of last box; box same
37
+ spline -> right .2 from 3rd last box to N3.sw + (dx,0)
38
+ spline -> right .3 from 2nd last box to D3.sw + (dx,0)
39
+ circlerad = .3
40
+ circle invis "ndblock" at last box.e + (1.2,.2)
41
+ arrow dashed from last circle.w to 5/8<last circle.w,2nd last box> chop
42
+ box invis wid 2*boxwid "ndtable:" with .e at Start.w
43
+ eos
44
+
45
+ describe Asciidoctor::Diagram::PikchrBlockMacroProcessor, :broken_on_windows do
46
+ include_examples "block_macro", :pikchr, PIKCHR_CODE, [:svg]
47
+ end
48
+
49
+ describe Asciidoctor::Diagram::PikchrBlockProcessor, :broken_on_windows do
50
+ include_examples "block", :pikchr, PIKCHR_CODE, [:svg]
51
+
52
+ it "should report syntax errors" do
53
+ doc = <<-eos
54
+ = Hello, Pikchr!
55
+ Doc Writer <doc@example.com>
56
+
57
+ == First Section
58
+
59
+ [pikchr]
60
+ ----
61
+ This should raise a syntax error.
62
+ ----
63
+ eos
64
+
65
+ expect {
66
+ load_asciidoc doc
67
+ }.to raise_error(/error/i)
68
+ end
69
+ end