class documentation

class GoogleDocstring:

Known subclasses: sphinx.ext.napoleon.docstring.NumpyDocstring

View In Hierarchy

Convert Google 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.
...
... Args:
...   arg1(int): Description of `arg1`
...   arg2(str): Description of `arg2`
... Returns:
...   str: Description of return value.
... '''
>>> print(GoogleDocstring(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>
Method __init__ Undocumented
Method __str__ Return the parsed docstring in reStructuredText format.
Method ​_consume​_contiguous Undocumented
Method ​_consume​_empty Undocumented
Method ​_consume​_field Undocumented
Method ​_consume​_fields Undocumented
Method ​_consume​_indented​_block Undocumented
Method ​_consume​_inline​_attribute Undocumented
Method ​_consume​_returns​_section Undocumented
Method ​_consume​_section​_header Undocumented
Method ​_consume​_to​_end Undocumented
Method ​_consume​_to​_next​_section Undocumented
Method ​_consume​_usage​_section Undocumented
Method ​_dedent Undocumented
Method ​_escape​_args​_and​_kwargs 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 ​_is​_section​_break Undocumented
Method ​_is​_section​_header 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​_see​_also​_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 ​_directive​_sections 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 __str__(self):

Return the parsed docstring in reStructuredText format.

Returns

unicode
Unicode version of the docstring.
Returns
strUndocumented
def _consume_contiguous(self):

Undocumented

Returns
List[str]Undocumented
def _consume_empty(self):

Undocumented

Returns
List[str]Undocumented
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_fields(self, parse_type=True, prefer_type=False, multiple=False):

Undocumented

Parameters
parse​_type:boolUndocumented
prefer​_type:boolUndocumented
multiple:boolUndocumented
Returns
List[Tuple[str, str, List[str]]]Undocumented
def _consume_indented_block(self, indent=1):

Undocumented

Parameters
indent:intUndocumented
Returns
List[str]Undocumented
def _consume_inline_attribute(self):

Undocumented

Returns
Tuple[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 _consume_to_end(self):

Undocumented

Returns
List[str]Undocumented
def _consume_to_next_section(self):

Undocumented

Returns
List[str]Undocumented
def _consume_usage_section(self):

Undocumented

Returns
List[str]Undocumented
def _dedent(self, lines, full=False):

Undocumented

Parameters
lines:List[str]Undocumented
full:boolUndocumented
Returns
List[str]Undocumented
def _escape_args_and_kwargs(self, name):

Undocumented

Parameters
name:strUndocumented
Returns
strUndocumented
def _fix_field_desc(self, desc):

Undocumented

Parameters
desc:List[str]Undocumented
Returns
List[str]Undocumented
def _format_admonition(self, admonition, lines):

Undocumented

Parameters
admonition:strUndocumented
lines:List[str]Undocumented
Returns
List[str]Undocumented
def _format_block(self, prefix, lines, padding=None):

Undocumented

Parameters
prefix:strUndocumented
lines:List[str]Undocumented
padding:strUndocumented
Returns
List[str]Undocumented
def _format_docutils_params(self, fields, field_role='param', type_role='type'):

Undocumented

Parameters
fields:List[Tuple[str, str, List[str]]]Undocumented
field​_role:strUndocumented
type​_role:strUndocumented
Returns
List[str]Undocumented
def _format_field(self, _name, _type, _desc):

Undocumented

Parameters
​_name:strUndocumented
​_type:strUndocumented
​_desc:List[str]Undocumented
Returns
List[str]Undocumented
def _format_fields(self, field_type, fields):

Undocumented

Parameters
field​_type:strUndocumented
fields:List[Tuple[str, str, List[str]]]Undocumented
Returns
List[str]Undocumented
def _get_current_indent(self, peek_ahead=0):

Undocumented

Parameters
peek​_ahead:intUndocumented
Returns
intUndocumented
def _get_indent(self, line):

Undocumented

Parameters
line:strUndocumented
Returns
intUndocumented
def _get_initial_indent(self, lines):

Undocumented

Parameters
lines:List[str]Undocumented
Returns
intUndocumented
def _get_min_indent(self, lines):

Undocumented

Parameters
lines:List[str]Undocumented
Returns
intUndocumented
def _indent(self, lines, n=4):

Undocumented

Parameters
lines:List[str]Undocumented
n:intUndocumented
Returns
List[str]Undocumented
def _is_indented(self, line, indent=1):

Undocumented

Parameters
line:strUndocumented
indent:intUndocumented
Returns
boolUndocumented
def _is_list(self, lines):

Undocumented

Parameters
lines:List[str]Undocumented
Returns
boolUndocumented
def _is_section_break(self):

Undocumented

Returns
boolUndocumented
def _is_section_header(self):

Undocumented

Returns
boolUndocumented
def _load_custom_sections(self):

Undocumented

def _lookup_annotation(self, _name):

Undocumented

Parameters
​_name:strUndocumented
Returns
strUndocumented
def _parse(self):

Undocumented

def _parse_admonition(self, admonition, section):

Undocumented

Parameters
admonition:strUndocumented
section:strUndocumented
Returns
List[str]Undocumented
def _parse_attribute_docstring(self):

Undocumented

Returns
List[str]Undocumented
def _parse_attributes_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_custom_generic_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_custom_params_style_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_custom_returns_style_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_examples_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_generic_section(self, section, use_admonition):

Undocumented

Parameters
section:strUndocumented
use​_admonition:boolUndocumented
Returns
List[str]Undocumented
def _parse_keyword_arguments_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_methods_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_notes_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_other_parameters_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_parameters_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_raises_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_receives_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_references_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_returns_section(self, section):

Undocumented

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

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_usage_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_warns_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _parse_yields_section(self, section):

Undocumented

Parameters
section:strUndocumented
Returns
List[str]Undocumented
def _partition_field_on_colon(self, line):

Undocumented

Parameters
line:strUndocumented
Returns
Tuple[str, str, str]Undocumented
def _qualify_name(self, attr_name, klass):

Undocumented

Parameters
attr​_name:strUndocumented
klass:TypeUndocumented
Returns
strUndocumented
def _strip_empty(self, lines):

Undocumented

Parameters
lines:List[str]Undocumented
Returns
List[str]Undocumented
def lines(self):

Return the parsed lines of the docstring in reStructuredText format.

Returns

list(str)
The lines of the docstring in a list.
Returns
List[str]Undocumented
_name_rgx =

Undocumented

_annotations =

Undocumented

_app =

Undocumented

_config =

Undocumented

_directive_sections: List[str] =
_is_in_section: bool =

Undocumented

_line_iter =

Undocumented

_name =

Undocumented

_obj =

Undocumented

_opt =

Undocumented

_parsed_lines =

Undocumented

_section_indent: int =

Undocumented

_sections: Dict[str, Callable] =

Undocumented

_what =

Undocumented