module sphinxext.sphinx_autosignature
¶
Short summary¶
module pyquickhelper.sphinxext.sphinx_autosignature
Defines a sphinx extension to describe a function, inspired from autofunction and AutoDirective.
Classes¶
class |
truncated documentation |
---|---|
Defines autosignature node. |
|
This directive displays a shorter signature than sphinx.ext.autodoc. Available options: |
Functions¶
function |
truncated documentation |
---|---|
What to do when leaving a node |
|
Removes annotation from a signature extracted with |
|
Looks for substring like the following and clean the signature to be able to use function _signature_fromstr. |
|
Create a new directive called autosignature which displays the signature of the function. |
|
What to do when visiting a node |
Properties¶
property |
truncated documentation |
---|---|
|
Return the document root node of the tree containing this Node. |
Static Methods¶
staticmethod |
truncated documentation |
---|---|
Formats the number of spaces in front every line to be equal to a specific value. |
Methods¶
method |
truncated documentation |
---|---|
Extracts methods of a class and document them. |
|
Builds the list of parameters. |
|
Extracts the part of the docstring before the parameters. |
|
|
Documentation¶
Defines a sphinx extension to describe a function, inspired from autofunction and AutoDirective.
- class pyquickhelper.sphinxext.sphinx_autosignature.AutoSignatureDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]¶
Bases:
Directive
This directive displays a shorter signature than sphinx.ext.autodoc. Available options:
nosummary: do not display a summary (shorten)
annotation: shows annotation
nolink: if False, add a link to a full documentation (produced by sphinx.ext.autodoc)
members: shows members of a class
path: three options, full displays the full path including submodules, name displays the last name, import displays the shortest syntax to import it (default).
debug: diplays debug information
syspath: additional paths to add to
sys.path
before importing, ‘;’ separated list
The signature is not always available for builtin functions or C++ functions depending on the way to bind them to Python. See Set the __text_signature__ attribute of callables.
The signature may not be infered by module
inspect
if the function is a compiled C function. In that case, the signature must be added to the documentation. It will parsed by autosignature with by functionenumerate_extract_signature
with regular expressions.- autosignature_class[source]¶
alias of
autosignature_node
- build_members(obj, members, object_name, annotation, summary)[source]¶
Extracts methods of a class and document them.
- build_parameters_list(parameters, annotation)[source]¶
Builds the list of parameters.
- Parameters:
parameters – list of Parameters
annotation – add annotation
- Returns:
string (RST format)
- build_summary(docstring)[source]¶
Extracts the part of the docstring before the parameters.
- Parameters:
docstring – document string
- Returns:
string
- option_spec = {'annotation': <function unchanged>, 'debug': <function unchanged>, 'members': <function unchanged>, 'nolink': <function unchanged>, 'nosummary': <function unchanged>, 'path': <function unchanged>, 'syspath': <function unchanged>}[source]¶
Mapping of option names to validator functions.
- class pyquickhelper.sphinxext.sphinx_autosignature.autosignature_node(rawsource='', *children, **attributes)[source]¶
Bases:
Structural
,Element
Defines autosignature node.
- pyquickhelper.sphinxext.sphinx_autosignature.depart_autosignature_node(self, node)[source]¶
What to do when leaving a node
autosignature_node
.
- pyquickhelper.sphinxext.sphinx_autosignature.enumerate_cleaned_signature(doc, max_args=20)[source]¶
Removes annotation from a signature extracted with
enumerate_extract_signature
.- Parameters:
doc – text to parse
max_args – maximum number of parameters
- Returns:
iterator of found signatures
- pyquickhelper.sphinxext.sphinx_autosignature.enumerate_extract_signature(doc, max_args=20)[source]¶
Looks for substring like the following and clean the signature to be able to use function _signature_fromstr.
- Parameters:
doc – text to parse
max_args – maximum number of parameters
- Returns:
iterator of found signatures
__init__(self: cpyquickhelper.numbers.weighted_number.WeightedDouble, value: float, weight: float=1.0) -> None
It is limited to 20 parameters.
- pyquickhelper.sphinxext.sphinx_autosignature.setup(app)[source]¶
Create a new directive called autosignature which displays the signature of the function.
- pyquickhelper.sphinxext.sphinx_autosignature.visit_autosignature_node(self, node)[source]¶
What to do when visiting a node
autosignature_node
.