numpydoc.el
numpydoc.el copied to clipboard
Already written docstring
Thanks for this fantastic package. I will definitely use this.
However some features are missing in my opinion.
Some times I have a "return" in my function but only write it as
def f(a, b, c)
and not as def f(a, b, c) -> float
so it would be nice to still be able to specify the return parameter in the doc even without specifying its type in the function definition.
Another usecase is that sometimes part of the docs are already written. It would be nice to have a default mode where the already written text is kept as a default so that I can use the package to modify only the doc of one argument.
Lastly, I notice the "prompt" option nicely format the doc. It would surely be possible to re-format badly written doc (such as when everything is written on a single line instead of nicely given as a paragraph.
Do you thing some of these things are worth to implement ?
Thanks for this fantastic package. I will definitely use this.
Great!
Some times I have a "return" in my function but only write it as
def f(a, b, c)
and not asdef f(a, b, c) -> float
so it would be nice to still be able to specify the return parameter in the doc even without specifying its type in the function definition.
I agree this is a feature that should be supported. I'll take a look at this soon as it should be pretty simple.
Another usecase is that sometimes part of the docs are already written. It would be nice to have a default mode where the already written text is kept as a default so that I can use the package to modify only the doc of one argument.
I don't have time right now to work on this but I would welcome a PR. Off the top of my head I think one could search the existing docstring for the single argument of interest, ask the user for new text, and insert it at the location of the existing argument in the docstring. Or if the user's cursor is on an argument, modify only that argument's description. I imagine the difficulty would be properly removing an existing argument description and replacing it with a new one while maintaining proper numpydoc format and not removing a part of the docstring that is meant to be preserved.
Lastly, I notice the "prompt" option nicely format the doc. It would surely be possible to re-format badly written doc (such as when everything is written on a single line instead of nicely given as a paragraph.
This isn't exactly a target of numpydoc.el
. One can easily reformat long lines in Emacs with the builtin fill-paragraph
function (which has a default binding of M-q
). It's used in numpydoc.el
here:
https://github.com/douglasdavis/numpydoc.el/blob/2d280dd704a1a54bcb3e8091f06656c3311894bc/numpydoc.el#L337-L345
Thanks a lot for this answer. I didn't know about the fill-paragraph function. This is definitely very useful. I'll think a bit on how to do the second thing. I would know how to do it in python but definitely not in e-lisp. Anyway thanks for the great work !
I've added a new option to always insert a Returns block in #11 I'll leave this open since that was only part of the issue.
Nice ! Thanks for this.