asciidoctor-diagram 1.5.3 → 1.5.4

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
  SHA1:
3
- metadata.gz: ed682b9f1a5ebc023f78291b9cb575ab954a7c98
4
- data.tar.gz: fb35b25a74669f7eb1540a2733b7c667ba0f2859
3
+ metadata.gz: d38f932148312e67e4249a2c171c71da2c796a49
4
+ data.tar.gz: c50317e4443b383f73be0b3e068364185cba7a97
5
5
  SHA512:
6
- metadata.gz: 29d512423d17e0cd4bb3c6f4ef21816e5716ad07e11df2059961c50a667d15a963521f6fe24b5702852d2610fededad4ab4b699aab5be52efed428e507deff6a
7
- data.tar.gz: 21829e5be06344ea24a6a48c43968d71a8c2f51c4828acaf456b97d04f80141a2fc83cb731829dfdf7ef52682966c6b30891e5d9f823fcdc4f23558302339b95
6
+ metadata.gz: 9d8544bb90e946c5b20b9e675268e519cf52f9dd89a3b054b4214a9c1b3dff59d6ce9683569616c3ed9d81441dc089179cb559e1569b1c11e4d586f99d457a41
7
+ data.tar.gz: d26cbf53122d923276a543f49efe434ba8690fbb85ba0e44ced6c52bd4c24779fb110bcef1c3f03c29f5b731dfc15c4a30c06d78516742987815c70a6d6886ab
@@ -1,5 +1,16 @@
1
1
  = Asciidoctor-diagram Changelog
2
2
 
3
+ == 1.5.4
4
+
5
+ Enhancements::
6
+
7
+ * Add support for UMLet.
8
+ * Issue #141: Allow blockdiag fontpath to be specified via attributes
9
+
10
+ Bug Fixes::
11
+
12
+ * Issue #140: Restore PNG as default format for Graphviz diagrams
13
+
3
14
  == 1.5.3
4
15
 
5
16
  Enhancements::
@@ -32,6 +32,7 @@ ifndef::env-site[:status:]
32
32
  :uri-rackdiag: http://blockdiag.com/en/nwdiag/index.html
33
33
  :uri-seqdiag: http://blockdiag.com/en/seqdiag/index.html
34
34
  :uri-shaape: https://github.com/christiangoltz/shaape
35
+ :uri-umlet: http://www.umlet.com/
35
36
  :uri-wavedrom: http://wavedrom.com
36
37
  :uri-wavedromeditor: https://github.com/wavedrom/wavedrom.github.io/releases
37
38
  :uri-wavedromcli: https://github.com/wavedrom/cli
@@ -119,6 +120,7 @@ The following diagram types and output formats are available:
119
120
  |{uri-rackdiag}[rackdiag] | |{check}|{check}|{check}|
120
121
  |{uri-seqdiag}[seqdiag] | |{check}|{check}|{check}|
121
122
  |{uri-shaape}[shaape] | | |{check}|{check}|
123
+ |{uri-umlet}[umlet] |{check}|{check}|{check}|{check}|
122
124
  |{uri-wavedrom}[wavedrom] | | |{check}|{check}|
123
125
  |===
124
126
 
@@ -287,6 +289,7 @@ The following table lists the tools that are required for each diagram type, the
287
289
  |rackdiag |{uri-nwdiag}[NwDiag] |`rackdiag`
288
290
  |seqdiag |{uri-seqdiag}[SeqDiag] |`seqdiag`
289
291
  |shaape |{uri-shaape}[Shaape] |`shaape`
292
+ |umlet |{uri-umlet}[Umlet] |`umlet`
290
293
  .2+|wavedrom |{uri-wavedromeditor}[WaveDrom Editor] |`wavedrom`
291
294
  |{uri-wavedromcli}[WaveDrom CLI] and {uri-phantomjs}[PhantomJS] |`wavedrom` and `phantomjs`
292
295
  |===
@@ -312,6 +315,36 @@ Occurrences of `\\` surrounded by whitespace are interpreted as line breaks.
312
315
  === Diagram Attributes
313
316
 
314
317
  Certain diagram types allow image generation to be customized using attributes.
318
+ Each attribute can be specified either at the block level or at the document level.
319
+ This is illustrated for the blockdiag `fontpath` attribute in the example below.
320
+
321
+ ----
322
+ = Asciidoctor Diagram
323
+ :blockdiag-fontpath: /path/to/font.ttf <1>
324
+
325
+ [blockdiag] <2>
326
+ ....
327
+ ....
328
+
329
+ [blockdiag, fontpath="/path/to/otherfont.ttf"] <3>
330
+ ....
331
+ ....
332
+ ----
333
+ <1> Block level attributes can be specified at the document level by prefixing them with `<blocktype>-`
334
+ <2> The first diagram does not specify an explicit value for `fontpath` so the global value will be used
335
+ <3> The second diagram specifies a `fontpath` value which overrrides the global value
336
+
337
+ Each attribute can either be specified at the block level or at the document level.
338
+ The attribute name at the block level should be prefixed with the name of the diagram type and a dash.
339
+
340
+
341
+ ==== Blockdiag
342
+
343
+ [cols=">,<,<",options="header"]
344
+ |===
345
+ |Name |Default value |Description
346
+ |fontpath |unspecified |The path to the font that should be used by blockdiag
347
+ |===
315
348
 
