module sphinxext.sphinx_autosignature

Inheritance diagram of pyquickhelper.sphinxext.sphinx_autosignature

Short summary

module pyquickhelper.sphinxext.sphinx_autosignature

Defines a sphinx extension to describe a function, inspired from autofunction and AutoDirective.

source on GitHub

Classes

class

truncated documentation

autosignature_node

Defines autosignature node.

AutoSignatureDirective

This directive displays a shorter signature than sphinx.ext.autodoc. Available options:

Functions

function

truncated documentation

depart_autosignature_node

What to do when leaving a node autosignature_node.

enumerate_cleaned_signature

Removes annotation from a signature extracted with enumerate_extract_signature().

enumerate_extract_signature

Looks for substring like the following and clean the signature to be able to use function _signature_fromstr.

setup

Create a new directive called autosignature which displays the signature of the function.

visit_autosignature_node

What to do when visiting a node autosignature_node.

Static Methods

staticmethod

truncated documentation

reformat

Formats the number of spaces in front every line to be equal to a specific value.

Methods

method

truncated documentation

build_members

Extracts methods of a class and document them.

build_parameters_list

Builds the list of parameters.

build_summary

Extracts the part of the docstring before the parameters.

run

Documentation

Defines a sphinx extension to describe a function, inspired from autofunction and AutoDirective.

source on GitHub

class pyquickhelper.sphinxext.sphinx_autosignature.AutoSignatureDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source][source]

Bases: docutils.parsers.rst.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 function enumerate_extract_signature with regular expressions.

source on GitHub

autosignature_class[source]

alias of autosignature_node

build_members(obj, members, object_name, annotation, summary)[source][source]

Extracts methods of a class and document them.

source on GitHub

build_parameters_list(parameters, annotation)[source][source]

Builds the list of parameters.

Parameters
  • parameters – list of Parameters

  • annotation – add annotation

Returns

string (RST format)

source on GitHub

build_summary(docstring)[source][source]

Extracts the part of the docstring before the parameters.

Parameters

docstring – document string

Returns

string

source on GitHub

static reformat(text, indent=4)[source][source]

Formats the number of spaces in front every line to be equal to a specific value.

Parameters
  • text – text to analyse

  • indent – specify the expected indentation for the result

Returns

number

source on GitHub

class pyquickhelper.sphinxext.sphinx_autosignature.autosignature_node(rawsource='', *children, **attributes)[source][source]

Bases: docutils.nodes.Structural, docutils.nodes.Element

Defines autosignature node.

source on GitHub

__slotnames__ = [][source]
pyquickhelper.sphinxext.sphinx_autosignature.depart_autosignature_node(self, node)[source][source]

What to do when leaving a node autosignature_node.

source on GitHub

pyquickhelper.sphinxext.sphinx_autosignature.enumerate_cleaned_signature(doc, max_args=20)[source][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

source on GitHub

pyquickhelper.sphinxext.sphinx_autosignature.enumerate_extract_signature(doc, max_args=20)[source][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.

source on GitHub

pyquickhelper.sphinxext.sphinx_autosignature.setup(app)[source][source]

Create a new directive called autosignature which displays the signature of the function.

source on GitHub

pyquickhelper.sphinxext.sphinx_autosignature.visit_autosignature_node(self, node)[source][source]

What to do when visiting a node autosignature_node.

source on GitHub