Repository navigation
Recommend Google as the docstring format #42
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
146bef6
Recommend sphinx as the docstring format
de0e208
Update docs/Coding-Conventions.md
thejcannon 2e3c049
Change the convention to be Google style
ff7063b
Update docs/Coding-Conventions.md
thejcannon 69c7a26
Allow any convention style
76069c5
Merge branch 'docstring-format' of https://github.com/thejcannon/pyth…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. I like the styling of the Google docstrings, but I've tended to prefer imperative method summaries, to harmonize with the rest of the Python community. But I can live with descriptive instead, if we have to go whole-hog on one standard or the other. One advantage of descriptive-style is that it would match our C# docstring conventions, so that's good, at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well shit, I prefer the other style.. Must we adopt this as part of Google docstring style?
I suppose if we subscribe to google docstring, we should just follow that and keep it simple.. but.. bah!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's gonna be all-or-nothing. 😄 Anything in the middle would just be confusing...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bummer :( ..anyway not a big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's kind of a big deal. Now our conventions violate PEP-0257. If this difference was highlighted pre-voting I would have changed from ambivalent to Sphinx.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish the Python community had a readable, more consistent, standard. I like the overall readability of Google Style because it looks like it was written for a human and not a computer. The Sphinx style seems written for a parser not a human. I prefer Google Style for the same reason I prefer yaml or toml over XML.
But why did Google decide to deviate from PEP-257 in this way? --Neil wrings his hands-- Did they want to match other languages at Google? Were they just trying to be difficult? I don't think I even noticed this deviation when reading the style the first time (so good catch) and have generally preferred imperative mood since it usually is shorter and matches convention in Git commits.
I just interpret those as plurals nouns rather than descriptive verbs since a function has multiple arguments, can return multiple values, and can raise more than one thing. It's a little of a stretch but makes me feel better :-)
My personal preference would be to adopt Google Style and PEP-257 and prefer PEP-257 where they conflict (i.e. use imperative mood).
As a side curiosity do we have a mood standard among any other languages at NI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NI's C# code uses declarative style, though it's not explicitly called out in the style guide (though there are examples there that are declarative).
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsurprisingly, Google's developer documentation style guide states:
I've also read a handful of posts from various people online (language-agnostic) basically saying "client documentation uses descriptive. Developer documentation (I.e. comments) uses imperative". I think this makes the most sense as it fits with the context of what's being described and to whom.
Ultimately, I think I'm inclined to leave it as "We follow Google's guide." which would mean advocating for descriptive style across the company. However also calling out, much like which guide to follow that being consistent is ultimately the important thing. The tooling currently doesn't enforce any verb-mood, and I'll switch it back to simply enforce all conventions (minus verb mood).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me. I also buy the developer versus user argument. I've never heard that before but it makes sense.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I love their explanation. Talk in terms of what the method can do for the user (gets the thing), instead of what the program will do if you use it (get the thing).