使用现有项目设置Sphinx Autodoc

时间:2019-04-18 15:26:21

标签: python-sphinx autodoc sphinx-apidoc

我是Sphinx的新手,已经看了数小时的教程,但是找不到解决问题的方法

我有一个像下面这样的当前项目结构

-project folder
 |-sub folder 1
 | |- sub folder 1.a
 |    | - ...
 |-sub folder 2
 | |- sub folder 2.a
 |    | - ...
 |-sub folder 3
 | |- sub folder 3.a
 |    | - ...
 |- .py files
 |...
 |- conf.py
 |- index.rst
 |- Makefile
 |- _build/
 |  |-doctrees/
 |  |-html/
 |    |...(all the html files generated by "make html")

我已经在conf.py中添加了以下内容

extensions = ['autoapi.extension']
# Document Python Code
autoapi_type = 'python'
autoapi_dir = '../project folder'

在每个子文件夹中,我都有.py文件,这些文件包含类,函数,模块,所有需要记录的成员。 sphinx是否可以解析当前项目文件夹及其所有子目录,以搜索要自动doc的.py文件?如果是这样,我将如何设置index.rst和conf.py文件来实现这一目标?

我看到的错误如下:

Removing everything under '_build'...
Running Sphinx v1.8.5  
making output directory...  

Extension error: 
You must configure an autoapi_dirs setting  
Makefile:19: recipe for target 'html' failed 
make: *** [html] Error 2 

1 个答案:

答案 0 :(得分:0)

错误是明确的:You must configure an autoapi_dirs setting。您的conf.py设置中有一个错字,省略了autoapi_dir的设置中的“ s”。请参阅autoapi_dirs for autoapi的配置值。