asciidoctor-diagram 1.5.19 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.adoc +10 -0
  3. data/README.adoc +22 -9
  4. data/examples/features.adoc +2 -2
  5. data/lib/asciidoctor-diagram.rb +1 -0
  6. data/lib/asciidoctor-diagram/a2s/converter.rb +55 -0
  7. data/lib/asciidoctor-diagram/a2s/extension.rb +6 -52
  8. data/lib/asciidoctor-diagram/blockdiag/converter.rb +37 -0
  9. data/lib/asciidoctor-diagram/blockdiag/extension.rb +9 -116
  10. data/lib/asciidoctor-diagram/bpmn.rb +7 -0
  11. data/lib/asciidoctor-diagram/bpmn/converter.rb +62 -0
  12. data/lib/asciidoctor-diagram/bpmn/extension.rb +14 -0
  13. data/lib/asciidoctor-diagram/diagram_converter.rb +19 -0
  14. data/lib/asciidoctor-diagram/diagram_processor.rb +320 -0
  15. data/lib/asciidoctor-diagram/diagram_source.rb +275 -0
  16. data/lib/asciidoctor-diagram/ditaa/converter.rb +86 -0
  17. data/lib/asciidoctor-diagram/ditaa/extension.rb +6 -71
  18. data/lib/asciidoctor-diagram/erd/converter.rb +31 -0
  19. data/lib/asciidoctor-diagram/erd/extension.rb +6 -35
  20. data/lib/asciidoctor-diagram/gnuplot/converter.rb +63 -0
  21. data/lib/asciidoctor-diagram/gnuplot/extension.rb +6 -62
  22. data/lib/asciidoctor-diagram/graphviz/converter.rb +32 -0
  23. data/lib/asciidoctor-diagram/graphviz/extension.rb +6 -35
  24. data/lib/asciidoctor-diagram/http/server.rb +127 -0
  25. data/lib/asciidoctor-diagram/lilypond/converter.rb +54 -0
  26. data/lib/asciidoctor-diagram/lilypond/extension.rb +6 -53
  27. data/lib/asciidoctor-diagram/meme/converter.rb +122 -0
  28. data/lib/asciidoctor-diagram/meme/extension.rb +5 -107
  29. data/lib/asciidoctor-diagram/mermaid/converter.rb +178 -0
  30. data/lib/asciidoctor-diagram/mermaid/extension.rb +6 -159
  31. data/lib/asciidoctor-diagram/msc/converter.rb +35 -0
  32. data/lib/asciidoctor-diagram/msc/extension.rb +6 -36
  33. data/lib/asciidoctor-diagram/nomnoml/converter.rb +25 -0
  34. data/lib/asciidoctor-diagram/nomnoml/extension.rb +6 -28
  35. data/lib/asciidoctor-diagram/plantuml/converter.rb +115 -0
  36. data/lib/asciidoctor-diagram/plantuml/extension.rb +10 -119
  37. data/lib/asciidoctor-diagram/shaape/converter.rb +25 -0
  38. data/lib/asciidoctor-diagram/shaape/extension.rb +6 -28
  39. data/lib/asciidoctor-diagram/smcat/converter.rb +44 -0
  40. data/lib/asciidoctor-diagram/smcat/extension.rb +6 -42
  41. data/lib/asciidoctor-diagram/svgbob/converter.rb +25 -0
  42. data/lib/asciidoctor-diagram/svgbob/extension.rb +6 -28
  43. data/lib/asciidoctor-diagram/syntrax/converter.rb +55 -0
  44. data/lib/asciidoctor-diagram/syntrax/extension.rb +6 -51
  45. data/lib/asciidoctor-diagram/tikz/converter.rb +56 -0
  46. data/lib/asciidoctor-diagram/tikz/extension.rb +6 -60
  47. data/lib/asciidoctor-diagram/umlet/converter.rb +24 -0
  48. data/lib/asciidoctor-diagram/umlet/extension.rb +6 -28
  49. data/lib/asciidoctor-diagram/util/java.rb +1 -1
  50. data/lib/asciidoctor-diagram/util/java_socket.rb +7 -9
  51. data/lib/asciidoctor-diagram/util/which.rb +0 -29
  52. data/lib/asciidoctor-diagram/vega/converter.rb +47 -0
  53. data/lib/asciidoctor-diagram/vega/extension.rb +6 -44
  54. data/lib/asciidoctor-diagram/version.rb +1 -1
  55. data/lib/asciidoctor-diagram/wavedrom/converter.rb +50 -0
  56. data/lib/asciidoctor-diagram/wavedrom/extension.rb +6 -54
  57. data/lib/ditaa-1.3.14.jar +0 -0
  58. data/lib/plantuml-1.3.14.jar +0 -0
  59. data/lib/plantuml.jar +0 -0
  60. data/lib/server-1.3.14.jar +0 -0
  61. data/spec/bpmn-example.xml +44 -0
  62. data/spec/bpmn_spec.rb +96 -0
  63. data/spec/mermaid_spec.rb +33 -1
  64. data/spec/plantuml_spec.rb +89 -0
  65. metadata +37 -8
  66. data/lib/asciidoctor-diagram/extensions.rb +0 -568
  67. data/lib/ditaa-1.3.13.jar +0 -0
  68. data/lib/plantuml-1.3.13.jar +0 -0
  69. data/lib/server-1.3.13.jar +0 -0
