Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

griffe-inherited-docstrings

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

griffe-inherited-docstrings

Griffe extension for inheriting docstrings.

  • 1.1.1
  • PyPI
  • Socket score

Maintainers
1

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:

ClassMethod docstring
AMethod in A.
BMethod in A.
CMethod in A.
DMethod in A.

Method in D.
EMethod 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.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc