asciidoctor-diagram 2.2.6 → 2.2.7

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: f3f3bffc76f761832b6e762e2dca5dc6cbfb026a452284b7841daaf4575c66c3
4
- data.tar.gz: 70fa27583dfd7190bd3c7fffee3320ea5b2ac5240757bab8bbb5940146714229
3
+ metadata.gz: 6d16a4ceac53c9b8aa223e3b22a061ee0c92cc6876b24522c224530f7559c6d9
4
+ data.tar.gz: 86d434f86830db71ea4369b2e1e08d05b0ca8d6ed8f3ed4927c90cb5458f0154
5
5
  SHA512:
6
- metadata.gz: 6a847622189aefde984b76476839f63fd6c05746ed9bd4b6a84f8d72a63ac0b105525399381db4074f3288ce5db807fc3569adf61971a46ac31e28f051b376b8
7
- data.tar.gz: 62d9c498b3c566353f6510b243b2fb262070dde468f19fbf6eaf9f2f436d00d62c0df32a84089b20e86a87c047feab56236310ab211a532381ed6abe8e2d4dd0
6
+ metadata.gz: d365c1149d8b2d7ce00a0aecdf0d40435518aeda247448adb4bfe81bc7b4c9cefe69477c3c3a6e3cb1fcbd703dc7efe2ad4e519d49aa4f32a10a51ecf523eaab
7
+ data.tar.gz: 567f9ba04c8bb97e09e6e2d70bfde26cd51700777257a5dd8a7a683ce101f6b0341f00d6729d12116400b620f38d5f4b3bea1113623641989c9d44a26110c04b
data/CHANGELOG.adoc CHANGED
@@ -1,5 +1,11 @@
1
1
  = Asciidoctor-diagram Changelog
2
2
 
3
+ == 2.2.7
4
+
5
+ Enhancements::
6
+
7
+ * Issue #407: Add https://d2lang.com[D2] support
8
+
3
9
  == 2.2.6
4
10
 
5
11
  Enhancements::
@@ -74,6 +74,7 @@ The following table lists the tools that are required for each diagram type, the
74
74
  |bpmn |{uri-bpmn}[bpmn-js-cmd] |`bpmn`
75
75
  |bytefield |{uri-bytefield}[bytefield-svg] |`bytefield-svg`
76
76
  |diagrams |{uri-python}[Python] |`diagrams-python`
77
+ |D2 |{uri-d2}[D2] |`d2`
77
78
  |ditaa |{uri-java}[Java] |`java`
78
79
  |dpic |{uri-dpic}[dpic] |`dpic`
79
80
  |erd |{uri-erd}[Erd] or {uri-erd-go}[Erd Go] |`erd`
@@ -234,6 +235,21 @@ If the maximum size is exceeded, POST requests are used instead
234
235
  |width |1024 |The target width of the diagram. Does not apply for output type `svg`.
235
236
  |===
236
237
 
238
+ ==== D2
239
+
240
+ [cols=">,<,<",options="header"]
241
+ |===
242
+ |Name |Default value |Description
243
+ |layout |dagre |Set the diagram layout engine
244
+ |theme |0 |Set the diagram theme ID
245
+ |pad |100 |Pixels padded around the rendered diagram
246
+ |animate-interval| |If given, multiple boards are packaged as 1 SVG which transitions through each board at the interval (in milliseconds). Can only be used with SVG exports.
247
+ |sketch |false |Renders the diagram to look like it was sketched by hand
248
+ |font-regular |Source Sans Pro Regular |Path to .ttf file to use for the regular font
249
+ |font-italic |Source Sans Pro Regular-Italic|Path to .ttf file to use for the italic font
250
+ |font-bol |Source Sans Pro Bold |Path to .ttf file to use for the bold font
251
+ |===
252
+
237
253
  ==== Diagrams
238
254
 
239
255
  No specific attributes.
@@ -27,6 +27,7 @@ The following diagram types and output formats are available:
27
27
  |{uri-blockdiag}[blockdiag] | |{check}|{check}|{check}|
28
28
  |{uri-bpmn}[bpmn] | |{check}|{check}|{check}|
29
29
  |{uri-bytefield}[bytefield] | | | |{check}|
30
+ |{uri-d2}[D2] | |{check}|{check}|{check}|
30
31
  |{uri-diagrams}[diagrams] | |{check}|{check}|{check}|
31
32
  |{uri-ditaa}[ditaa] | | |{check}|{check}|{check}
32
33
  |{uri-dpic}[dpic] | | | |{check}|
@@ -5,6 +5,7 @@
5
5
  :uri-blockdiag: http://blockdiag.com
6
6
  :uri-bpmn: https://github.com/gtudan/bpmn-js-cmd
7
7
  :uri-bytefield: https://github.com/Deep-Symmetry/bytefield-svg
8
+ :uri-d2: https://d2lang.com
8
9
  :uri-diagrams: https://diagrams.mingrammer.com
9
10
  :uri-ditaa: http://ditaa.sourceforge.net/
10
11
  :uri-dpic: https://gitlab.com/aplevich/dpic