@@ -0,0 +1,25 @@
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 SvgbobConverter
9
+ include DiagramConverter
10
+ include CliGenerator
11
+
12
+
13
+ def supported_formats
14
+ [:svg]
15
+ end
16
+
17
+
18
+ def convert(source, format, options)
19
+ generate_stdin(source.find_command('svgbob'), format.to_s, source.to_s) do |tool_path, output_path|
20
+ [tool_path, '-o', Platform.native_path(output_path)]
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,36 +1,14 @@
1
- require_relative '../extensions'
2
- require_relative '../util/cli_generator'
3
- require_relative '../util/platform'
4
- require_relative '../util/which'
1
+ require_relative 'converter'
2
+ require_relative '../diagram_processor'
5
3
 
6
4
  module Asciidoctor
7
5
  module Diagram
8
- # @private
9
- module Svgbob
10
- include CliGenerator
11
- include Which
12
-
13
- def self.included(mod)
14
- [:svg].each do |f|
15
- mod.register_format(f, :image) do |parent, source|
16
- svgbob(parent, source, f)
17
- end
18
- end
19
- end
20
-
21
- def svgbob(parent, source, format)
22
- generate_stdin(which(parent, 'svgbob'), format.to_s, source.to_s) do |tool_path, output_path|
23
- [tool_path, '-o', Platform.native_path(output_path)]
24
- end
25
- end
26
- end
27
-
28
- class SvgBobBlockProcessor < Extensions::DiagramBlockProcessor
29
- include Svgbob
6
+ class SvgBobBlockProcessor < DiagramBlockProcessor
7
+ use_converter SvgbobConverter
30
8
  end
31
9
 
32
- class SvgBobBlockMacroProcessor < Extensions::DiagramBlockMacroProcessor
33
- include Svgbob
10
+ class SvgBobBlockMacroProcessor < DiagramBlockMacroProcessor
11
+ use_converter SvgbobConverter
34
12
  end
35
13
  end
36
14
  end
@@ -0,0 +1,55 @@
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 SyntraxConverter
9
+ include DiagramConverter
10
+ include CliGenerator
11
+
12
+
13
+ def supported_formats
14
+ [:png, :svg]
15
+ end
16
+
17
+ def collect_options(source, name)
18
+ {
19
+ :heading => source.attr('heading', nil, name),
20
+ :scale => source.attr('scale', nil, name),
21
+ :transparent => source.attr('transparent', nil, name),
22
+ :style => source.attr('style', nil, name)
23
+ }
24
+ end
25
+
26
+
27
+ def convert(source, format, options)
28
+ generate_file(source.find_command('syntrax'), 'spec', format.to_s, source.to_s) do |tool_path, input_path, output_path|
29
+ args = [tool_path, '-i', Platform.native_path(input_path), '-o', Platform.native_path(output_path)]
30
+
31
+ title = options[:heading]
32
+ if title
33
+ args << '--title' << title
34
+ end
35
+
36
+ scale = options[:scale]
37
+ if scale
38
+ args << '--scale' << scale
39
+ end
40
+
41
+ transparent = options[:transparent]
42
+ if transparent == 'true'
43
+ args << '--transparent'
44
+ end
45
+ style = options[:style]
46
+ if style
47
+ args << '--style' << style
48
+ end
49
+
50
+ args
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,59 +1,14 @@
1
- require_relative '../extensions'
2
- require_relative '../util/cli_generator'
3
- require_relative '../util/platform'
4
- require_relative '../util/which'
1
+ require_relative '../diagram_processor'
2
+ require_relative 'converter'
5
3
 
6
4
  module Asciidoctor
7
5
  module Diagram
