more_autodoc.typehints
¶
The changes are:
New in version 0.4.0.
Changed in version 0.6.0: Moved from sphinx_toolbox.autodoc_typehints
.
Changed in version 0.8.0: Added support for collections.namedtuple()
.
Enable sphinx_toolbox.more_autodoc.typehints
by adding the following
to the extensions
variable in your conf.py
:
extensions = [
...
'sphinx_toolbox.more_autodoc.typehints',
]
For more information see https://www.sphinx-doc.org/en/master/usage/extensions#third-party-extensions .
API Reference¶
Classes:
|
Used to represent a module, class, function etc in a Sphinx function/class signature. |
|
Used to represent a module in a Sphinx function/class signature. |
|
Used to represent a function in a Sphinx function/class signature. |
|
Used to represent a class in a Sphinx function/class signature. |
Functions:
|
Process the signature for a function/method. |
|
Process the docstring of a class, function, method etc. |
|
Format a type annotation. |
|
Returns the resolved type hints for the given objects. |
|
Data:
List of additional hooks to run in |
|
A list of 2-element tuples, comprising a function to check the default value against and a preprocessor to pass the function to if True. |
|
Type hint for default preprocessor functions. |
- class ObjectAlias(name)[source]¶
Bases:
object
Used to represent a module, class, function etc in a Sphinx function/class signature.
New in version 0.9.0.
- Parameters
name (
str
) – The name of the object being aliased.
- __repr__()[source]¶
Returns a string representation of the
ObjectAlias
.- Return type
- class Module(name)[source]¶
Bases:
ObjectAlias
Used to represent a module in a Sphinx function/class signature.
- Parameters
name (
str
) – The name of the module.
- class Function(name)[source]¶
Bases:
ObjectAlias
Used to represent a function in a Sphinx function/class signature.
New in version 0.9.0.
- Parameters
name (
str
) – The name of the function.
- class Class(name)[source]¶
Bases:
ObjectAlias
Used to represent a class in a Sphinx function/class signature.
New in version 0.9.0.
- Parameters
name (
str
) – The name of the class.
- process_signature(app, what, name, obj, options, signature, return_annotation)[source]¶
Process the signature for a function/method.
- Parameters
- Return type
Changed in version 0.8.0: Added support for factory function default values in attrs classes.
- process_docstring(app, what, name, obj, options, lines)[source]¶
Process the docstring of a class, function, method etc.
- Parameters
Changed in version 1.1.0: An empty
:rtype:
flag can be used to control the position of the return type annotation in the docstring.
- docstring_hooks¶
Type:
List
[Tuple
[Callable
[[Any
],Callable
],int
]]List of additional hooks to run in
process_docstring()
.Each entry in the list consists of:
- default_preprocessors¶
Type:
List
[Tuple
[Callable
[[Type
],bool
],Callable
[[Type
],Any
]]]A list of 2-element tuples, comprising a function to check the default value against and a preprocessor to pass the function to if True.
- setup(app)[source]¶
Setup
sphinx_toolbox.more_autodoc.typehints
.- Parameters
app (
Sphinx
) – The Sphinx application.- Return type