modify_docstring

plasmapy.utils.decorators.modify_docstring(func=None, prepend: Optional[str] = None, append: Optional[str] = None)

A decorator which programmatically prepends and/or appends the docstring of the decorated method/function. The unmodified/original docstring is saved as the __original_doc__ attribute.

Parameters
  • func (callable) – The method/function to be decorated.

  • prepend (str) – The string to be prepended to the func’s docstring.

  • append (str) – The string to be appended to the func’s docstring.

Returns

Wrapped version of the function.

Return type

callable

Examples

>>> @modify_docstring(prepend='''Hello''', append='''World''')
... def foo():
...     '''Beautiful'''
...     pass
>>> foo.__original_doc__
'Beautiful'
>>> foo.__doc__
'Hello\n\nBeautiful\n\nWorld'