快速開始

要開始,請轉到專案目錄的根目錄並執行:

$ sphinx-quickstart

你將獲得為專案建立文件的選項。對於預設設定,請遵循以下命令

Prompt    Choice
> Root path for the documentation [.]:    <ENTER>
> Separate source and build directories (y/N) [n]:    y
> Name prefix for templates and static dir [_]:    <ENTER>
> Project name:    an_example_pypi_project
> Author name(s):    Andrew Carter
> Project version:    0.0.1
> Project release [0.0.1]:    <ENTER>
> Source file suffix [.rst]:    <ENTER>
> Name of your master document (without suffix) [index]:    <ENTER>
> autodoc: automatically insert docstrings from modules (y/N) [n]:    y
> doctest: automatically test code snippets in doctest blocks (y/N) [n]:    n
> intersphinx: link between Sphinx documentation of different projects (y/N) [n]:    y
> todo: write `todo` entries that can be shown or hidden on build (y/N) [n]:    n
> coverage: checks for documentation coverage (y/N) [n]:    n
> pngmath: include math, rendered as PNG images (y/N) [n]:    n
> jsmath: include math, rendered in the browser by JSMath (y/N) [n]:    n
> ifconfig: conditional inclusion of content based on config values (y/N) [n]:    y
> Create Makefile? (Y/n) [y]:    n
> Create Windows command file? (Y/n) [y]:    n

成功執行後,你可以在專案的 doc / source 目錄中發現 config.py 檔案。此檔案可以控制執行 build 命令時文件生成方式的基本結構,如下所示

$ sphinx-build -b html sourcedir builddir

有關詳細說明,請訪問: https ://pythonhosted.org/an_example_pypi_project/sphinx.html