Skip to content

extension ¤

The Griffe extension.

Classes:

InheritDocstringsExtension ¤

InheritDocstringsExtension(*, merge: bool = False)

Bases: Extension

Griffe extension for inheriting docstrings.

Parameters:

  • merge (bool, default: False ) –

    Whether to merge the docstrings from the parent classes into the docstring of the member.

Methods:

  • on_package_loaded

    Inherit docstrings from parent classes once the whole package is loaded.

Source code in src/griffe_inherited_docstrings/extension.py
70
71
72
73
74
75
76
def __init__(self, *, merge: bool = False) -> None:
    """Initialize the extension by setting the merge flag.

    Parameters:
        merge: Whether to merge the docstrings from the parent classes into the docstring of the member.
    """
    self.merge = merge

on_package_loaded ¤

on_package_loaded(*, pkg: Module, **kwargs: Any) -> None

Inherit docstrings from parent classes once the whole package is loaded.

Source code in src/griffe_inherited_docstrings/extension.py
78
79
80
def on_package_loaded(self, *, pkg: Module, **kwargs: Any) -> None:  # noqa: ARG002
    """Inherit docstrings from parent classes once the whole package is loaded."""
    _inherit_docstrings(pkg, merge=self.merge, seen=set())