Usage

Add structured information to the end of your python docstrings.

get_docdata(obj)[source]

Get the docdata if it is available.

Return type

Any

parse_docdata(obj=None, *, delimiter='---', formatter=None)[source]

Parse the structured data from the end of the docstr and store it in __docdata__.

The data after the delimiter should be in the YAML form. It is parsed with yaml.safe_load() then stored in the __docdata__ field of the object.

Parameters
  • obj (Optional[TypeVar(X)]) – Any object that can has a __doc__ field.

  • delimiter (str) – The delimiter between the actual docstring and structured YAML.

  • formatter (Optional[Callable[[Any], str]]) – A function that takes the parsed docdata and turns it into more documentation

Return type

Union[TypeVar(X), Callable[[TypeVar(X)], TypeVar(X)]]

Returns

The same object with a modified docstr.

Raises

AttributeError – if the object has no __doc__ field.