more_autodoc.typevars
¶
Documenter for module level typing.TypeVar
's, similar to Sphinx’s
autotypevar
but with a different appearance.
New in version 1.3.0.
Enable sphinx_toolbox.more_autodoc.typevars
by adding the following
to the extensions
variable in your conf.py
:
extensions = [
...
'sphinx_toolbox.more_autodoc.typevars',
]
For more information see https://www.sphinx-doc.org/en/master/usage/extensions#third-party-extensions .
Configuration¶
-
all_typevars
¶ - Type:
bool
Default: FalseDocument all
typing.TypeVar
s, even if they have no docstring.
-
no_unbound_typevars
¶ - Type:
bool
Default: TrueOnly document
typing.TypeVar
s that have a constraint of are bound.This option has no effect if
all_typevars
is False.
Usage¶
-
.. autotypevar::
¶ Directive to automatically document a
typing.TypeVar
.The output is based on the
autodata
directive, and takes all of its options plus these additional ones:-
:no-value:
¶ Don’t show the value of the variable.
-
:value:
value (string)¶ Show this instead of the value taken from the Python source code.
-
:no-type:
¶ Don’t show the type of the variable.
-
API Reference¶
Classes:
|
Alternative version of |
Functions:
|
Unskip undocumented |
|
-
class
TypeVarDocumenter
(directive, name, indent='')[source]¶ Bases:
VariableDocumenter
Alternative version of
sphinx.ext.autodoc.TypeVarDocumenter
with better type hint rendering.Specialized Documenter subclass for
typing.TypeVar
s.Methods:
can_document_member
(member, membername, …)Called to see if a member can be documented by this documenter.
resolve_type
(forward_ref)Resolve a
typing.ForwardRef
using the module theTypeVar
belongs to.add_content
(more_content[, no_docstring])Add content from docstrings, attribute documentation and user.
add_directive_header
(sig)Add the directive’s header.
get_doc
([encoding, ignore])Decode and return lines of the docstring(s) for the object.
-
classmethod
can_document_member
(member, membername, isattr, parent)[source]¶ Called to see if a member can be documented by this documenter.
-
resolve_type
(forward_ref)[source]¶ Resolve a
typing.ForwardRef
using the module theTypeVar
belongs to.- Parameters
forward_ref (
ForwardRef
)- Return type
-
classmethod
-
unskip_typevars
(app, what, name, obj, skip, options)[source]¶ Unskip undocumented
typing.TypeVar
s ifall_typevars
isTrue
.- Parameters
app (
Sphinx
) – The Sphinx application.what (
str
) – The type of the object which the docstring belongs to (one of'module'
,'class'
,'exception'
,'function'
,'method'
,'attribute'
).name (
str
) – The fully qualified name of the object.obj (
Any
) – The object itself.skip (
bool
) – A boolean indicating if autodoc will skip this member if the user handler does not override the decision.options (
Dict
[str
,Any
]) – The options given to the directive: an object with attributesinherited_members
,undoc_members
,show_inheritance
andnoindex
that are true if the flag option of same name was given to the auto directive.
- Return type
-
setup
(app)[source]¶ Setup
sphinx_toolbox.more_autodoc.typevars
.- Parameters
app (
Sphinx
) – The Sphinx application.- Return type