-
-
Notifications
You must be signed in to change notification settings - Fork 167
Why should docstrings end with a blank line? #274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I took most of that change from the numpy repository rather than inventing
it.
I agree that I can't see why there should be a blank line there.
|
Okay, thanks for the clarification. We'll probably leave out the blank line in our project's numpydoc flavor then. I do think it would be good if numpydoc had an explicit opinion on that though. I'd prefer if it was "no blank line", but any fixed guideline would be good. Should I close this issue or keep it open for further discussion/opinions? |
I did some more git-history archeology, and it looks like the actual first mention was by @jarrodmillman in numpy/numpy@76ab788 back in 2007. |
Just to clarify, the referenced suggestion seems to apply to module docstrings. It does seem that this is more of a style choice than something that is part of the There are other cases where |
I've always used a blank line at the end of docstrings because it provides better separation from the code. Whether that is recommended somewhere I don't know. |
The clause
seems to be copied from PEP 8 back then when the NumPy docstring guide was introduced. The clause is not part of PEP 8 as of today. According to the Wayback Machine (archive.org) it was removed in 2014. PEP 8 / PEP 257, June 2006:
https://web.archive.org/web/20060610022424/http://www.python.org/dev/peps/pep-0008/ (section "Documentation Strings") August 2014 (consistent with today's version):
https://web.archive.org/web/20140819083127/http://legacy.python.org/dev/peps/pep-0008/#documentation-strings From what has changed in the PEPs it seems that Emacs' So, the clause is in the example of the NumPy docstring guide for historic reasons. The blank line is not needed for See also the post from "endolith" on stackoverflow:
|
I didn't know it was part of a pep, but I prefer it because it looks nicer and effectively separates the docstring from the code. |
The example points out that
I'm curious if there is any reason for that preference or if it is just picked arbitrarily. It seems a bit unintuitive to me to put that blank line into the docstring. If you want visual separation to the implementation, putting it after the docstring would seem better.
Note that I'm not trying to start a style discussion, I'm just looking for clarification if there's any particular reason for the suggestion. I hope this is the right place to put this sort of question. CC @jnothman, who added the example in e71411d.
The text was updated successfully, but these errors were encountered: