Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Doc: Mention Sphinx directive for docstrings #278

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

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions 42 docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ documentation includes:

* **A docstring**

Each docstring contains a summary line, a linebreak, the description
of its arguments in `Sphinx style`_, and an optional doctest.
Each docstring contains a summary line, a linebreak, an optional
directive (see next item), the description of its arguments in
`Sphinx style`_, and an optional doctest.
The docstring is extracted and reused in the :ref:`api` section.
An appropriate docstring should look like this::

Expand All @@ -177,6 +178,43 @@ documentation includes:

"""

* **An optional directive**

If you introduce a new feature, change a function/method, or remove something,
it is a good practice to introduce Sphinx directives into the docstring.
This gives the reader an idea what version is affected by this change.

The first required argument, ``VERSION``, defines the version when this change
was introduced. You can choose from:

* ``.. versionadded:: VERSION``

Use this directive to describe a new feature.

* ``.. versionchanged:: VERSION``

Use this directive to describe when something has changed, for example,
new parameters were added, changed side effects, different return values, etc.

* ``.. deprecated:: VERSION``

Use this directive when a feature is deprecated. Describe what should
be used instead, if appropriate.


Add such a directive *after* the summary line, if needed.
An appropriate directive could look like this::

def to_tuple(self):
"""
Convert the VersionInfo object to a tuple.

.. versionadded:: 2.10.0
Renamed ``VersionInfo._astuple`` to ``VersionInfo.to_tuple`` to
make this function available in the public API.
[...]
"""

* **The documentation**

A docstring is good, but in most cases it's too dense. Describe how
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.