From cbec0f8c6ad01a3987506c27d2c0d0706d479659 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 17 Jul 2020 23:54:41 +0300 Subject: CONTRIBUTING: document the docstring style we use --- CONTRIBUTING.rst | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'CONTRIBUTING.rst') diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 0523c0ece..4481fee38 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -89,6 +89,38 @@ without using a local copy. This can be convenient for small fixes. The built documentation should be available in ``doc/en/_build/html``, where 'en' refers to the documentation language. +Pytest has an API reference which in large part is +`generated automatically `_ +from the docstrings of the documented items. Pytest uses the +`Sphinx docstring format `_. +For example: + +.. code-block:: python + + def my_function(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 short_arg: An argument which determines stuff. + :param long_arg: + A long explanation which spans multiple lines, overflows + like this. + :returns: The result. + :raises ValueError: + Detailed information when this can happen. + + .. versionadded:: 6.0 + + Including types into the annotations above is not necessary when + type-hinting is being used (as in this example). + """ + + .. _submitplugin: Submitting Plugins to pytest-dev -- cgit v1.2.3