summaryrefslogtreecommitdiff
path: root/doc/usage/extensions/autodoc.rst
diff options
context:
space:
mode:
Diffstat (limited to 'doc/usage/extensions/autodoc.rst')
-rw-r--r--doc/usage/extensions/autodoc.rst162
1 files changed, 106 insertions, 56 deletions
diff --git a/doc/usage/extensions/autodoc.rst b/doc/usage/extensions/autodoc.rst
index a07042781..1bfa8086c 100644
--- a/doc/usage/extensions/autodoc.rst
+++ b/doc/usage/extensions/autodoc.rst
@@ -89,33 +89,96 @@ inserting them into the page source under a suitable :rst:dir:`py:module`,
Boil the noodle *time* minutes.
- **Options and advanced usage**
+ .. rubric:: Options
+
+ .. rst:directive:option:: members
+ :type: no value or comma separated list
+
+ If set, autodoc will generate document for the members of the target
+ module, class or exception.
- * If you want to automatically document members, there's a ``members``
- option::
+ For example::
.. automodule:: noodle
:members:
- will document all module members (recursively), and ::
+ will document all module members (recursively), and ::
.. autoclass:: Noodle
:members:
- will document all non-private member functions and properties (that is,
- those whose name doesn't start with ``_``).
+ will document all class member methods and properties.
- For modules, ``__all__`` will be respected when looking for members unless
- you give the ``ignore-module-all`` flag option. Without
- ``ignore-module-all``, the order of the members will also be the order in
- ``__all__``.
+ By default, autodoc will not generate document for the members that are
+ private, not having docstrings, inherited from super class, or special
+ members.
- You can also give an explicit list of members; only these will then be
- documented::
+ For modules, ``__all__`` will be respected when looking for members unless
+ you give the ``ignore-module-all`` flag option. Without
+ ``ignore-module-all``, the order of the members will also be the order in
+ ``__all__``.
+
+ You can also give an explicit list of members; only these will then be
+ documented::
.. autoclass:: Noodle
:members: eat, slurp
+ .. rst:directive:option:: undoc-members
+ :type: no value
+
+ If set, autodoc will also generate document for the members not having
+ docstrings::
+
+ .. automodule:: noodle
+ :members:
+ :undoc-members:
+
+ .. rst:directive:option:: private-members
+ :type: no value or comma separated list
+
+ If set, autodoc will also generate document for the private members
+ (that is, those named like ``_private`` or ``__private``)::
+
+ .. automodule:: noodle
+ :members:
+ :private-members:
+
+ It can also take an explicit list of member names to be documented as
+ arguments::
+
+ .. automodule:: noodle
+ :members:
+ :private-members: _spicy, _garlickly
+
+ .. versionadded:: 1.1
+ .. versionchanged:: 3.2
+ The option can now take arguments.
+
+ .. rst:directive:option:: special-members
+ :type: no value or comma separated list
+
+ If set, autodoc will also generate document for the special members
+ (that is, those named like ``__special__``)::
+
+ .. autoclass:: my.Class
+ :members:
+ :special-members:
+
+ It can also take an explicit list of member names to be documented as
+ arguments::
+
+ .. autoclass:: my.Class
+ :members:
+ :special-members: __init__, __name__
+
+ .. versionadded:: 1.1
+
+ .. versionchanged:: 1.2
+ The option can now take arguments
+
+ **Options and advanced usage**
+
* If you want to make the ``members`` option (or other options described
below) the default, see :confval:`autodoc_default_options`.
@@ -139,31 +202,6 @@ inserting them into the page source under a suitable :rst:dir:`py:module`,
.. versionchanged:: 3.5
The default options can be overridden or extended temporarily.
- * Members without docstrings will be left out, unless you give the
- ``undoc-members`` flag option::
-
- .. automodule:: noodle
- :members:
- :undoc-members:
-
- * "Private" members (that is, those named like ``_private`` or ``__private``)
- will be included if the ``private-members`` flag option is given::
-
- .. automodule:: noodle
- :members:
- :private-members:
-
- It can also take an explicit list of member names to be documented as
- arguments::
-
- .. automodule:: noodle
- :members:
- :private-members: _spicy, _garlickly
-
- .. versionadded:: 1.1
- .. versionchanged:: 3.2
- The option can now take arguments.
-
* autodoc considers a member private if its docstring contains
``:meta private:`` in its :ref:`info-field-lists`.
For example:
@@ -203,21 +241,6 @@ inserting them into the page source under a suitable :rst:dir:`py:module`,
.. versionadded:: 3.5
- * Python "special" members (that is, those named like ``__special__``) will
- be included if the ``special-members`` flag option is given::
-
- .. autoclass:: my.Class
- :members:
- :private-members:
- :special-members:
-
- would document both "private" and "special" members of the class.
-
- .. versionadded:: 1.1
-
- .. versionchanged:: 1.2
- The option can now take arguments, i.e. the special members to document.
-
* For classes and exceptions, members inherited from base classes will be
left out when documenting all members, unless you give the
``inherited-members`` option, in addition to ``members``::
@@ -506,15 +529,19 @@ There are also config values that you can set:
looks like a signature, use the line as the signature and remove it from the
docstring content.
- If the signature line ends with backslash, autodoc considers the function has
- multiple signatures and look at the next line of the docstring. It is useful
- for overloaded function.
+ autodoc will continue to look for multiple signature lines,
+ stopping at the first line that does not look like a signature.
+ This is useful for declaring overloaded function signatures.
.. versionadded:: 1.1
.. versionchanged:: 3.1
Support overloaded signatures
+ .. versionchanged:: 4.0
+
+ Overloaded signatures do not need to be separated by a backslash
+
.. confval:: autodoc_mock_imports
This value contains a list of modules to be mocked up. This is useful when
@@ -548,6 +575,19 @@ There are also config values that you can set:
New option ``'description'`` is added.
+.. confval:: autodoc_typehints_description_target
+
+ This value controls whether the types of undocumented parameters and return
+ values are documented when ``autodoc_typehints`` is set to ``description``.
+
+ The default value is ``"all"``, meaning that types are documented for all
+ parameters and return values, whether they are documented or not.
+
+ When set to ``"documented"``, types will only be documented for a parameter
+ or a return value that is already documented by the docstring.
+
+ .. versionadded:: 4.0
+
.. confval:: autodoc_type_aliases
A dictionary for users defined `type aliases`__ that maps a type name to the
@@ -586,6 +626,16 @@ There are also config values that you can set:
.. __: https://mypy.readthedocs.io/en/latest/kinds_of_types.html#type-aliases
.. versionadded:: 3.3
+.. confval:: autodoc_preserve_defaults
+
+ If True, the default argument values of functions will be not evaluated on
+ generating document. It preserves them as is in the source code.
+
+ .. versionadded:: 4.0
+
+ Added as an experimental feature. This will be integrated into autodoc core
+ in the future.
+
.. confval:: autodoc_warningiserror
This value controls the behavior of :option:`sphinx-build -W` during
@@ -597,7 +647,7 @@ There are also config values that you can set:
This value controls the docstrings inheritance.
If set to True the docstring for classes or methods, if not explicitly set,
- is inherited form parents.
+ is inherited from parents.
The default is ``True``.