Twisted
Home FAQ Docs Download Timeline Roadmap View Tickets Search
module documentation

Classes for google-style and numpy-style docstring conversion.

Forked from sphinx.ext.napoleon.docstring.

:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
Class Field Represent a field with a name and/or a type and/or a description. Commonly a parameter description. It's also used for Returns section and other sections structured with fields.
Class GoogleDocstring Convert Google style docstrings to reStructuredText.
Class ITokenizer A tokenizer for annotations.
Class NumpyDocstring Convert NumPy style docstrings to reStructuredText.
Class Token A token in a type specification.
Class Tokenizer A tokenizer for string annotations.
Class TokenType Undocumented
Class TypeDocstring Convert natural language type strings to reStructuredText.
Exception FreeFormException Exception to encapsulate the converted lines when numpy-style fields get treated as free form.
Function is_google_typed_arg Is this string a valid type expression and/or google-style field name and type expression in parenthesis?
Function is_obj_identifier Is this string a Python object(s) identifier?
Function is_type Is this string a type expression that can be parsed by TypeDocstring without generating any warnings?
Type Variable _T Undocumented
Variable _bullet_list_regex Undocumented
Variable _directive_regex Undocumented
Variable _enumerated_list_regex Undocumented
Variable _google_section_regex Undocumented
Variable _google_typed_arg_regex Undocumented
Variable _numpy_section_regex Undocumented
Variable _single_colon_regex Undocumented
Variable _xref_or_code_regex Undocumented
Variable _xref_regex Undocumented
def is_google_typed_arg(string: str, parse_type: bool = True) -> bool: (source)

Is this string a valid type expression and/or google-style field name and type expression in parenthesis?

Valid strings are like:

param (list(str), optional)
list(str), optional
ValueError

When parse_type=True (default), this multi-word field name and type is even recognized:

multiple words parameter (list(str), optional)
Note
Behave exactly like is_type if parse_type=False.
def is_obj_identifier(string: str) -> bool: (source)

Is this string a Python object(s) identifier?

An object identifier is a valid type string. But a valid type can be more complex than an object identifier.

def is_type(string: str) -> bool: (source)

Is this string a type expression that can be parsed by TypeDocstring without generating any warnings?

See Also
TypeDocstring
Note
Some string will be parsed without warnings even if is_type returns False.

Undocumented

Value
TypeVar('_T',
        covariant=True)
_bullet_list_regex = (source)

Undocumented

_directive_regex = (source)

Undocumented

_enumerated_list_regex = (source)

Undocumented

_google_section_regex = (source)

Undocumented

_google_typed_arg_regex = (source)

Undocumented

_numpy_section_regex = (source)

Undocumented

_single_colon_regex = (source)

Undocumented

_xref_or_code_regex = (source)

Undocumented

_xref_regex = (source)

Undocumented