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

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for griffe_inherited_docstrings-1.1.1.tar.gz
Algorithm Hash digest
SHA256 d179b6a6b7dc260fb892ad5b857837afd6f9de6193fc26d14463c4e9975a0cd3
MD5 6645085c7b1577a99089a5246e9dfb3f
BLAKE2b-256 7c9f098599019b2715e1edad3618305b8acf253e2ee375cbd389507cb23a2a00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for griffe_inherited_docstrings-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0cb613ade70793b3589c706269a2cc4ceb91cbc4cfdc651037839cb9506eabe6
MD5 9aafc576aee44e6e9f7fe2da6e39af1c
BLAKE2b-256 67f951a3fd7460b95583ff470c7b4fd706bd21f3fda97d521f3770126dc6d1fc

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