Closed mojavelinux closed 9 years ago
@mojavelinux can you please assign me on this issue ?
I'm back on extension but I got an error:
/home/mogztter/.rvm/gems/ruby-1.9.3-p429/gems/asciidoctor-1.5.2/lib/asciidoctor/extensions.rb:66:in `use_dsl': undefined method `nil_or_empty?' for "ChartBlockMacro":String (NoMethodError)
I didn't change the code and I know this is supposed to be working because there's a test in Asciidoctor core: https://github.com/asciidoctor/asciidoctor/blob/master/test/extensions_test.rb#L88
Maybe related to https://github.com/asciidoctor/asciidoctor/commit/9fdf6bdb2bea93de4554ede0f129d9b38d1be14c ?
I think we need to add tests to this project. When I come back on this project I always spend some time writing a dummy test.rb file to be able to test my extension. Maybe we can reuse the Asciidoctor test harness ?
This is working with CLI asciidoctor lib/chart-block-macro/sample.adoc -r 'chart-block-macro' --load-path lib
My test.rb:
require_relative 'lib/chart-block-macro'
Asciidoctor.render_file 'lib/chart-block-macro/sample.adoc', :safe => :safe, :in_place => true
Maybe we can reuse the Asciidoctor test harness?
That's a pretty bad foundation...which I plan to eventually overhaul. What we could do is reuse the cucumber tests here:
https://github.com/asciidoctor/asciidoctor/tree/master/features
We just need to pick one of the proposed approaches and stick with it. I find it the best way to express the inputs and outputs. Keep in mind, if it applies, we can also use the Asciidoctor doctest.
This is working with CLI asciidoctor lib/chart-block-macro/sample.adoc -r 'chart-block-macro' --load-path lib
The -r
flag has to be a path relative to the load path. Thus, you can either modify the load path, as you have done, or you can specify a qualified relative path:
asciidoctor -r ./lib/chart-block-macro lib/chart-block-macro/sample.adoc
Of course, if we get to the point of installing it as a gem, then it will already be on the load path...so you can reduce it to -r chart-block-macro
or whatever we call the gem.
This is truly excellent! Let's proceed!
Note that the chart extension now lives in it's own repository. See https://github.com/asciidoctor/asciidoctor-chart.
Add a block extension to demonstrate how to output a chart using the content of the block as the data. One idea is using chart.js or d3.js.