Griffe extension for inheriting docstrings.
Project description
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file griffe_inherited_docstrings-1.1.0.tar.gz
.
File metadata
- Download URL: griffe_inherited_docstrings-1.1.0.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b69616eee4972149d047a54aa87ae29e9ba65e45c5ac0df8e22f39884b61f20 |
|
MD5 | a5f6aa4f2bb62e2c8fd53ef2be8afc75 |
|
BLAKE2b-256 | a24084878639b0611d0b40121d2244443d6f36fff18beabf37e48bff1b31478c |
File details
Details for the file griffe_inherited_docstrings-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: griffe_inherited_docstrings-1.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 078440adf9d14284728c4531638ef0fc39dcea464c90e1d22d2414ee22f811f8 |
|
MD5 | 309b15d9c65928bb7fb9ad48b11a72b5 |
|
BLAKE2b-256 | 7b8a052f73d281b1266bd55b659b4d2bcb5b098e1555a0604bbfa39870a97888 |