Sphinx autodoc dies from third party package ImportError

Is there a way to exclude the import part of the module and then document it using sphinx-python? I have a module that is importing another package (another project) and then sphinx gives this error:

"" File "/usr/local/lib/python2.7/dist-packages/Sphinx-1.1.3-py2.7.egg/sphinx/ext/autodoc.py", line 321, in import_object      import (self.modname ) File "/home/x/GitHub/project/mod_example1.py", line 33, c from other_pck import Klass, KlassStuff ImportError: no module named other_pck ""

And if I comment out the import parts in the module that calls / imports the package the sphinx can do autodoc. I've tried with all authoc sphinx modules: autoclass, automodule, etc., but the result is always the same when it tries to import a different package.

thank

+1


source to share


1 answer


You are fixing the problem incorrectly. The correct way to fix the problem is to make Sphinx aware of your existing other packages, as autodoc functions have to import Python packages to scan source code. Python packages cannot be imported without resolving all dependencies, and you cannot strip lines of source code from it, because this is how Python is built (*)

Possible solutions:



*) In theory you can, but this is beyond the scope of the Sphinx and this question

+2


source







All Articles