Skip to content

Commit

Permalink
#225 Add support for WaveDrom CLI 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pepijnve committed Jun 12, 2019
1 parent 1e845de commit f695488
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
= Asciidoctor-diagram Changelog

== 1.5.19

Enhancements::
* Issue #225: Add support for WaveDrom CLI 2.0.0

== 1.5.18

Bug Fixes::
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ The following table lists the tools that are required for each diagram type, the
|vega |{uri-vega}[vg2png] and/or {uri-vega}[vg2png] |`vg2png` and `vg2svg`
|vegalite |{uri-vegalite}[vl2vg] and {uri-vega}[vg2png] and/or {uri-vega}[vg2svg]|`vl2vg`, `vg2png` and `vg2svg`
.2+|wavedrom |{uri-wavedromeditor}[WaveDrom Editor] |`wavedrom`
|{uri-wavedromcli}[WaveDrom CLI] and {uri-phantomjs}[PhantomJS] |`wavedrom` and `phantomjs`
|{uri-wavedromcli}[WaveDrom CLI] (and {uri-phantomjs}[PhantomJS] for WaveDrom CLI v1) |`wavedrom` (and `phantomjs`)
|===

If for instance you installed `actdiag` in `/home/me/actdiag/bin` and this path is not included in the `PATH` you can specify its location on the command line
Expand Down
32 changes: 20 additions & 12 deletions lib/asciidoctor-diagram/wavedrom/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,33 @@ def self.included(mod)
end

def wavedrom(parent, source, format)
wavedrom_cli = which(parent, 'wavedrom', :raise_on_error => false)
phantomjs = which(parent, 'phantomjs', :alt_attrs => ['phantomjs_2'], :raise_on_error => false)
wavedrom_cli = which(parent, 'wavedrom-cli', :raise_on_error => false)

if wavedrom_cli && !wavedrom_cli.include?('WaveDromEditor') && phantomjs
if wavedrom_cli
generate_file(wavedrom_cli, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
[phantomjs, Platform.native_path(tool_path), '-i', Platform.native_path(input_path), "-#{format.to_s[0]}", Platform.native_path(output_path)]
[Platform.native_path(tool_path), '--input', Platform.native_path(input_path), "--#{format.to_s}", Platform.native_path(output_path)]
end
else
if ::Asciidoctor::Diagram::Platform.os == :macosx
wavedrom = which(parent, 'WaveDromEditor.app', :alt_cmds => ['wavedrom-editor.app'], :attrs => ['WaveDromEditorApp'],:path => ['/Applications'])
if wavedrom
wavedrom = File.join(wavedrom, 'Contents/MacOS/nwjs')
wavedrom_cli = which(parent, 'wavedrom', :raise_on_error => false)
phantomjs = which(parent, 'phantomjs', :alt_attrs => ['phantomjs_2'], :raise_on_error => false)

if wavedrom_cli && !wavedrom_cli.include?('WaveDromEditor') && phantomjs
generate_file(wavedrom_cli, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
[phantomjs, Platform.native_path(tool_path), '-i', Platform.native_path(input_path), "-#{format.to_s[0]}", Platform.native_path(output_path)]
end
else
wavedrom = which(parent, 'WaveDromEditor')
end
if ::Asciidoctor::Diagram::Platform.os == :macosx
wavedrom = which(parent, 'WaveDromEditor.app', :alt_cmds => ['wavedrom-editor.app'], :attrs => ['WaveDromEditorApp'],:path => ['/Applications'])
if wavedrom
wavedrom = File.join(wavedrom, 'Contents/MacOS/nwjs')
end
else
wavedrom = which(parent, 'WaveDromEditor')
end

generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
[tool_path, 'source', Platform.native_path(input_path), format.to_s, Platform.native_path(output_path)]
generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
[tool_path, 'source', Platform.native_path(input_path), format.to_s, Platform.native_path(output_path)]
end
end
end
end
Expand Down

0 comments on commit f695488

Please sign in to comment.