@@ -0,0 +1,49 @@
1
+ require_relative '../diagram_converter'
2
+ require_relative '../util/cli_generator'
3
+ require_relative '../util/platform'
4
+
5
+ module Asciidoctor
6
+ module Diagram
7
+ # @private
8
+ class D2Converter
9
+ include DiagramConverter
10
+ include CliGenerator
11
+
12
+ def supported_formats
13
+ [:svg, :png, :pdf]
14
+ end
15
+
16
+ def collect_options(source)
17
+ {
18
+ :layout => source.attr('layout'),
19
+ :theme => source.attr('theme'),
20
+ :pad => source.attr('pad'),
21
+ :animate_interval => source.attr('animate-interval'),
22
+ :sketch => source.attr('sketch'),
23
+ :font_regular => source.attr('font-regular'),
24
+ :font_italic => source.attr('font-italic'),
25
+ :font_bold => source.attr('font-bold')
26
+ }.delete_if { |key, value| value.nil? }
27
+ end
28
+
29
+ def convert(source, format, options)
30
+ generate_file(source.find_command('d2'), "d2", format.to_s, source.code) do |tool_path, input_path, output_path|
31
+ args = [tool_path, '--browser', 'false']
32
+
33
+ options.each_pair do |key, value|
34
+ args << "--#{key.to_s.gsub('_', '-')}"
35
+
36
+ if key.to_s.start_with?('font')
37
+ args << Platform.native_path(value)
38
+ else
39
+ args << value
40
+ end
41
+ end
42
+
43
+ args << Platform.native_path(input_path)
44
+ args << Platform.native_path(output_path)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'converter'
2
+ require_relative '../diagram_processor'
3
+
4
+ module Asciidoctor
5
+ module Diagram
6
+ class D2BlockProcessor < DiagramBlockProcessor
7
+ use_converter D2Converter
8
+ end
9
+
10
+ class D2BlockMacroProcessor < DiagramBlockMacroProcessor
11
+ use_converter D2Converter
12
+ end
13
+
14
+ class D2InlineMacroProcessor < DiagramInlineMacroProcessor
15
+ use_converter D2Converter
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'd2/extension'
3
+
4
+ Asciidoctor::Extensions.register do
5
+ block Asciidoctor::Diagram::D2BlockProcessor, :d2
6
+ block_macro Asciidoctor::Diagram::D2BlockMacroProcessor, :d2
7
+ inline_macro Asciidoctor::Diagram::D2InlineMacroProcessor, :d2
8
+ end
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Diagram
3
- VERSION = "2.2.6"
3
+ VERSION = "2.2.7"
4
4
  end
5
5
  end
@@ -3,6 +3,7 @@ require_relative 'asciidoctor-diagram/barcode'
3
3
  require_relative 'asciidoctor-diagram/blockdiag'
4
4
  require_relative 'asciidoctor-diagram/bpmn'
5
5
  require_relative 'asciidoctor-diagram/bytefield'
6
+ require_relative 'asciidoctor-diagram/d2'
6
7
  require_relative 'asciidoctor-diagram/diagrams'
7
8
  require_relative 'asciidoctor-diagram/ditaa'
8
9
  require_relative 'asciidoctor-diagram/dpic'
data/spec/d2_spec.rb ADDED
@@ -0,0 +1,37 @@
1
+ require_relative 'test_helper'
2
+
3
+ D2_CODE = <<-eos
4
+ # Actors
5
+ hans: Hans Niemann
6
+
7
+ defendants: {
8
+ mc: Magnus Carlsen
9
+ playmagnus: Play Magnus Group
10
+ chesscom: Chess.com
11
+ naka: Hikaru Nakamura
12
+
13
+ mc -> playmagnus: Owns majority
14
+ playmagnus <-> chesscom: Merger talks
15
+ chesscom -> naka: Sponsoring
16
+ }
17
+
18
+ # Accusations
19
+ hans -> defendants: 'sueing for $100M'
20
+
21
+ # Offense
22
+ defendants.naka -> hans: Accused of cheating on his stream
23
+ defendants.mc -> hans: Lost then withdrew with accusations
24
+ defendants.chesscom -> hans: 72 page report of cheating
25
+ eos
26
+
27
+ describe Asciidoctor::Diagram::D2InlineMacroProcessor, :broken_on_windows do
28
+ include_examples "inline_macro", :d2, D2_CODE, [:svg]
29
+ end
30
+
31
+ describe Asciidoctor::Diagram::D2BlockMacroProcessor, :broken_on_windows do
32
+ include_examples "block_macro", :d2, D2_CODE, [:svg]
33
+ end
34
+
35
+ describe Asciidoctor::Diagram::D2BlockProcessor, :broken_on_windows do
36
+ include_examples "block", :d2, D2_CODE, [:svg]
37
+ 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: 2.2.6
4
+ version: 2.2.7
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: 2023-03-23 00:00:00.000000000 Z
11
+ date: 2023-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -156,6 +156,9 @@ files:
156
156
  - lib/asciidoctor-diagram/bytefield.rb
157
157
  - lib/asciidoctor-diagram/bytefield/converter.rb
158
158
  - lib/asciidoctor-diagram/bytefield/extension.rb
159
+ - lib/asciidoctor-diagram/d2.rb
160
+ - lib/asciidoctor-diagram/d2/converter.rb
161
+ - lib/asciidoctor-diagram/d2/extension.rb
159
162
  - lib/asciidoctor-diagram/diagram_converter.rb
160
163
  - lib/asciidoctor-diagram/diagram_processor.rb
161
164
  - lib/asciidoctor-diagram/diagram_source.rb
@@ -252,6 +255,7 @@ files:
252
255
  - spec/blockdiag_spec.rb
253
256
  - spec/bpmn_spec.rb
254
257
  - spec/bytefield_spec.rb
258
+ - spec/d2_spec.rb
255
259
  - spec/diagrams_spec.rb
256
260
  - spec/ditaa_spec.rb
257
261
  - spec/dpic_spec.rb
@@ -309,6 +313,7 @@ test_files:
309
313
  - spec/blockdiag_spec.rb
310
314
  - spec/bpmn_spec.rb
311
315
  - spec/bytefield_spec.rb
316
+ - spec/d2_spec.rb
312
317
  - spec/diagrams_spec.rb
313
318
  - spec/ditaa_spec.rb
314
319
  - spec/dpic_spec.rb