Ale*_*ugh 7 python python-sphinx autodoc
我正在尝试使用 Sphinx 记录一个项目,但遇到了一个问题,即仅从文件夹中导入了一些模块。我的项目结构如下所示:
Project
|
|--Main
| |--Scripts
| __init__.py
| libsmop.py
| conv_table.py
| f_discrim.py
| recipes.py
| ...
Run Code Online (Sandbox Code Playgroud)
当我尝试运行make html,libsmop并recipes没有任何问题都是进口的,但是conv_table并f_discrim得到以下错误:
WARNING: autodoc: failed to import module u'conv_table' from module u'Scripts'; the following exception was raised:No module named conv_table
我不认为这是我的配置文件,因为它在我运行时找到了所有文件,sphinx-apidoc -o _rst Main/Scripts并且我已经确认它们出现在结果Scripts.rst文件中。
为什么 autodoc 会找到一些模块而不是其他模块?
编辑:
conv_table.py是这种形式:
import re
import numpy as np
"""
conv_table dictionary at the bottom of this file maps from matlab functions
to their python equivalents.
"""
def get_args(line,separator=",", open_char='(', close_char=')'):
"""Returns the arguments of line
>>> get_args('ones(3,1,length(arr))')
...
< a bunch of function definitions>
...
conv_table = {... < a very big dictionary > ...}
Run Code Online (Sandbox Code Playgroud)
小智 2
根据Sphinx 文档,您需要检查模块加载路径:
\n\n\n\n\n为了让 Sphinx(实际上是执行 Sphinx 的 Python 解释器)找到您的模块,它必须是可导入的。这意味着模块或包必须位于 sys.path \xe2\x80\x93 上的目录之一中,相应地调整配置文件中的 sys.path。
\n
__init__.py此外,了解Scripts 目录的外观以及conv_table模块的外观也很有用。