Re: Interactively debugging a template with a REPL
Posted by
obilodeau on
Mar 14, 2016; 3:20am
URL: https://discuss.asciidoctor.org/Interactively-debugging-a-template-with-a-REPL-tp4498p4502.html
I got this to work by invoking pry directly from the template I was working on. Let me tell you it is a wonderful and powerful way to poke around for someone not familiar with ruby or asciidoctor's core. I was able to implement what I intended to do much more quicker than by going through those huge "sections" printouts (which holds references to @document and so would scroll forever).
I documented the approach here:
https://github.com/asciidoctor/asciidoctor-reveal.js/blob/master/HACKING.adoc#interactively-debug-a-templateLet me stress out how awesome this is for a non-rubyist nor asciidoctor contributor like me: It takes literally 2 minutes to setup and then I could do stuff like `(subsections = sections).empty?` (and understand what it meant, assignment or test!? oh both...) or `? find_by` which pulls out nicely formatted documentation of asciidoctor's AbstractBlock's find_by without me needing to hunt for where the source code was (was doing that before). When you quit the debugger, the processing resumes and debugger will fire again if the `binding.pry` is encountered again otherwise process completes with a rendered document. Marvellous.
Feel free to copy the stuff and improve this documentation as you see fit.
Cheers