我目前正在使用Sphinx和我的项目。我的项目设置如下:
Orpheus/
docs/
build/
...
source/
conf.py
index.rst
...
...
Orpheus/
Utils/
__init__.py
...
__init__.py
Orpheus.pyx
setup.py
docs文件夹是我基于Sphinx文件的地方。我为Orpheus包添加了sys.path
的相应路径。这是:
sys.path.insert(0, os.path.abspath('../../Orpheus'))
sys.path.insert(0, os.path.abspath('../../Orpheus/Utils'))
使用autodoc
我正在尝试使用以下文档将Orpheus.pyx
文档添加到index.rst
中:
.. automodule:: Orpheus
:members:
:undoc-members:
:show-inheritance:
当我使用make html
时,我得到以下追溯:
C:\Users\Robert\PycharmProjects\Orpheus\docs\source\index.rst:14: WARNING: autodoc: failed to import module 'Orpheus'; the follo
wing exception was raised:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\sphinx-1.3a0dev_20140708-py3.4.egg\sphinx\ext\autodoc.py", line 368, in import_object
__import__(self.modname)
File "Orpheus.pyx", line 1, in init Orpheus.Orpheus (Orpheus\Orpheus.c:3370)
import os
SystemError: Parent module '' not loaded, cannot perform relative import
我尝试将文档字符串添加到Orpheus.pyx
的顶部,但我仍然收到错误:
C:\Users\Robert\PycharmProjects\Orpheus\docs\source\index.rst:14: WARNING: autodoc: failed to import module 'Orpheus'; the follo
wing exception was raised:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\sphinx-1.3a0dev_20140708-py3.4.egg\sphinx\ext\autodoc.py", line 368, in import_object
__import__(self.modname)
File "Orpheus.pyx", line 1, in init Orpheus.Orpheus (Orpheus\Orpheus.c:3370)
"""
SystemError: Parent module '' not loaded, cannot perform relative import
我之前从未使用过狮身人面像所以我不确定这里有什么问题。有没有解决这个问题?我正在使用Python 3.4
Sphinx v1.3a0
。