-
Notifications
You must be signed in to change notification settings - Fork 7
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
Docstring Style #33
Comments
fwiw my favourite is "whichever some highly-regarded Python linty thing uses" /cc @ghickman |
"whichever some highly-regarded Python linty thing uses" 👍 |
There's no clear standard, as far as I know. The PEP regarding docstrings does not describe all the details. |
:( |
@ghickman-as-a-Service? ;P |
PEP257 should cover everything. One line:
Multi-line:
Ideally docstrings are limited to 78 characters since they are prose but I don't feel this needs to be a hard limit. |
Yay PEP257. Do you have an automated enforcer handy? |
I don't unfortunately… |
PEP257 is vague on various things. E.g. it specified that single-line docstrings are possible, but not that they can't stand on their own line, or which one is better. Rather it explains what a docstring is, what it should contain and how it should be parsed. I'd vote for simply showing a few good examples. On the one line docstring thing I don't have a big preference, but usually I'd go for consistency (always starting on the second line). Also makes conversion from one style to the other unnecessary once someone adds more content to the docstring. |
This seems pretty simple to me ;) But I would agree with everything you say nonetheless, especially putting the single line docstring on a newline. Clean diffs are always better than the alternative. For multiline docstrings I find Tim Pope's guide to git commits can be very useful on how to separate the "subject" and "body". How's this? One line:
Multi-line:
|
+1 |
Yes, that part is obvious. The question is whether we want a trailing empty line (useful to separate the docstring visually from the following function definition, as according to some PEP IIRC the code should follow the |
Personally I prefer no line between the docstring text and the |
@dbrgn Can you clarify what "[t]he question is" please? I've revisited this issue trying to understand where we're at, and I confess to having no idea what's actually being debated... |
Format / Whitespace:
vs
I'd vote for the latter. Single line docstrings
vs
vs
I'd vote for the last example. If a docstring is extended, we have cleaner git diffs. Argument docs
vs
vs some other formats like Epydoc. For non-library software I usually prefer the Google-Style docstrings, as they're easily readable. But for libraries I'd go with Sphinx-Style, so we could auto-generate API docs. |
@dbrgn <3 thanks for clarifying! |
(1/3/same-as-you here) |
1, 1 or 3, don't care here. On Sun, Oct 19, 2014 at 11:24 AM, Kristian Glass [email protected]
|
I've been pointed to a docstring checking tool, pep257 and a flake8 wrapper for it (thanks @meshy!). Some error codes I'm not sure about: D100: seems overkill to do this for every module. re examples: 1, 1/3, don't mind |
@ghickman Whack it in a PR with vanilla settings, see how it goes? |
Pleasure |
Wow, pep257 is nice :) |
What docstring style should we use?
My currently favorite style is:
And:
For the docstring style we could use Sphinx syntax to be able to generate parseable documentation.
The text was updated successfully, but these errors were encountered: