InheritDocstrings

class utilipy.utils.metaclasses.InheritDocstrings(name: str, bases: Any, dct: Dict)[source]

Bases: type

Docstring inheritance metaclass.

This metaclass makes methods of a class automatically have their docstrings filled in from the methods they override in the base class. If the class uses multiple inheritance, the docstring will be chosen from the first class in the bases list, in the same way as methods are normally resolved in Python. If this results in selecting the wrong docstring, the docstring will need to be explicitly included on the method.

For example::
>>> class A(metaclass=InheritDocstrings):
...     def wiggle(self):
...         "Wiggle the thingamajig"
...         pass
>>> class B(A):
...     def wiggle(self):
...         pass
>>> B.wiggle.__doc__
'Wiggle the thingamajig'

taken from astropy

Todo

  • add docparse tools so can merge docstrings

Set up docstring inheritance.