直接使用 pip3 install sphinx 便可html
建一个存放文档的 docs 目录,进入 docs 目录执行: sphinx-quickstartpython
填写信息的按本身的清空填写便可,有两个插件在安装过程当中须要启用:api
autodoc: automatically insert docstrings from modules (y/n) [n]: y 很重要,输入yapp
viewcode: include links to the source code of documented Python objects (y/n) [n]: y 很重要,输入y,表示将源码也放到文档中,你看不少python的模块的文档,其实都是包含代码的。ui
extensions = [ "sphinx.ext.autodoc", "sphinx.ext.coverage", "sphinx.ext.doctest", "sphinx.ext.intersphinx", "sphinx.ext.viewcode", ]
返回 docs 目录的上一级,对当前目录的每个文件夹及子文件夹生成一个rst文件,对应python的包,存放在./docs目录下:spa
sphinx-apidoc -o ./docs/ ..net
注意:插件
进入 docs 目录,执行命令:make htmlcode
if __name__ == '__main__': pass
参考了: https://blog.csdn.net/suzyu12345/article/details/52923464htm