我正试图使用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 模块并可导入。 - Steve Piercyautodoc
命令长什么样? - user9903