I'm trying to run autodoc over a class that extends an external class.
I've used mock so that the import is accepted.
For that I used what was described in this blog http://blog.rtwilson.com/how-to-make-your-sphinx-documentation-compile-with-readthedocs-when-youre-using-numpy-and-scipy/
import mock
MOCK_MODULES = ['de', 'de.xyz', 'de.xyz.class_that_is_extended']
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = mock.Mock()
The python file I try to document looks like this: from de.xyz import class_that_is_extended
class extending_class (class_that_is_extended):
'''
docstring
'''
After running sphinx the result is, that just the class name plus the link to the source is shown.
When I change the line "class extending_class (class_that_is_extended):" to "class extending_class (object):" sphinx/autodoc generates the documentation with docstring.
How can I leave the class as is and still get the docstring in the documentation?
Using the apporach posted here: Sphinx-doc :automodule: with Mock imports
I just changed this line:
to:
and removed 'de.xyz.class_that_is_extended' from MOCK_MODULES
I met the same problem, and my solution was to return
object
directly fromMock
on attribute access.