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?

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
  • I guess pure Python trickery inspired by answers found here http://stackoverflow.com/questions/2025562/inherit-docstrings-in-python-class-inheritance?lq=1 is out of the question, since Sphinx itself seems to pull the docstring from the parent. – Prof. Falken May 13 '13 at 09:47

1 Answers1

3

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.

Chris
  • 5,664
  • 6
  • 44
  • 55