I am trying to generate documentation of some python interface module generated by SWIG on C code. I am using %feature(docstring)
directive in SWIG interface files (*.i) as mentioned the post:
Sphinx and documenting python from a swigged C++ api
SWIG is generating docstrings in the generated python modules as intended.
But when I am trying to generate documentation out of the SWIG generated python modules it is throwing exception:
/home/imitra/testdoc/doc/test_module.rst:4: WARNING: autodoc: failed to import module u'test_module'; the following exception was raised:
Traceback (most recent call last):
File "/home/imitra/.local/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 658, in import_object
__import__(self.modname)
File "/home/imitra/testdoc/generated/test_module.py", line 3, in <module>
_test_module = swig_import_helper()
File "/home/imitra/testdoc/generated/test_module.py", line 25, in swig_import_helper
return importlib.import_module('_test_module')
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named _tiger
This happens as Sphinx try to import test_module.py and the SWIG generated code gets executed.
Is there a way around this problem ? I am newbie to both SWIG and Sphinx. Please share your thoughts.