快乐学习
前程无忧、中华英才非你莫属!

自动生成Python 文档-Sphinx

1、安装sphinx 模块

pip install Sphinx

2、创建doc文档项目路径

PS D:\rd\PyJob\tongle> sphinx-quickstart pydoc
Welcome to the Sphinx 4.2.0 quickstart utility.

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

The project name will occur in several places in the built documentation.
> Project name: ztloo
> Author name(s): 张同乐
> Project release []: 1.0
> Project language [en]: zh_CN

3、配置conf.py

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

添加扩展,来识别各种格式的注释

extensions = ['sphinx.ext.autodoc',
              'sphinx.ext.doctest',
              'sphinx.ext.intersphinx',
              'sphinx.ext.todo',
              'sphinx.ext.coverage',
              'sphinx.ext.mathjax',
              'sphinx.ext.napoleon']

4、生成RST文件

PS D:\rd\PyJob\tongle\pydoc> sphinx-apidoc -o ./source ../clean/
Creating file ./source\coding_clear.rst.
Creating file ./source\ztloo.rst.
Creating file ./source\modules.rst.

5、生成html

PS D:\rd\PyJob\tongle\pydoc> ./make html
Running Sphinx v4.2.0
loading translations [zh_CN]... done
making output directory... done

打赏
赞(1) 打赏
未经允许不得转载:同乐学堂 » 自动生成Python 文档-Sphinx

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

特别的技术,给特别的你!

联系QQ:1071235258QQ群:710045715

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