Usage

Add structured information to the end of your python docstrings.

get_docdata(obj: X) Any[source]

Get the docdata if it is available.

parse_docdata(obj: X | None = None, *, delimiter: str = '---', formatter: Callable[[Any], str] | None = None) X | Callable[[X], X][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 – Any object that can has a __doc__ field.

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

  • formatter – A function that takes the parsed docdata and turns it into more documentation

Returns:

The same object with a modified docstr.

Raises:

AttributeError – if the object has no __doc__ field.