quemb.shared.helper.add_docstring¶
- quemb.shared.helper.add_docstring(doc)¶
Add a docstring to a function as decorator.
Is useful for programmatically generating docstrings.
- Parameters:
doc (str) – A docstring.
- Return type:
Callable
[[TypeVar
(Function
, bound=Callable
)],TypeVar
(Function
, bound=Callable
)]
Example
>>> @add_docstring("Returns 'asdf'") >>> def f(): >>> return 'asdf' is equivalent to >>> def f(): >>> "Returns 'asdf'" >>> return 'asdf'