Skip to content

Use method docstring from abstract base class if derived class has none #3140

@alexvorndran

Description

@alexvorndran

Let's say I have the following two classes

# -*- coding: utf-8 -*
import abc


class Superclass(object):
    """The one to rule them all"""

    @abc.abstractmethod
    def give(self, ring):
        """Give out a ring"""
        pass


class Derived(Superclass):
    """Somebody has to do the work"""

    def give(self, ring):
        print("I pass the ring {} to you".format(ring))

Is it possible to instruct Sphinx (or even better sphinx-apidoc) to use the docstring of Superclass.give(...) for Derived.give(...) without copying it manually?

The Help widget of Spyder IDE does something similar but as far as I understand, fetching the parent's docstring is not handled by Sphinx there.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions