https://github.com/mkdocstrings/griffe-inherited-docstrings
Griffe extension for inheriting docstrings.
https://github.com/mkdocstrings/griffe-inherited-docstrings
docstrings griffe griffe-extension
Last synced: 26 days ago
JSON representation
Griffe extension for inheriting docstrings.
- Host: GitHub
- URL: https://github.com/mkdocstrings/griffe-inherited-docstrings
- Owner: mkdocstrings
- License: isc
- Created: 2023-10-20T15:21:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-09-05T15:17:17.000Z (6 months ago)
- Last Synced: 2026-01-21T17:40:52.880Z (about 2 months ago)
- Topics: docstrings, griffe, griffe-extension
- Language: Python
- Homepage: https://mkdocstrings.github.io/griffe-inherited-docstrings/
- Size: 846 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Griffe Inherited Docstrings
[](https://github.com/mkdocstrings/griffe-inherited-docstrings/actions?query=workflow%3Aci)
[](https://mkdocstrings.github.io/griffe-inherited-docstrings/)
[](https://pypi.org/project/griffe-inherited-docstrings/)
[](https://app.gitter.im/#/room/#griffe-inherited-docstrings:gitter.im)
Griffe extension for inheriting docstrings.
## Installation
```bash
pip install griffe-inherited-docstrings
```
## Usage
With Python:
```python
import griffe
griffe.load("...", extensions=griffe.load_extensions(["griffe_inherited_docstrings"]))
```
With MkDocs and mkdocstrings:
```yaml
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.
```yaml
plugins:
- mkdocstrings:
handlers:
python:
options:
extensions:
- griffe_inherited_docstrings:
merge: true
```
```python
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.
## Sponsors