default_values

Sphinx extension to show default values in documentation.

Docs

Documentation Build Status Docs Check Status

Tests

Linux Test Status Windows Test Status macOS Test Status Coverage

PyPI

PyPI - Package Version PyPI - Supported Python Versions PyPI - Supported Implementations PyPI - Wheel

Anaconda

Conda - Package Version Conda - Platform

Activity

GitHub last commit GitHub commits since tagged version Maintenance PyPI - Downloads

QA

CodeFactor Grade Flake8 Status mypy status

Other

License GitHub top language Requirements Status

Overview

This extension shows the default values in autodoc-formatted docstrings.

The default behaviour of autodoc is to turn this:

def namedlist(name: str = "NamedList") -> Callable:
    """
    A factory function to return a custom list subclass with a name.

    :param name: The name of the list.

    :return:
    """

into this:

domdf_python_tools.bases.namedlist(name='NamedList')

A factory function to return a custom list subclass with a name.

Parameters

name (str) – The name of the list.

Return type

Callable

With default_values enabled, the documentation will now look like this:

domdf_python_tools.bases.namedlist(name='NamedList')

A factory function to return a custom list subclass with a name.

Parameters

name (str) – The name of the list. Default 'NamedList'.

Return type

Callable

Default values are taken from the function/class signature. They can be overridden using the default option in the docstring. The default value can be suppressed using the no-default option.

No default value is shown if the argument does not have a default value.

The formatting of the default value can be customised using the default_description_format option in conf.py. By default this is 'Default %s'.