Routines to interface docfiller with custom_inherit (docinherit
)#
Note that to use this module, you must install docstring-inheritanc
Functions:
|
Decorator interface to docstring_inheritance.inherit_numpy_docstring |
|
Decorator with docfiller inheriting from cls |
Create decorator inheriting from 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()
orstr
) – 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.