Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid docstrings from parent, in Sphinx

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?

like image 509
Prof. Falken Avatar asked May 01 '26 23:05

Prof. Falken


1 Answers

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.

like image 83
Chris Avatar answered May 03 '26 13:05

Chris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!