Skip to main content

sphinx-autodoc-defaultargs

PyPi Version Build Status Coverage Status License Python Versions

Overview

This extension automatically generates default arguments for the Sphinx autodoc extension.

Example

With this package, the default values of all documented arguments, and undocumented arguments if enabled, are automatically detected and added to the docstring.

It also detects existing documentation of default arguments with the text unchanged.

def func(x=None, y=None):
    """
    Example docstring.

    :param x: The default value ``None`` will be added here.
    :param y: The text of default value is unchanged.
              (Default: ``'Default Value'``)
    """

    if y is None:
        y = 'Default Value'

    ...

Installation

pip

If you use pip, you can install the package with:

python -m pip install sphinx_autodoc_defaultargs

setup.py

In the root directory, run the following command in the terminal.

python setup.py install

Usage

Add the extension as well as the global substitution to the conf.py file:

extensions = [
    'sphinx.ext.autodoc',
    'sphinx_autodoc_defaultargs'
]

rst_prolog = """
.. |default| raw:: html

    <div class="default-value-section">""" + \
    ' <span class="default-value-label">Default:</span>'

Note that it should be loaded after sphinx.ext.napoleon.

Config Options

  • always_document_default_args (default: False): If False, do not add info of default arguments for undocumented parameters. If True, add stub documentation for undocumented parameters to be able to add default value and to flag optional in the type.

  • docstring_default_arg_flags (default: [('(Default: ', ')')]): List of pairs indicating the header and the footer of an existing documentation of default values, which is expected at the end of the param section. If detected, it will be replaced by the unified style but the text should remain unchanged.

  • docstring_default_arg_after_directives (default: False): If True, the default value will be added after all directives (e.g., note, warning). Existing documentation of the default value is also expected after these directives. Otherwise, it will be added, and expected to exist, before these directives.

  • docstring_default_arg_substitution (default: '|default|'): The substitution markup defined in the conf.py file.

Metadata

Release files for sphinx-autodoc-defaultargs 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinx-autodoc-defaultargs 0.1.2
File Size Uploaded Provenance Actions
sphinx-autodoc-defaultargs-0.1.2.tar.gz 16.7 kB Without provenance Details for sphinx-autodoc-defaultargs-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sphinx-autodoc-defaultargs 0.1.2
File Interpreter ABI Platform Actions
sphinx_autodoc_defaultargs-0.1.2-py3-none-any.whl Python 3 none any Details for sphinx_autodoc_defaultargs-0.1.2-py3-none-any.whl

Total release size: 25.6 kB

Release files / sphinx-autodoc-defaultargs-0.1.2.tar.gz

Download URL sphinx-autodoc-defaultargs-0.1.2.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b11cd9ac43510c1f1e9a3f9469a370e6bbe2bc2cb9e67cb79987f4dcd3be5be3
BLAKE2b-256 checksum
How to use checksums
1a7c8edb5d817ebeb146073be629ed58f89b292a643ee111bee3c703be05a7a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / sphinx_autodoc_defaultargs-0.1.2-py3-none-any.whl

Download URL sphinx_autodoc_defaultargs-0.1.2-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1513b1aea8c20348f1763dbfd7ff11f86cd77f2ce3246c73e1405a2a67fea3ff
BLAKE2b-256 checksum
How to use checksums
e23fa352e58671b1e6d932a6a4b28b45ff58791788ab7fb6a1f9a7162411198d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Security for sphinx-autodoc-defaultargs 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page