Griffe extension for inheriting docstrings.
Project Links
Meta
Author: Timothée Mazzucotelli
Requires Python: >=3.9
Classifiers
Development Status
- 4 - Beta
Intended Audience
- Developers
Programming Language
- Python
- Python :: 3
- Python :: 3 :: Only
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
- Python :: 3.14
Topic
- Documentation
- Software Development
- Utilities
Typing
- Typed
Griffe Inherited Docstrings
Griffe extension for inheriting docstrings.
Installation
pip install griffe-inherited-docstrings
Usage
With Python:
import griffe
griffe.load("...", extensions=griffe.load_extensions(["griffe_inherited_docstrings"]))
With MkDocs and mkdocstrings:
plugins:
- mkdocstrings:
handlers:
python:
options:
extensions:
- griffe_inherited_docstrings
The extension will iterate on every class and their members to set docstrings from parent classes when they are not already defined.
The extension accepts a merge option, that when set to true
will actually merge all parent docstrings in the class hierarchy
to the child docstring, if any.
plugins:
- mkdocstrings:
handlers:
python:
options:
extensions:
- griffe_inherited_docstrings:
merge: true
class A:
def method(self):
"""Method in A."""
class B(A):
def method(self):
...
class C(B):
...
class D(C):
def method(self):
"""Method in D."""
class E(D):
def method(self):
"""Method in E."""
With the code above, docstrings will be merged like following:
| Class | Method docstring |
|---|---|
A |
Method in A. |
B |
Method in A. |
C |
Method in A. |
D |
Method in A. Method in D. |
E |
Method in A. Method in D. Method in E. |
WARNING: Limitation This extension runs once on whole packages. There is no way to toggle merging or simple inheritance for specifc objects.
1.1.2
Sep 05, 2025
1.1.1
Nov 05, 2024
1.1.0
Oct 25, 2024
1.0.1
Aug 15, 2024
1.0.0
Jan 05, 2024
0.0.0
Oct 20, 2023
Wheel compatibility matrix
Files in release
Extras:
None
Dependencies:
griffe
(>=1.14)