8
- # @private
9
- module Syntrax
10
- include CliGenerator
11
- include Which
12
-
13
- def self.included(mod)
14
- [:png, :svg].each do |f|
15
- mod.register_format(f, :image) do |parent, source|
16
- syntrax(parent, source, f)
17
- end
18
- end
19
- end
20
-
21
- def syntrax(parent, source, format)
22
- inherit_prefix = name
23
-
24
- generate_file(which(parent, 'syntrax'), 'spec', format.to_s, source.to_s) do |tool_path, input_path, output_path|
25
- args = [tool_path, '-i', Platform.native_path(input_path), '-o', Platform.native_path(output_path)]
26
-
27
- title = source.attr('heading', nil, inherit_prefix)
28
- if title
29
- args << '--title' << title
30
- end
31
-
32
- scale = source.attr('scale', nil, inherit_prefix)
33
- if scale
34
- args << '--scale' << scale
35
- end
36
-
37
- transparent = source.attr('transparent', nil, inherit_prefix)
38
- if transparent == 'true'
39
- args << '--transparent'
40
- end
41
- style = source.attr('style', nil, inherit_prefix)
42
- if style
43
- args << '--style' << style
44
- end
45
-
46
- args
47
- end
48
- end
49
- end
50
-
51
- class SyntraxBlockProcessor < Extensions::DiagramBlockProcessor
52
- include Syntrax
6
+ class SyntraxBlockProcessor < DiagramBlockProcessor
7
+ use_converter SyntraxConverter
53
8
  end
54
9
 
55
- class SyntraxBlockMacroProcessor < Extensions::DiagramBlockMacroProcessor
56
- include Syntrax
10
+ class SyntraxBlockMacroProcessor < DiagramBlockMacroProcessor
11
+ use_converter SyntraxConverter
57
12
  end
58
13
  end
59
14
  end
@@ -0,0 +1,56 @@
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 TikZConverter
9
+ include DiagramConverter
10
+ include CliGenerator
11
+
12
+ def supported_formats
13
+ [:pdf, :svg]
14
+ end
15
+
16
+
17
+ def convert(source, format, options)
18
+ latexpath = source.find_command('pdflatex')
19
+
20
+ if format == :svg
21
+ svgpath = source.find_command('pdf2svg')
22
+ else
23
+ svgpath = nil
24
+ end
25
+
26
+ latex = <<'END'
27
+ \documentclass[border=2bp, tikz]{standalone}
28
+ \usepackage{tikz}
29
+ \begin{document}
30
+ \begingroup
31
+ \tikzset{every picture/.style={scale=1}}
32
+ END
33
+ latex << source.to_s
34
+ latex << <<'END'
35
+ \endgroup
36
+ \end{document}
37
+ END
38
+
39
+ pdf = generate_file(latexpath, 'tex', 'pdf', latex) do |tool_path, input_path, output_path|
40
+ {
41
+ :args => [tool_path, '-shell-escape', '-file-line-error', '-interaction=nonstopmode', '-output-directory', Platform.native_path(File.dirname(output_path)), Platform.native_path(input_path)],
42
+ :out_file => "#{File.dirname(input_path)}/#{File.basename(input_path, '.*')}.pdf"
43
+ }
44
+ end
45
+
46
+ if svgpath
47
+ generate_file(svgpath, 'pdf', 'svg', pdf) do |tool_path, input_path, output_path|
48
+ [tool_path, Platform.native_path(input_path), Platform.native_path(output_path)]
49
+ end
50
+ else
51
+ pdf
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -1,68 +1,14 @@
1
- require_relative '../extensions'
2
- require_relative '../util/cli_generator'
3
- require_relative '../util/platform'
4
- require_relative '../util/which'
1
+ require_relative '../diagram_processor'
2
+ require_relative 'converter'
5
3
 
6
4
  module Asciidoctor
7
5
  module Diagram
8
- # @private
9
- module TikZ
10
- include CliGenerator
11
- include Which
12
-
13
- def self.included(mod)
14
- [:pdf, :svg].each do |f|
15
- mod.register_format(f, :image) do |parent, source|
16
- tikz(parent, source, f)
17
- end
18
- end
19
- end
20
-
21
- def tikz(parent, source, format)
22
- latexpath = which(parent, 'pdflatex')
23
-
24
- if format == :svg
25
- svgpath = which(parent, 'pdf2svg')
26
- else
27
- svgpath = nil
28
- end
29
-
30
- latex = <<'END'
31
- \documentclass[border=2bp, tikz]{standalone}
32
- \usepackage{tikz}
33
- \begin{document}
34
- \begingroup
35
- \tikzset{every picture/.style={scale=1}}
36
- END
37
- latex << source.to_s
38
- latex << <<'END'
39
- \endgroup
40
- \end{document}
41
- END
42
-
43
- pdf = generate_file(latexpath, 'tex', 'pdf', latex) do |tool_path, input_path, output_path|
44
- {
45
- :args => [tool_path, '-shell-escape', '-file-line-error', '-interaction=nonstopmode', '-output-directory', Platform.native_path(File.dirname(output_path)), Platform.native_path(input_path)],
46
- :out_file => "#{File.dirname(input_path)}/#{File.basename(input_path, '.*')}.pdf"
47
- }
48
- end
49
-
50
- if svgpath
51
- generate_file(svgpath, 'pdf', 'svg', pdf) do |tool_path, input_path, output_path|
52
- [tool_path, Platform.native_path(input_path), Platform.native_path(output_path)]
53
- end
54
- else
55
- pdf
56
- end
57
- end
58
- end
59
-
60
- class TikZBlockProcessor < Extensions::DiagramBlockProcessor
61
- include TikZ
6
+ class TikZBlockProcessor < DiagramBlockProcessor
7
+ use_converter TikZConverter
62
8
  end
