LSSTApplications  20.0.0
LSSTDataManagementBasePackage
Functions
lsst.utils.inheritDoc Namespace Reference

Functions

def inheritDoc (klass)
 

Function Documentation

◆ inheritDoc()

def lsst.utils.inheritDoc.inheritDoc (   klass)
Extends existing documentation for a method that exists in another
class and extend it with any additional documentation defined.

This decorator takes a class from which to draw documentation from as an
argument. This is so that any class may be used as a source of documentation
and not just the immediate parent of a class. This is useful when there may
be a long inheritance chain, or in the case of mixins.

Parameters
----------
klass : object
    The class to inherit documentation from.

Returns
-------
decorator : callable
    Intermediate decorator used in the documentation process.

Definition at line 23 of file inheritDoc.py.

23 def inheritDoc(klass):
24  """Extends existing documentation for a method that exists in another
25  class and extend it with any additional documentation defined.
26 
27  This decorator takes a class from which to draw documentation from as an
28  argument. This is so that any class may be used as a source of documentation
29  and not just the immediate parent of a class. This is useful when there may
30  be a long inheritance chain, or in the case of mixins.
31 
32  Parameters
33  ----------
34  klass : object
35  The class to inherit documentation from.
36 
37  Returns
38  -------
39  decorator : callable
40  Intermediate decorator used in the documentation process.
41  """
42  def tmpDecorator(method):
43  """Decorator to update the documentation from a class with the same method
44  """
45  methodName = method.__name__
46  if not hasattr(klass, methodName):
47  raise AttributeError(f"{klass} has no method named {methodName} to inherit from")
48  appendText = method.__doc__ or ""
49  method.__doc__ = getattr(klass, methodName).__doc__ + appendText
50  return method
51  return tmpDecorator
lsst::utils.inheritDoc.inheritDoc
def inheritDoc(klass)
Definition: inheritDoc.py:23