316
349
  ==== Ditaa
317
350
 
@@ -7,4 +7,5 @@ require_relative 'asciidoctor-diagram/mermaid'
7
7
  require_relative 'asciidoctor-diagram/plantuml'
8
8
  require_relative 'asciidoctor-diagram/salt'
9
9
  require_relative 'asciidoctor-diagram/shaape'
10
+ require_relative 'asciidoctor-diagram/umlet'
10
11
  require_relative 'asciidoctor-diagram/wavedrom'
@@ -106,8 +106,13 @@ module Asciidoctor
106
106
  # a '3' suffix.
107
107
  alt_cmd_name = "#{tool.downcase}3"
108
108
 
109
+ font_path = source.attr('fontpath', nil, tool.downcase)
110
+
109
111
  generate_stdin(which(parent, cmd_name, :alt_cmds => [alt_cmd_name]), format.to_s, source.to_s) do |tool_path, output_path|
110
- [tool_path, '-a', '-o', Platform.native_path(output_path), "-T#{format.to_s}", '-']
112
+ args = [tool_path, '-a', '-o', Platform.native_path(output_path), "-T#{format.to_s}"]
113
+ args << "-f#{Platform.native_path(font_path)}" if font_path
114
+ args << '-'
115
+ args
111
116
  end
112
117
  end
113
118
  end
@@ -11,7 +11,7 @@ module Asciidoctor
11
11
  include Which
12
12
 
13
13
  def self.included(mod)
14
- [:pdf, :png, :svg].each do |f|
14
+ [:png, :pdf, :svg].each do |f|
15
15
  mod.register_format(f, :image) do |parent, source|
16
16
  graphviz(parent, source, f)
17
17
  end
@@ -0,0 +1,8 @@
1
+ require_relative 'extensions'
2
+
3
+ Asciidoctor::Extensions.register do
4
+ require_relative 'umlet/extension'
5
+
6
+ block Asciidoctor::Diagram::UmletBlockProcessor, :umlet
7
+ block_macro Asciidoctor::Diagram::UmletBlockMacroProcessor, :umlet
8
+ end
@@ -0,0 +1,36 @@
1
+ require_relative '../extensions'
2
+ require_relative '../util/cli_generator'
3
+ require_relative '../util/platform'
4
+ require_relative '../util/which'
5
+
6
+ module Asciidoctor
7
+ module Diagram
8
+ # @private
9
+ module Umlet
10
+ include CliGenerator
11
+ include Which
12
+
13
+ def self.included(mod)
14
+ [:svg, :png, :pdf, :gif].each do |f|
15
+ mod.register_format(f, :image) do |parent, source|
16
+ umlet(parent, source, f)
17
+ end
18
+ end
19
+ end
20
+
21
+ def umlet(parent, source, format)
22
+ generate_file(which(parent, 'umlet'), 'uxf', format.to_s, source.to_s) do |tool_path, input_path, output_path|
23
+ [tool_path, '-action=convert', "-format=#{format.to_s}", "-filename=#{Platform.native_path(input_path)}", "-output=#{Platform.native_path(output_path)}"]
24
+ end
25
+ end
26
+ end
27
+
28
+ class UmletBlockProcessor < Extensions::DiagramBlockProcessor
29
+ include Umlet
30
+ end
31
+
32
+ class UmletBlockMacroProcessor < Extensions::DiagramBlockMacroProcessor
33
+ include Umlet
34
+ end
35
+ end
36
+ end
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Diagram
3
- VERSION = "1.5.3"
3
+ VERSION = "1.5.4"
4
4
  end
5
5
  end
@@ -14,6 +14,7 @@ require_relative '../lib/asciidoctor-diagram/meme/extension'
14
14
  require_relative '../lib/asciidoctor-diagram/mermaid/extension'
15
15
  require_relative '../lib/asciidoctor-diagram/plantuml/extension'
16
16
  require_relative '../lib/asciidoctor-diagram/shaape/extension'
17
+ require_relative '../lib/asciidoctor-diagram/umlet/extension'
17
18
  require_relative '../lib/asciidoctor-diagram/wavedrom/extension'
18
19
 
19
20
  require_relative '../lib/asciidoctor-diagram/util/platform'
