【发布时间】:2019-02-21 20:29:50
【问题描述】:
我正在尝试使用 Sphinx 记录一个项目,但遇到了一个问题,即仅从文件夹中导入了一些模块。我的项目结构如下:
Project
|
|--Main
| |--Scripts
| __init__.py
| libsmop.py
| conv_table.py
| f_discrim.py
| recipes.py
| ...
当我尝试运行 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 > ...}
【问题讨论】:
-
收到
__init__.py?每个目录都需要它以使其成为 Python 模块并且可导入。 -
是的,我在
Scripts目录中有一个__init__.py文件。 -
Sphinx
autodoc命令长什么样子?
标签: python python-sphinx autodoc