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.

Sponsors

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.3.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

griffe_inherited_docstrings-1.1.3-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for griffe_inherited_docstrings-1.1.3.tar.gz
Algorithm Hash digest
SHA256 cd1f937ec9336a790e5425e7f9b92f5a5ab17f292ba86917f1c681c0704cb64e
MD5 e088e3d54876526dc570580ebc44f3d7
BLAKE2b-256 cbdafd002dc5f215cd896bfccaebe8b4aa1cdeed8ea1d9d60633685bd61ff933

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for griffe_inherited_docstrings-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 aa7f6e624515c50d9325a5cfdf4b2acac547f1889aca89092d5da7278f739695
MD5 5dde94c2cb46edc8532398d47c0acbfa
BLAKE2b-256 16204bc15f242181daad1c104e0a7d33be49e712461ea89e548152be0365b9ea

See more details on using hashes here.

Supported by

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