Preferred docstring style
See original GitHub issuepytest uses various docstring styles, which also leaks to the documentation, and I’m starting to develop an OCD from this!
I propose we use this style:
def func(arg: ArgType) -> Foo:
"""Do important stuff.
More detailed info here, in separate paragraphs from the subject line.
Use proper sentences -- start sentences with capital letters and end with periods.
Can include annotated documentation:
:param ArgType arg: an argument which determines stuff.
:returns the result.
:rtype Foo
:raises ValueError
"""
After we agree on a style I’ll make a sweep over the code (possibly gradual) to update to it.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9 (9 by maintainers)
Top Results From Across the Web
What are the most common Python docstring formats?
There follows the main used formats for docstrings. - Epytext. Historically a javadoc like style was prevalent, so it was taken as a...
Read more >3 Different Docstring Formats for Python | by Yash Salvi
3 Different Docstring Formats for Python · 1. Google Docstring · 2. NumPy Docstring · 3. Sphinx Docstring.
Read more >Style guide — numpydoc v1.6.0rc1.dev0 Manual
The docstring consists of a number of sections separated by headings (except for the deprecation warning). Each heading should be underlined in hyphens,...
Read more >Google Python Style Guide
Python uses docstrings to document code. A docstring is a string that is the first statement in a package, module, class or function....
Read more >PEP 257 – Docstring Conventions
A docstring is a string literal that occurs as the first statement in a ... The preferred form for such a docstring would...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
IIRC I was using sphinx-autodoc-typehints extension to show the annotations correctly. Not sure if it will fit here, but might be worth checking.