ronisbr / TerminalPager.jl

Pure Julia implementation of the command less
MIT License
116 stars 8 forks source link

[Feature] Easier `@doc` Macro or Alternative #14

Closed TheCedarPrince closed 3 years ago

TheCedarPrince commented 3 years ago

Hey @ronisbr!

Now that I have started using TerminalPager frequently, I had one feature request/idea that I am not sure how much work would be to do on your end. A big use that I have right now for the package is looking at documentation as it tends to clutter my REPL session. However, with your handy tool and the docs macro, this is no longer a problem!

However, what I was wondering if rather than having to write syntax like this every time:

@doc(println) |> pager

Could you instead make it something more like this:

@doc println

Where the macro implicitly knows to call the pager command? Thanks for the great work! Use it everyday. :)

ronisbr commented 3 years ago

Hi @TheCedarPrince !

Nice! I am glad this package is being useful :)

I think we cannot "hijack" @doc without many consequences (I don't know even if it is possible). However, it should be really easy to create another macro, like @docp or something. What do you think?

ronisbr commented 3 years ago

Sorry, hit the wrong button...

TheCedarPrince commented 3 years ago

Oh! I didn't realize that @doc was provisioned from base Julia. What about @dpr - short for "docs pager" and pronounced like "dapper"? Either way, another macro sounds great! Plus, that has the bonus - to my eyes - of getting away from having to depend on base Julia if they were to change around the @doc macro. What do you think @ronisbr ?

ronisbr commented 3 years ago

Hi @TheCedarPrince !

Done! I followed your suggestion and added the macro @dpr. Hence you can now call open a documentation inside the pager using @dpr <function_name>. Can you please test?

TheCedarPrince commented 3 years ago

Hey @ronisbr - what a great tool! Works perfectly on my fork of TerminalPager. :100:

Thank you for adding this in! Would you like an example of @dpr added to the docs? Happy to open a small PR adding how it can be used! :smile:

ronisbr commented 3 years ago

Hey @ronisbr - what a great tool! Works perfectly on my fork of TerminalPager. 💯

Nice!!

Thank you for adding this in! Would you like an example of @dpr added to the docs? Happy to open a small PR adding how it can be used! 😄

You're welcome. Yes, if you can submit a PR with the documentation, I will appreciate! :) Thanks!!