DoctorDocstrings.jl is a package that will help you enhance your REPL workflow for adding docstrings to your package. It is very simple, alpha, and hardcoded (for now). Dear lord don’t judge me from the janky hacks it’s awful awful. But it works! The docs are here.
The idea is to
listdocs($MyPackage) to know see all exports in your package/module and true/false for having docstrings/examples.
diagnosedocs($MyPackage) if you only want to know the ones that are missing docstrings
Now that you know which one you want to add docstrings to, you play around with some inputs in the REPL.
fixdocs() select from your REPL history which inputs you want, choose a docstrings template, and step in to @edit the last selected input. The previous REPL entries are in your clipboard, so just pasting should work.
Here’s a live 3 minute demo to show the workflow.
Comments, issues, PRs welcome.
Acknowledgments
Thanks a lot to @mbauman for early feedback, @PetrKryslUCSD for REPLHistory.jl, (a good reference for this project), and @StefanKarpinski for “incepting” this idea into my todo-list, and @tlienart for help with the documentation.
The logic for checking if it has examples is very unsophisticated - I just splat everything onto a string and check for the existence of a Examples\n==== occurring. I’m open to suggestions on how not to jankily abuse the doc internals . (This works for enough use cases as a hack that perfect is the enemy of the good for shipping, so I thought I’d nerdsnipe someone into helping me implement something better .)
Sometimes you do not realise how much you want/need a package doing something until you see a package and see how great idea is it. It is a great idea. I will try with my code and then I will give my feedback.
Great, Examples\n==== is exactly what I was looking for. Would be good to extend this with other possibilities. So far I have always used ## Example or ## Examples, so It would be good to provide a keyword like example_quantifier = ["Examples\n====", "## Examples"...] that has a lot of defaults