I would like to create documentation of my code in Sphinx. I installed everything and made some simple trial that worked fine. (I run sphinx-quickstart, edit the conf.py to include modules' path, work with a tutorial to know how sphinx works etc. etc.)
Yet, my code import many Kivy libraries. And when I want to create the documentation on module that import Kivy, it fails.
For instance, if I have my main.py like this:
#!/usr/bin/python
# -*- coding: utf-8 -*-
from kivy.app import App
def test_app(a,b):
""" Test documentation """
print a + b
if __name__ == '__main__':
test_app(1,2)
Then, if I run
make clean && make html
I have the following wanring (and no doc edited..):
WARNING: /home/math/drphytoscan/source/autodoc.rst:4: (WARNING/2) autodoc: failed to import module u'src.main'; the following exception was raised: Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/sphinx/ext/autodoc.py", line 657, in import_object import (self.modname) File "/home/math/drphytoscan/source/src/main.py", line 14, in from kivy.app import App ImportError: No module named app
Note: If I erase the line:
from kivy.app import App
it works. That shows that it comes from the Kivy lib import.
PS: I have Python 2.7.9, Kivy 1.9.1 and Sphinx 1.6.3 on a Debian Jessie
From the note at the top of the documentation for autodoc :
For Sphinx (actually, the Python interpreter that executes Sphinx) to find your module, it must be importable. That means that the module or the package must be in one of the directories on sys.path – adapt your sys.path in the configuration file accordingly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.