Skip to main content

Griffe extension for inheriting docstrings.

Project description

Griffe Inherited Docstrings

ci documentation pypi version gitter

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

griffe_inherited_docstrings-1.1.0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file griffe_inherited_docstrings-1.1.0.tar.gz.

File metadata

File hashes

Hashes for griffe_inherited_docstrings-1.1.0.tar.gz
Algorithm Hash digest
SHA256 1b69616eee4972149d047a54aa87ae29e9ba65e45c5ac0df8e22f39884b61f20
MD5 a5f6aa4f2bb62e2c8fd53ef2be8afc75
BLAKE2b-256 a24084878639b0611d0b40121d2244443d6f36fff18beabf37e48bff1b31478c

See more details on using hashes here.

File details

Details for the file griffe_inherited_docstrings-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for griffe_inherited_docstrings-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 078440adf9d14284728c4531638ef0fc39dcea464c90e1d22d2414ee22f811f8
MD5 309b15d9c65928bb7fb9ad48b11a72b5
BLAKE2b-256 7b8a052f73d281b1266bd55b659b4d2bcb5b098e1555a0604bbfa39870a97888

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page