Repository navigation
Recommend Google Style for DocStrings - #88
Conversation
Co-authored-by: mshafer-NI <matthew.shafer@ni.com>
Co-authored-by: Ryan Zoeller <Ryan.Zoeller@ni.com>
…on-styleguide into docstring-format
… "suggest Google"
|
Thank you for contributing! 👋 Since this changes the Coding Conventions, I'll @-mention the appropriate NI engineers. |
|
Tagging our newest Python Working Group Member to review the conventions change as well: |
|
I want to mention in hardware-land, we've been using restructured test extensively in docstrings (and increasingly; far far more than when the original PR was created) over the past year, along with starting to write some documentation in straight-up rst. I was originally thinking to start rehashing/relitigating the discussion from nearly 2 years ago since I hadn't participated (not having an opinion at the time). However, after googling enough I see that Napoleon can be used to allow google-style docstrings with sphinx and so my only qualm is that if I switch things to google-style docstrings I'm going to have to rewrite some tooling I wrote that parses python docstrings into LabVIEW documentation. Is it worth mentioning any rationale for this choice in the styleguide, possibly also noting the integrations available for google-style docstrings in sphinx? |
Hmmm, we mostly don’t have rationale in the doc since it is preferable to keep it a “do this”; however, this PR should probably capture more of the rationale. For Sphinx integration – yeah, we should call that out since that was one of our requirements. I’ll try to update the doc to capture that. |
This reverts commit c09c931.
|
Thank you for contributing! 👋 Since this changes the Coding Conventions, I'll @-mention the appropriate NI engineers. |
|
Thank you for contributing! 👋 Since this changes the Coding Conventions, I'll @-mention the appropriate NI engineers. |
|
Thank you for contributing! 👋 Since this changes the Coding Conventions, I'll @-mention the appropriate NI engineers. |
kcuzner
left a comment
There was a problem hiding this comment.
but you can choose any format so long as you are consistent
So long as this stays, I think my concerns are addressed. I've been working on a tool that will not work well with google-style docstrings since it uses docutils to parse things, but I still need to see if I can somehow leverage sphinx napoleon into fixing that.
* Recommend sphinx as the docstring format * Update docs/Coding-Conventions.md Co-authored-by: mshafer-NI <matthew.shafer@ni.com> * Change the convention to be Google style * Update docs/Coding-Conventions.md Co-authored-by: Ryan Zoeller <Ryan.Zoeller@ni.com> * Allow any convention style * add org-check to PR notify * touch conventions file to prompt PR checks * touch again * set docstring convention to Google * add some debug output * document D412 * rname vars and re-work to bettter show what the error is * switch to "all" and suprress the codes that we see that don't fit the "suggest Google" * format * revert most of the docstring changes * remove blank lines before closing quotes * fix branch name in notify action * add note about using sphinx.ext.napolean to handle docs * Revert "revert most of the docstring changes" This reverts commit c09c931. * more docstrings to active form * add D406 to excluded rules * s/sell/sells/g * add all the codes pydocstyle would ignore if we were explicitly stating Google style * don't need that twice Co-authored-by: Joshua Cannon <joshua.cannon@ni.com> Co-authored-by: Joshua Cannon <joshdcannon@gmail.com> Co-authored-by: Ryan Zoeller <Ryan.Zoeller@ni.com>
Having any documentation is better than no documentation. Likewise following a format is better than not. However choosing a format can be intractable.
We chose Google style because the majority of people preferred it.
Since type hints exist (and we will be recommending their usage) the type information format of either doesn't concern me much.
NOTE: This PR started off recommending sphinx format - See #42 for history (which will be briefly recapped here)
There are two primary competing standards for Python Docstrings.
Sphinx
An example Sphinx DocString:
source
Google
An example Google Style DocString:
source
Because there is not a widely adopted "use type-hinted signatures and good names and use the doc-string to document what the method does at a high level" standard, we are choosing to adopt an existing standard that best fits our needs.
Initially, the proposal was to use Sphinx; however, consensus was reached that requiring additional parameter-type information on top of the method/function/class signature and the imperative mood, were both undesirable for maintenance and reading code.
The PR was changed to recommending Google-style doc-strings because it offers fewer constraints on verbage and less duplicate information from the signature.