I would like to be able to interactively debug a template modification I am trying to make instead of putting puts statements all over the place and trying to reach the proper object.
Using the slim template engine. In python this would look like this: - import ipdb; ipdb.set_trace() Then running the program from a shell I would get an interactive debugger in the context of where the line executed. Ideally the debugger/REPL would have tab completion to make object hierarchy discovery faster. |
Administrator
|
The debugger you're looking for is PRY. It's pretty amazing, though I have to admit I don't have much experience using it. I'd be thrilled to learn from your experience. On Sun, Mar 13, 2016 at 1:26 PM, obilodeau [via Asciidoctor :: Discussion] <[hidden email]> wrote: I would like to be able to interactively debug a template modification I am trying to make instead of putting puts statements all over the place and trying to reach the proper object. Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen |
Awesome! I'll try and report back here. On Sun, Mar 13, 2016 at 3:58 PM mojavelinux [via Asciidoctor :: Discussion] <[hidden email]> wrote:
|
You should be able to do this by starting PRY and requiring asciidoctor then run the necessary convert methods with the correct template options. You may also want to look into pry-byebug which will add gdb style debugging commands to pry.
On Sunday, March 13, 2016, obilodeau [via Asciidoctor :: Discussion] <[hidden email]> wrote:
-- Sent from Gmail Mobile |
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-template Let 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 |
Administrator
|
Olivier, I can't tell you how excited I am to read this. It made my day. Thanks for sharing! This is definitely key material for the guide that will cover how to create custom templates. I'll link to this thread from there. Cheers, -Dan On Sun, Mar 13, 2016 at 9:20 PM, obilodeau [via Asciidoctor :: Discussion] <[hidden email]> wrote: 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). Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen |
Free forum by Nabble | Edit this page |