MODULE

MKAPI.CORE.DOCSTRING

This module provides functions that parse docstring.

Functions
function

mkapi.core.docstring.section_heading(line) → (str, str)

Returns a tuple of (section name, style name).

Parameters
  • line (str) Docstring line.
Examples
>>> section_heading("Args:")
('Args', 'google')
>>> section_heading("Raises")
('Raises', 'numpy')
>>> section_heading("other")
('', '')
generator

mkapi.core.docstring.split_section(doc) → (str, str, str)

Yields a tuple of (section name, contents, style).

Parameters
  • doc (str) Docstring
Examples
>>> doc = "abc\n\nArgs:\n    x: X\n"
>>> it = split_section(doc)
>>> next(it)
('', 'abc', '')
>>> next(it)
('Parameters', 'x: X', 'google')
generator

mkapi.core.docstring.split_parameter(doc) → list of str

Yields a list of parameter string.

Parameters
  • doc (str) Docstring
function

mkapi.core.docstring.parse_parameter(lines, style)Item

Returns a Item instance that represents a parameter.

Parameters
  • lines (list of str) Splitted parameter docstring lines.
  • style (str) Docstring style. google or numpy.
function

mkapi.core.docstring.parse_parameters(doc, style) → list of Item

Returns a list of Item.

Parameters
  • doc (str)
  • style (str)
function

mkapi.core.docstring.parse_returns(doc, style) → (str, str)

Returns a tuple of (type, markdown).

Parameters
  • doc (str)
  • style (str)
function

mkapi.core.docstring.get_section(name, doc, style)Section

Returns a Section instance.

Parameters
  • name (str)
  • doc (str)
  • style (str)
function

mkapi.core.docstring.parse_bases(doc, obj)

Parses base classes to create a Base(s) line.

Parameters
function

mkapi.core.docstring.parse_source(doc, obj)

Parses parameters' docstring to inspect type and description from source.

Parameters
Examples
>>> from mkapi.core.base import Base
>>> doc = Docstring()
>>> parse_source(doc, Base)
>>> section = doc['Parameters']
>>> section['name'].to_tuple()
('name', 'str, optional', 'Name of self.')
>>> section = doc['Attributes']
>>> section['html'].to_tuple()
('html', 'str', 'HTML output after conversion.')
function

mkapi.core.docstring.get_docstring(obj)Docstring

Returns a Docstring instance.

Parameters
  • obj (any)