sphinx, kivy and autodoc: warning and issues to create documentation

纵饮孤独 提交于 2020-01-07 03:52:14

问题


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.

Do you know what is the problem? Could you help me?

Thank you in advance!

M.

PS: I have python 2.7.9, kivy 1.9.1 and Sphinx 1.6.3 on a Debian Jessie


回答1:


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.



来源:https://stackoverflow.com/questions/45061657/sphinx-kivy-and-autodoc-warning-and-issues-to-create-documentation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!