Routines to interface docfiller with custom_inherit (docinherit)#

Note that to use this module, you must install docstring-inheritanc

Functions:

doc_inherit(parent)

Decorator interface to docstring_inheritance.inherit_numpy_docstring

factory_docfiller_from_parent(cls, docfiller)

Decorator with docfiller inheriting from cls

factory_docinherit_from_parent(cls)

Create decorator inheriting from cls

factory_docfiller_inherit_from_parent(cls, ...)

Do combination of doc_inherit and docfiller

module_utilities.docinherit.doc_inherit(parent)[source]#

Decorator interface to docstring_inheritance.inherit_numpy_docstring

Parameters:

parent (callable() or str) – Parent function to inherit from.

Returns:

decorator (callable())

Examples

>>> from module_utilities.docfiller import DocFiller, indent_docstring
>>> template = '''
... Parameters
... ----------
... x : {type_}
...     x parameter
... y : {type_}
...     y parameter
... '''
>>> d_int = DocFiller.from_docstring(template.format(type_="int"), combine_keys='parameters')
>>> d_float = DocFiller.from_docstring(template.format(type_="float"), combine_keys='parameters')
>>> @d_int.decorate
... def func(x, y):
...     '''
...     A function
...
...     Parameters
...     ----------
...     {x}
...     {y}
...     '''
...     pass
>>> @d_float.inherit(func)
... def func1(x, y, z):
...     '''
...     A new function
...
...     Parameters
...     ----------
...     z : str
...         z parameter
...     '''
...     pass
>>> print(indent_docstring(func))
+  A function

+  Parameters
+  ----------
+  x : int
+      x parameter
+  y : int
+      y parameter
>>> print(indent_docstring(func1))
+  A new function

+  Parameters
+  ----------
+  x : float
+      x parameter
+  y : float
+      y parameter
+  z : str
+      z parameter
module_utilities.docinherit.factory_docfiller_from_parent(cls, docfiller)[source]#

Decorator with docfiller inheriting from cls

Note this returns a factory itself.

module_utilities.docinherit.factory_docinherit_from_parent(cls)[source]#

Create decorator inheriting from cls

module_utilities.docinherit.factory_docfiller_inherit_from_parent(cls, docfiller)[source]#

Do combination of doc_inherit and docfiller

  1. Fill parent and child with docfiller (from this module).

  2. Merge using doc_inherit