#先安裝lib庫
pip install sphinx
創建一個文件夾,隨便名字,例如 test
cmd中執行命令
sphinx-quickstart > Root path for the documentation [.]: doc # 在當前目錄下新建doc文件夾存放sphinx相關信息 > Separate source and build directories (y/n) [n]: # 默認,直接回車 > Name prefix for templates and static dir [_]: > Project name: python123 # 輸入項目名稱 > Author name(s): 123 # 作者 > Project version: 1.0 # 項目版本 > Project release [1.0]: > Project language [en]: # 默認,回車 > Source file suffix [.rst]: > Name of your master document (without suffix) [index]: > Do you want to use the epub builder (y/n) [n]: > autodoc: automatically insert docstrings from modules (y/n) [n]: y # 這個很重要,輸入y > doctest: automatically test code snippets in doctest blocks (y/n) [n]: > intersphinx: link between Sphinx documentation of different projects (y/n) [n]: > todo: write "todo" entries that can be shown or hidden on build (y/n) [n]: > coverage: checks for documentation coverage (y/n) [n]: > pngmath: include math, rendered as PNG images (y/n) [n]: > mathjax: include math, rendered in the browser by MathJax (y/n) [n]: > ifconfig: conditional inclusion of content based on config values (y/n) [n]: > viewcode: include links to the source code of documented Python objects (y/n) [n]: y # 很重要,輸入y,表示將源碼也放到文檔中,你看很多python的模塊的文檔,其實都是包含代碼的。 > Create Makefile? (y/n) [y]: > Create Windows command file? (y/n) [y]:
會新增一個doc文件夾,目錄結構
將需要轉的rst文件復制到doc文件夾里面 改明為index.rst 如果不想改名字 就到conf.py里面改下配置文件
_build中就為需要的html了~