3

I use Sphinx for autodocs, but I find it annoying how it by default appends the parent class docstring to my docstring.

The result is that for each and every documented test class inheriting from unittest.TestCase, I get the docstring "Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name." appended. So these two sentences litter my test documentation, over and over again.

How can I stop Sphinx from pulling the docstring from the parent?

1
  • I guess pure Python trickery inspired by answers found here stackoverflow.com/questions/2025562/… is out of the question, since Sphinx itself seems to pull the docstring from the parent. Commented May 13, 2013 at 9:47

1 Answer 1

4

There's a setting:

autodoc_inherit_docstrings

This value controls the docstrings inheritance. If set to True the docstring for classes or methods, if not explicitly set, is inherited form (sic) parents.

The default is True.

New in version 1.7.

Although use with care - this setting appears to break a directive I'm calling in docstrings.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.