InheritDocstrings

class astropy.utils.misc.InheritDocstrings(name, bases, dct)[source]

Bases: type

Deprecated since version 4.0: The InheritDocstrings class is deprecated and may be removed in a future version. Use Sphinx>=1.7 automatically inherits docstring instead.

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:

>>> import warnings
>>> from astropy.utils.misc import InheritDocstrings
>>> with warnings.catch_warnings():
...     # Ignore deprecation warning
...     warnings.simplefilter('ignore')
...     class A(metaclass=InheritDocstrings):
...         def wiggle(self):
...             "Wiggle the thingamajig"
...             pass
...     class B(A):
...         def wiggle(self):
...             pass
>>> B.wiggle.__doc__
u'Wiggle the thingamajig'

Deprecated since version 4.0: The InheritDocstrings class is deprecated and may be removed in a future version. Use Sphinx>=1.7 automatically inherits docstring instead.

Create and return a new object. See help(type) for accurate signature.