MODULE

MKAPI.CORE.INHERIT

This module implements the functionality of docstring inheritance.

Functions
  • get_bases(node) (Node, iterator of Node) Yields a tuple of (Node instance, iterator of Node).</>
  • get_section(node, name, mode) (Section) Returns a tuple of (docstring section, signature section).</>
  • inherit(node) Inherits Parameters and Attributes from superclasses.</>
  • inherit_base(node, base, name) Inherits Parameters or Attributes section from base class.</>
  • is_complete(node, name) (bool) Returns True if docstring is complete.</>
function

mkapi.core.inherit.get_section(node, name, mode)Section

Returns a tuple of (docstring section, signature section).

Parameters
  • node (Node) Node instance.
  • name (str) Section name: Parameters or Attributes.
  • mode (str) Mode name: Docstring or Signature.
Examples
>>> node = get_node('mkapi.core.base.Type')
>>> section = get_section(node, 'Parameters', 'Docstring')
>>> 'name' in section
True
>>> section['name'].to_tuple()
('name', 'str, optional', '')
function

mkapi.core.inherit.is_complete(node, name='both') → bool

Returns True if docstring is complete.

Parameters
  • node (Node) Node instance.
  • name (str, optional) Section name: 'Parameters' or 'Attributes', or 'both'. If name is 'both', both sections are checked.
Examples
>>> from mkapi.core.object import get_object
>>> node = Node(get_object('mkapi.core.base.Base'))
>>> is_complete(node, 'Parameters')
True
>>> node = Node(get_object('mkapi.core.base.Type'))
>>> is_complete(node)
False
function

mkapi.core.inherit.inherit_base(node, base, name='both')

Inherits Parameters or Attributes section from base class.

Parameters
  • node (Node) Node instance.
  • base (Node) Node instance of a super class.
  • name (str, optional) Section name: 'Parameters' or 'Attributes', or 'both'. If name is 'both', both sections are inherited.
Examples
>>> from mkapi.core.object import get_object
>>> base = Node(get_object('mkapi.core.base.Base'))
>>> node = Node(get_object('mkapi.core.base.Type'))
>>> node.docstring['Parameters']['name'].to_tuple()
('name', 'str, optional', '')
>>> inherit_base(node, base)
>>> node.docstring['Parameters']['name'].to_tuple()
('name', 'str, optional', 'Name of self.')
generator

mkapi.core.inherit.get_bases(node) → (Node, iterator of Node)

Yields a tuple of (Node instance, iterator of Node).

Parameters
  • node (Node) Node instance.
Examples
>>> from mkapi.core.object import get_object
>>> node = Node(get_object('mkapi.core.base.Type'))
>>> it = get_bases(node)
>>> n, gen = next(it)
>>> n is node
True
>>> [x.object.name for x in gen]
['Inline', 'Base']
>>> for n, gen in it:
...     if n.object.name == 'set_html':
...         break
>>> [x.object.name for x in gen]
['set_html', 'set_html']
function

mkapi.core.inherit.inherit(node)

Inherits Parameters and Attributes from superclasses.

Parameters
  • node (Node) Node instance.