直接使用 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