我正在用 sphinx 在本地记录我的金字塔项目。本地autodoc
工作正常,文档看起来像我想要的那样。
但是,如果我使用 read the docs,每次使用 autodoc 功能都会收到以下错误:
/home/docs/checkouts/readthedocs.org/user_builds/buchungssystem/checkouts/latest/docs/source/02database/02models.rst:8: WARNING: autodoc: failed to import class u'Person' from module u'buchungssystem.models.person'; the following exception was raised:
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/buchungssystem/envs/latest/local/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 385, in import_object
__import__(self.modname)
ImportError: No module named buchungssystem.models.person
我的项目结构如下:
project
->code
->models
->scripts
->...
->__init__.py
->...
->docs
->conf.py
->documentation
->setup.py
我认为我的 sys.path 配置不正确。在尝试了很多之后我又回来了sys.path.insert(0, os.path.abspath('.'))