@@ -42,9 +43,24 @@ module Asciidoctor
42
43
  options = options.dup
43
44
  options[:trace] = true
44
45
  options[:attributes] ||= {}
46
+
45
47
  options[:attributes]['phantomjs_19'] = ENV['PHANTOMJS_19']
48
+
46
49
  options[:attributes]['phantomjs_2'] = ENV['PHANTOMJS_2']
50
+
51
+ fontpath = ENV['BLOCKDIAG_FONTPATH']
52
+ if fontpath
53
+ options[:attributes]['actdiag-fontpath'] = fontpath
54
+ options[:attributes]['blockdiag-fontpath'] = fontpath
55
+ options[:attributes]['seqdiag-fontpath'] = fontpath
56
+ options[:attributes]['nwdiag-fontpath'] = fontpath
57
+ options[:attributes]['rackdiag-fontpath'] = fontpath
58
+ options[:attributes]['packetdiag-fontpath'] = fontpath
59
+ options[:attributes]['seqdiag-fontpath'] = fontpath
60
+ end
61
+
47
62
  options[:attributes]['diagram-on-error'] = 'abort'
63
+
48
64
  ::Asciidoctor.load(StringIO.new(source), options.merge({:trace => true}))
49
65
  end
50
66
  end
@@ -0,0 +1,85 @@
1
+ require_relative 'test_helper'
2
+
3
+ code = <<-eos
4
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
5
+ <diagram program="umlet" version="14.2">
6
+ <zoom_level>10</zoom_level>
7
+ <element>
8
+ <id>UMLActor</id>
9
+ <coordinates>
10
+ <x>20</x>
11
+ <y>20</y>
12
+ <w>60</w>
13
+ <h>120</h>
14
+ </coordinates>
15
+ <panel_attributes>Hello
16
+ AsciiDoc</panel_attributes>
17
+ <additional_attributes/>
18
+ </element>
19
+ </diagram>
20
+ eos
21
+
22
+
23
+ describe Asciidoctor::Diagram::UmletBlockMacroProcessor do
24
+ it "should generate SVG images when format omitted" do
25
+ File.write('umlet.uxf', code)
26
+
27
+ doc = <<-eos
28
+ = Hello, Umlet!
29
+ Doc Writer <doc@example.com>
30
+
31
+ == First Section
32
+
33
+ umlet::umlet.uxf[]
34
+ eos
35
+
36
+ d = load_asciidoc doc
37
+ expect(d).to_not be_nil
38
+
39
+ b = d.find { |bl| bl.context == :image }
40
+ expect(b).to_not be_nil
41
+
42
+ expect(b.content_model).to eq :empty
43
+
44
+ target = b.attributes['target']
45
+ expect(target).to_not be_nil
46
+ expect(target).to match(/\.svg$/)
47
+ expect(File.exist?(target)).to be true
48
+
49
+ expect(b.attributes['width']).to_not be_nil
50
+ expect(b.attributes['height']).to_not be_nil
51
+ end
52
+ end
53
+
54
+
55
+ describe Asciidoctor::Diagram::UmletBlockProcessor do
56
+ it "should generate SVG images when format is omitted" do
57
+ doc = <<-eos
58
+ = Hello, Umlet!
59
+ Doc Writer <doc@example.com>
60
+
61
+ == First Section
62
+
63
+ [umlet]
64
+ ----
65
+ #{code}
66
+ ----
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
85
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-diagram
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pepijn Van Eeckhoudt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-03 00:00:00.000000000 Z
11
+ date: 2017-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -104,6 +104,8 @@ files:
104
104
  - lib/asciidoctor-diagram/salt.rb
105
105
  - lib/asciidoctor-diagram/shaape.rb
106
106
  - lib/asciidoctor-diagram/shaape/extension.rb
107
+ - lib/asciidoctor-diagram/umlet.rb
108
+ - lib/asciidoctor-diagram/umlet/extension.rb
107
109
  - lib/asciidoctor-diagram/util/binaryio.rb
108
110
  - lib/asciidoctor-diagram/util/cli.rb
109
111
  - lib/asciidoctor-diagram/util/cli_generator.rb
@@ -131,6 +133,7 @@ files:
131
133
  - spec/plantuml_spec.rb
132
134
  - spec/shaape_spec.rb
133
135
  - spec/test_helper.rb
136
+ - spec/umlet_spec.rb
134
137
  - spec/wavedrom_spec.rb
135
138
  homepage: https://github.com/asciidoctor/asciidoctor-diagram
136
139
  licenses:
@@ -168,4 +171,5 @@ test_files:
168
171
  - spec/plantuml_spec.rb
169
172
  - spec/shaape_spec.rb
170
173
  - spec/test_helper.rb
174
+ - spec/umlet_spec.rb
171
175
  - spec/wavedrom_spec.rb