Interactively debugging a template with a REPL

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Interactively debugging a template with a REPL

obilodeau
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.
Reply | Threaded
Open this post in threaded view
|

Re: Interactively debugging a template with a REPL

mojavelinux
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.

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.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Interactively-debugging-a-template-with-a-REPL-tp4498.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen
Reply | Threaded
Open this post in threaded view
|

Re: Interactively debugging a template with a REPL

obilodeau
Awesome! I'll try and report back here.

On Sun, Mar 13, 2016 at 3:58 PM mojavelinux [via Asciidoctor :: Discussion] <[hidden email]> wrote:
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.

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.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Interactively-debugging-a-template-with-a-REPL-tp4498.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Interactively-debugging-a-template-with-a-REPL-tp4498p4499.html
To unsubscribe from Interactively debugging a template with a REPL, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Interactively debugging a template with a REPL

LightGuardjp
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:
Awesome! I'll try and report back here.

On Sun, Mar 13, 2016 at 3:58 PM mojavelinux [via Asciidoctor :: Discussion] <[hidden email]> wrote:
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.

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.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Interactively-debugging-a-template-with-a-REPL-tp4498.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Interactively-debugging-a-template-with-a-REPL-tp4498p4499.html
To unsubscribe from Interactively debugging a template with a REPL, click here.
NAML



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Interactively-debugging-a-template-with-a-REPL-tp4498p4500.html
To start a new topic under Asciidoctor :: Discussion, email <a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;ml-node%2Bs49171n1h37@n6.nabble.com&#39;);" target="_blank">ml-node+s49171n1h37@...
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Sent from Gmail Mobile
Reply | Threaded
Open this post in threaded view
|

Re: Interactively debugging a template with a REPL

obilodeau
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
Reply | Threaded
Open this post in threaded view
|

Re: Interactively debugging a template with a REPL

mojavelinux
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).

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


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Interactively-debugging-a-template-with-a-REPL-tp4498p4502.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen