class documentation

class NumpyDocstring(GoogleDocstring):

View In Hierarchy

Convert NumPy style docstrings to reStructuredText.

Parameters

docstring : str or list of str
The docstring to parse, given either as a string or split into individual lines.
config: sphinx.ext.napoleon.Config or sphinx.config.Config
The configuration settings to use. If not given, defaults to the config object on app; or if app is not given defaults to the a new sphinx.ext.napoleon.Config object.

Other Parameters

app : sphinx.application.Sphinx, optional
Application object representing the Sphinx process.
what : str, optional
A string specifying the type of the object to which the docstring belongs. Valid values: "module", "class", "exception", "function", "method", "attribute".
name : str, optional
The fully qualified name of the object.
obj : module, class, exception, function, method, or attribute
The object to which the docstring belongs.
options : sphinx.ext.autodoc.Options, optional
The options given to the directive: an object with attributes inherited_members, undoc_members, show_inheritance and noindex that are True if the flag option of same name was given to the auto directive.

Example

>>> from sphinx.ext.napoleon import Config
>>> config = Config(napoleon_use_param=True, napoleon_use_rtype=True)
>>> docstring = '''One line summary.
...
... Extended description.
...
... Parameters
... ----------
... arg1 : int
...     Description of `arg1`
... arg2 : str
...     Description of `arg2`
... Returns
... -------
... str
...     Description of return value.
... '''
>>> print(NumpyDocstring(docstring, config))
One line summary.
<BLANKLINE>
Extended description.
<BLANKLINE>
:param arg1: Description of `arg1`
:type arg1: int
:param arg2: Description of `arg2`
:type arg2: str
<BLANKLINE>
:returns: Description of return value.
:rtype: str
<BLANKLINE>

Methods

__str__()

Return the parsed docstring in reStructuredText format.

str
UTF-8 encoded version of the docstring.
__unicode__()

Return the parsed docstring in reStructuredText format.

unicode
Unicode version of the docstring.
lines()

Return the parsed lines of the docstring in reStructuredText format.

list(str)
The lines of the docstring in a list.
Method __init__ Undocumented
Method ​_consume​_field Undocumented
Method ​_consume​_returns​_section Undocumented
Method ​_consume​_section​_header Undocumented
Method ​_escape​_args​_and​_kwargs Undocumented
Method ​_get​_location Undocumented
Method ​_is​_section​_break Undocumented
Method ​_is​_section​_header Undocumented
Method ​_parse​_numpydoc​_see​_also​_section Derived from the NumpyDoc implementation of _parse_see_also.
Method ​_parse​_see​_also​_section Undocumented
Instance Variable ​_directive​_sections Undocumented

Inherited from GoogleDocstring:

Method __str__ Return the parsed docstring in reStructuredText format.
Method ​_consume​_contiguous Undocumented
Method ​_consume​_empty Undocumented
Method ​_consume​_fields Undocumented
Method ​_consume​_indented​_block Undocumented
Method ​_consume​_inline​_attribute Undocumented
Method ​_consume​_to​_end Undocumented
Method ​_consume​_to​_next​_section Undocumented
Method ​_consume​_usage​_section Undocumented
Method ​_dedent Undocumented
Method ​_fix​_field​_desc Undocumented
Method ​_format​_admonition Undocumented
Method ​_format​_block Undocumented
Method ​_format​_docutils​_params Undocumented
Method ​_format​_field Undocumented
Method ​_format​_fields Undocumented
Method ​_get​_current​_indent Undocumented
Method ​_get​_indent Undocumented
Method ​_get​_initial​_indent Undocumented
Method ​_get​_min​_indent Undocumented
Method ​_indent Undocumented
Method ​_is​_indented Undocumented
Method ​_is​_list Undocumented
Method ​_load​_custom​_sections Undocumented
Method ​_lookup​_annotation Undocumented
Method ​_parse Undocumented
Method ​_parse​_admonition Undocumented
Method ​_parse​_attribute​_docstring Undocumented
Method ​_parse​_attributes​_section Undocumented
Method ​_parse​_custom​_generic​_section Undocumented
Method ​_parse​_custom​_params​_style​_section Undocumented
Method ​_parse​_custom​_returns​_style​_section Undocumented
Method ​_parse​_examples​_section Undocumented
Method ​_parse​_generic​_section Undocumented
Method ​_parse​_keyword​_arguments​_section Undocumented
Method ​_parse​_methods​_section Undocumented
Method ​_parse​_notes​_section Undocumented
Method ​_parse​_other​_parameters​_section Undocumented
Method ​_parse​_parameters​_section Undocumented
Method ​_parse​_raises​_section Undocumented
Method ​_parse​_receives​_section Undocumented
Method ​_parse​_references​_section Undocumented
Method ​_parse​_returns​_section Undocumented
Method ​_parse​_usage​_section Undocumented
Method ​_parse​_warns​_section Undocumented
Method ​_parse​_yields​_section Undocumented
Method ​_partition​_field​_on​_colon Undocumented
Method ​_qualify​_name Undocumented
Method ​_strip​_empty Undocumented
Method lines Return the parsed lines of the docstring in reStructuredText format.
Class Variable ​_name​_rgx Undocumented
Instance Variable ​_annotations Undocumented
Instance Variable ​_app Undocumented
Instance Variable ​_config Undocumented
Instance Variable ​_is​_in​_section Undocumented
Instance Variable ​_line​_iter Undocumented
Instance Variable ​_name Undocumented
Instance Variable ​_obj Undocumented
Instance Variable ​_opt Undocumented
Instance Variable ​_parsed​_lines Undocumented
Instance Variable ​_section​_indent Undocumented
Instance Variable ​_sections Undocumented
Instance Variable ​_what Undocumented
def __init__(self, docstring, config=None, app=None, what='', name='', obj=None, options=None):

Undocumented

Parameters
docstring:Union[str, List[str]]Undocumented
config:SphinxConfigUndocumented
app:SphinxUndocumented
what:strUndocumented
name:strUndocumented
obj:AnyUndocumented
options:AnyUndocumented
def _consume_field(self, parse_type=True, prefer_type=False):

Undocumented

Parameters
parse​_type:boolUndocumented
prefer​_type:boolUndocumented
Returns
Tuple[str, str, List[str]]Undocumented
def _consume_returns_section(self, preprocess_types=False):

Undocumented

Parameters
preprocess​_types:boolUndocumented
Returns
List[Tuple[str, str, List[str]]]Undocumented
def _consume_section_header(self):

Undocumented

Returns
strUndocumented
def _escape_args_and_kwargs(self, name):

Undocumented

Parameters
name:strUndocumented
Returns
strUndocumented
def _get_location(self):

Undocumented

Returns
strUndocumented
def _is_section_break(self):

Undocumented

Returns
boolUndocumented
def _is_section_header(self):

Undocumented

Returns
boolUndocumented
def _parse_numpydoc_see_also_section(self, content):

Derived from the NumpyDoc implementation of _parse_see_also.

See Also

func_name : Descriptive text
continued text

another_func_name : Descriptive text func_name1, func_name2, func_name, func_name3

Parameters
content:List[str]Undocumented
Returns
List[str]Undocumented
def _parse_see_also_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
_directive_sections: list[str] =