modify_docstring

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

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'