【问题标题】:Setting up Sphinx Autodoc with existing project使用现有项目设置 Sphinx Autodoc
【发布时间】:2019-04-18 15:26:20
【问题描述】:

我是 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 有没有办法解析当前项目文件夹及其所有子目录以搜索 .py 文件到 autodoc?如果是这样,我将如何设置我的 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 

【问题讨论】:

  • 您收到的错误信息是什么? sphinx-apidoc 应该选择 Python 包,根据定义,每个目录中必须包含 __init__.py,并写入 .rst 源文件。然后运行 ​​make html 来构建您的文档的 HTML 版本。
  • @StevePiercy 我在上面添加了我的错误。感谢您的快速回复!

标签: python-sphinx autodoc sphinx-apidoc


【解决方案1】:

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

【讨论】:

  • 省略“s”是什么意思?您可以使用我上面的 conf.py 设置提供一个明确的示例吗?你是说我的“autoapi_dir”实际上应该是“autoapi_dirs”
  • 解决了这个问题!非常感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-02-09
  • 1970-01-01
  • 2016-07-24
  • 1970-01-01
  • 2020-09-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多