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