dhlab.utils
¶
Utility functions.
Submodules¶
Package Contents¶
Functions¶
Decorator to reuse docstrings for several functions. |
|
Extract only parameter descriptions from |
API¶
- dhlab.utils._is_documented_by(original)¶
Decorator to reuse docstrings for several functions.
Fetch the docstring of another
original
function, and assign it as the docstring of the decorated function.Code copied from
StackExchange <https://softwareengineering.stackexchange.com/a/386758>
_.- Parameters:
original (Callable) – Function that is decorated
- Returns:
The
target
function, with theoriginal
docstring
Example use:
… code-block:: python
def original(args): ‘’’A complete docstring.
:param args: Arguments. ''' ...
@_is_documented_by(original) def target(args): …
- dhlab.utils._docstring_parameters_from(original, drop: str = None)¶
Extract only parameter descriptions from
original
’s docstring.Optionally, specify a
drop
parameter to skip in the parameter list, and append the rest. Can be a comma-separated string of several parameters.Otherwise, the wrapper works the same way as :func:
_is_documented_by
.