Windows 中的 Sphinx 不为模块创建文档
Sphinx in Windows doesn't create docs for modules
我正在尝试使用 sphinx 为我的项目创建文档。
我的项目结构如下所示。
Project_root
|-docs
|-_build
|-_static
|-_template
|-rst
|-conf.py
|-Makefile
|-make.bat
|-index.rst
|-modules
|-__init__.py
|-module1.py
|-module2.py
我通过 运行ning sphinx-quickstart
在我的文档目录中设置了这个目录,模块目录包含我需要创建文档的程序模型。文件包含文档字符串以创建这样的自动文档。
"""Class represent a sentence of a comment of a bug report
Parameters
----------
sentence_id : str
sentence_id is a combination of turn_id and the sequence number
(ex: 1.3 means turn 1 and 3rd sentence of the turn)
text : str
orginal sentence text as appeared in the bug report
cleaned_text : str
cleaned text after removing irrelevant characters, stop words,
turning to lower case and lemmatizing
tags :list of str
tags indicate the type of the sentence (description, clarification,
plan, resolution) and/or picked by certain algorithm
"""
我已经将conf.py中的路径修改如下。
import os
import sys
sys.path.insert(0, os.path.abspath('..\'))
当我 运行 sphinx-apidoc -o rst ..\models
时,它只会创建 models.rst 和 modules.rst。没有为 module1.py 和 module2.py 创建。
我想知道我的配置是怎么回事。
编辑:我忘记在我的目录树中添加`init.py。
尝试 abspath('../')
因为 Python 不关心目录的 Windows 反斜杠。
我正在尝试使用 sphinx 为我的项目创建文档。 我的项目结构如下所示。
Project_root
|-docs
|-_build
|-_static
|-_template
|-rst
|-conf.py
|-Makefile
|-make.bat
|-index.rst
|-modules
|-__init__.py
|-module1.py
|-module2.py
我通过 运行ning sphinx-quickstart
在我的文档目录中设置了这个目录,模块目录包含我需要创建文档的程序模型。文件包含文档字符串以创建这样的自动文档。
"""Class represent a sentence of a comment of a bug report
Parameters
----------
sentence_id : str
sentence_id is a combination of turn_id and the sequence number
(ex: 1.3 means turn 1 and 3rd sentence of the turn)
text : str
orginal sentence text as appeared in the bug report
cleaned_text : str
cleaned text after removing irrelevant characters, stop words,
turning to lower case and lemmatizing
tags :list of str
tags indicate the type of the sentence (description, clarification,
plan, resolution) and/or picked by certain algorithm
"""
我已经将conf.py中的路径修改如下。
import os
import sys
sys.path.insert(0, os.path.abspath('..\'))
当我 运行 sphinx-apidoc -o rst ..\models
时,它只会创建 models.rst 和 modules.rst。没有为 module1.py 和 module2.py 创建。
我想知道我的配置是怎么回事。
编辑:我忘记在我的目录树中添加`init.py。
尝试 abspath('../')
因为 Python 不关心目录的 Windows 反斜杠。