Windows中的Sphinx不会为模块创建文档

我正在尝试使用sphinx为我的项目创建文档。 我的项目结构如下所示。

Project_root
|-docs
  |-_build
  |-_static
  |-_template
  |-rst
  |-conf.py
  |-Makefile
  |-make.bat
  |-index.rst
|-modules
  |-__init__.py
  |-module1.py
  |-module2.py

我通过在文档目录中运行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。

icem_net 回答:Windows中的Sphinx不会为模块创建文档

请尝试abspath('../'),因为Python并不关心Windows的目录反斜杠。

本文链接:https://www.f2er.com/3131435.html

大家都在问