doctools

Utilities for documenting functions, classes and methods.

Data:

_F

Invariant TypeVar bound to typing.Callable[…, typing.Any].

_T

Invariant TypeVar bound to typing.Type.

Functions:

append_docstring_from(original)

Decorator to appends the docstring from the original function to the target function.

append_doctring_from_another(target, original)

Sets the docstring of the target function to that of the original function.

deindent_string(string)

Removes all indentation from the given string.

document_object_from_another(target, original)

Sets the docstring of the target function to that of the original function.

is_documented_by(original)

Decorator to set the docstring of the target function to that of the original function.

make_sphinx_links(input_string[, builtins_list])

Make proper sphinx links out of double-backticked strings in docstring.

prettify_docstrings(obj)

Decorator to prettify the default object docstrings for use in Sphinx documentation.

sphinxify_docstring()

Decorator to make proper sphinx links out of double-backticked strings in the docstring.

_F = TypeVar(_F, bound=typing.Callable[..., typing.Any])

Type:    TypeVar

Invariant TypeVar bound to typing.Callable[…, typing.Any].

_T = TypeVar(_T, bound=typing.Type)

Type:    TypeVar

Invariant TypeVar bound to typing.Type.

append_docstring_from(original)[source]

Decorator to appends the docstring from the original function to the target function.

This may be useful for subclasses or wrappers that use the same arguments.

Any indentation in either docstring is removed to ensure consistent indentation between the two docstrings. Bear this in mind if additional indentation is used in the docstring.

Parameters

original (Callable)

Return type

Callable[[~_F], ~_F]

append_doctring_from_another(target, original)[source]

Sets the docstring of the target function to that of the original function.

This may be useful for subclasses or wrappers that use the same arguments.

Any indentation in either docstring is removed to ensure consistent indentation between the two docstrings. Bear this in mind if additional indentation is used in the docstring.

Parameters
deindent_string(string)[source]

Removes all indentation from the given string.

Parameters

string (Optional[str]) – The string to deindent

Return type

str

Returns

The string without indentation

document_object_from_another(target, original)[source]

Sets the docstring of the target function to that of the original function.

This may be useful for subclasses or wrappers that use the same arguments.

Parameters
is_documented_by(original)[source]

Decorator to set the docstring of the target function to that of the original function.

This may be useful for subclasses or wrappers that use the same arguments.

Parameters

original (Callable)

Return type

Callable[[~_F], ~_F]

Make proper sphinx links out of double-backticked strings in docstring.

i.e. ``str`` becomes :class:`str`

Make sure to include the following in your conf.py file for Sphinx:

intersphinx_mapping = {"python": ("https://docs.python.org/3/", None)}
Parameters
  • input_string (str) – The string to process.

  • builtins_list (Optional[Sequence[str]]) – A list of builtins to make links for. Default dir(builtins).

Return type

str

Returns

Processed string with links.

prettify_docstrings(obj)[source]

Decorator to prettify the default object docstrings for use in Sphinx documentation.

New in version 0.8.0.

Parameters

obj (~_T) – The object to prettify the method docstrings for.

Return type

~_T

sphinxify_docstring()[source]

Decorator to make proper sphinx links out of double-backticked strings in the docstring.

i.e. ``str`` becomes :class:`str`

Make sure to include the following in your conf.py file for Sphinx:

intersphinx_mapping = {
    "python": ("https://docs.python.org/3/", None),
}
Return type

Callable[[~_F], ~_F]