API
docstrands.docstring(style, use_annotations=True)
Parses the docstring of a function so that it can be manipulated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
style
|
DocstringStyle
|
The style of docstring to parse. One of "rest" (aka Sphinx), "google", "numpydoc" or "epydoc". |
required |
use_annotations
|
bool
|
Whether to apply annotations from the function signature. |
True
|
Returns:
| Type | Description |
|---|---|
Callable[[Callable[P, R]], ParsedFunc[P, R]]
|
A decorator. When this is applied to a function this decorator will return a |
docstrands.ParsedFunc
dataclass
Contains a function and its parsed docstring, allowing the docstring to be manipulated.
In general ParsedFunc impersonates the original function, so it can be used in most places where the original function would be used.
A ParsedFunc should only ever be created by the docstring decorator.
copy_synopsis()
Copies the synopsis (first line) from this function to the decorated function.
copy_description()
Copies the description (everything after the synopsis that isn't in a dedicated block) from this function to the decorated function.
copy_params(*params)
Copies parameter documentation from this function to the decorated function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
str
|
The names of the parameters to copy. |
()
|
copy_returns()
Copies the return documentation from this function to the decorated function.
docstrands.Description
dataclass
Allows a description to be attached to any type annotation.