Skip to content

Commit cbec0f8

Browse files
committed
CONTRIBUTING: document the docstring style we use
1 parent 0242de4 commit cbec0f8

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

CONTRIBUTING.rst

+32
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,38 @@ without using a local copy. This can be convenient for small fixes.
8989
The built documentation should be available in ``doc/en/_build/html``,
9090
where 'en' refers to the documentation language.
9191

92+
Pytest has an API reference which in large part is
93+
`generated automatically <https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html>`_
94+
from the docstrings of the documented items. Pytest uses the
95+
`Sphinx docstring format <https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html>`_.
96+
For example:
97+
98+
.. code-block:: python
99+
100+
def my_function(arg: ArgType) -> Foo:
101+
"""Do important stuff.
102+
103+
More detailed info here, in separate paragraphs from the subject line.
104+
Use proper sentences -- start sentences with capital letters and end
105+
with periods.
106+
107+
Can include annotated documentation:
108+
109+
:param short_arg: An argument which determines stuff.
110+
:param long_arg:
111+
A long explanation which spans multiple lines, overflows
112+
like this.
113+
:returns: The result.
114+
:raises ValueError:
115+
Detailed information when this can happen.
116+
117+
.. versionadded:: 6.0
118+
119+
Including types into the annotations above is not necessary when
120+
type-hinting is being used (as in this example).
121+
"""
122+
123+
92124
.. _submitplugin:
93125

94126
Submitting Plugins to pytest-dev

0 commit comments

Comments
 (0)