无法在Python中使用sphinxapidoc从docstring生成文档

2024-06-07 09:14:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用sphinx自动生成python项目的文档。但是,我无法从doscstring生成文档。以下是我采取的步骤

My Directory structure looks like enter image description here

在docs目录中,我执行

sphinx-quickstart

我回答

Separate source and build directories (y/n) [n]: y

其余为标准默认值。现在医生看起来像

enter image description here

在形态py在docs中,我做了以下编辑

import os
import sys
sys.path.insert(0, os.path.abspath('..'))

extensions = ['sphinx.ext.autodoc','sphinx.ext.todo','sphinx.ext.coverage']

然后,在docs目录中运行

sphinx-apidoc -f -o source/ ../axolotl/

之后我就跑了

make html 在docs目录中,我得到以下日志

enter image description here

我的索引.html内部版本文件夹如下所示 enter image description here

没有任何子文件夹的列表

另一个额外的模块.html列出文件夹,但不生成文档表单文档字符串

enter image description here

这两天以来,我参考了各种stackoverflow链接和博客,有人能指出我的错误吗?

其他细节:

  1. 我在做MacOS
  2. 我用康达创造了一个环境 安装了狮身人面像和其他必要的模块

****先前的问题通过按照@mzn的建议修复sys路径并安装n个必要的模块来解决**** **问题2:索引.rst如下所示** .. 你知道吗

axolotl documentation master file, created by
   sphinx-quickstart on Wed Nov  6 18:45:01 2019.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

Welcome to axolotl's documentation!
===================================

.. toctree::
   :maxdepth: 2
   :caption: Contents:



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

你知道吗索引.html看起来像 enter image description here


Tags: 模块and文档import目录文件夹refdocs

热门问题