63
9
 
64
- class TikZBlockMacroProcessor < Extensions::DiagramBlockMacroProcessor
65
- include TikZ
10
+ class TikZBlockMacroProcessor < DiagramBlockMacroProcessor
11
+ use_converter TikZConverter
66
12
  end
67
13
  end
68
14
  end
@@ -0,0 +1,24 @@
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 UmletConverter
9
+ include DiagramConverter
10
+ include CliGenerator
11
+
12
+
13
+ def supported_formats
14
+ [:svg, :png, :pdf, :gif]
15
+ end
16
+
17
+ def convert(source, format, options)
18
+ generate_file(source.find_command('umlet'), 'uxf', format.to_s, source.to_s) do |tool_path, input_path, output_path|
19
+ [tool_path, '-action=convert', "-format=#{format.to_s}", "-filename=#{Platform.native_path(input_path)}", "-output=#{Platform.native_path(output_path)}"]
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,36 +1,14 @@
1
- require_relative '../extensions'
2
- require_relative '../util/cli_generator'
3
- require_relative '../util/platform'
4
- require_relative '../util/which'
1
+ require_relative '../diagram_processor'
2
+ require_relative 'converter'
5
3
 
6
4
  module Asciidoctor
7
5
  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
6
+ class UmletBlockProcessor < DiagramBlockProcessor
7
+ use_converter UmletConverter
30
8
  end
31
9
 
32
- class UmletBlockMacroProcessor < Extensions::DiagramBlockMacroProcessor
33
- include Umlet
10
+ class UmletBlockMacroProcessor < DiagramBlockMacroProcessor
11
+ use_converter UmletConverter
34
12
  end
35
13
  end
36
14
  end
@@ -6,7 +6,7 @@ module Asciidoctor
6
6
  module Java
7
7
  def self.classpath
8
8
  @classpath ||= [
9
- File.expand_path(File.join('../..', 'server-1.3.13.jar'), File.dirname(__FILE__))
9
+ File.expand_path(File.join('../..', 'server-1.3.14.jar'), File.dirname(__FILE__))
10
10
  ]
11
11
  end
12
12
 
@@ -9,28 +9,25 @@ module Asciidoctor
9
9
  # @private
10
10
  module Java
11
11
  class CommandServer
12
- attr_reader :port
13
-
14
12
  def initialize(java, classpath)
15
13
  args = []
16
14
  args << '-Djava.awt.headless=true'
17
15
  args << '-Djava.net.useSystemProxies=true'
18
16
  args << '-cp'
19
17
  args << classpath.flatten.map { |jar| ::Asciidoctor::Diagram::Platform.host_os_path(jar).strip }.join(::Asciidoctor::Diagram::Platform.host_os_path_separator)
20
- args << 'org.asciidoctor.diagram.CommandServer'
18
+ args << 'org.asciidoctor.diagram.StdInOutCommandServer'
21
19
 
22
- @server = IO.popen([java, *args])
23
- @port = @server.readline.strip.to_i
24
- @client = TCPSocket.new 'localhost', port
20
+ @server = IO.popen([java, *args], 'r+')
25
21
  end
26
22
 
27
23
  def io
28
- @client
24
+ @server
29
25
  end
30
26
 
31
27
  def shutdown
32
28
  # KILL is a bit heavy handed, but TERM does not seem to shut down the JVM on Windows.
33
29
  Process.kill('KILL', @server.pid)
30
+ @server.close
34
31
  end
35
32
  end
36
33
 
@@ -60,8 +57,9 @@ module Asciidoctor
60
57
 
61
58
  def self.send_request(req)
62
59
  svr = instance
63
- headers = req[:headers] ||= {}
64
- headers['Host'] = "localhost:#{svr.port}"
60
+ req[:headers] ||= {}
61
+ # headers = req[:headers] ||= {}
62
+ # headers['Host'] = "localhost:#{svr.port}"
65
63
  format_request(req, svr.io)
66
64
  parse_response(svr.io)
67
65
  end