Sphinx-如何自动对多个文件夹中的.py文件进行docdoc?

时间:2018-06-22 14:54:06

标签: python python-sphinx autodoc

我对Python和Sphinx还是陌生的,并且正在尝试自动对位于类似于以下目录的目录中的python文件进行doc:

Project
├── Sphinx
|   ├── index.rst
|   ├── autodoc.rst
|   └──  conf.py
├── Scripts
|   ├── file1.py
|   └──  file2.py
|   ├── folder
|   |   └── file3.py

我的conf.py文件包含:

sys.path.insert(0, os.path.abspath("../Scripts/"))

并且autodoc包含:

.. automodule:: file1
  :members:

.. automodule:: file2
  :members:

.. automodule:: folder.file3
  :members:

File3.py无法正确自动记录文档(错误:没有名为metric.billpay的模块)

我也尝试过:

.. automodule:: folder/file3
  :members:

但我收到

  

警告:自动模块(u'folder / file3')的无效签名

     

警告:不知道要导入哪个模块以进行自动记录   u'folder / file3'(尝试放置“模块”或“ currentmodule”指令   在文档中,或者给出明确的模块名称)

有人知道如何解决此问题吗?我是Python,Sphinx和StackOverflow的新手,所以很抱歉如果这个问题有问题。

1 个答案:

答案 0 :(得分:2)

此外:

sys.path.insert(0, os.path.abspath("..Scripts/"))

我后来添加了这个:

sys.path.insert(0, os.path.abspath("..Scripts/Folder/"))

允许我使用autodoc访问“文件夹”中的文件。