Sphinx Documentation generator
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
sphinx-quickstart
sphinx-build -b html <src> <out>
make htmlsphinx-build -W <src> <out>
sphinx-build -E -a <src> <out>
sphinx-build -b linkcheck <src> <out>
sphinx-apidoc -o <out> <pkg>
sphinx-build -j auto <src> <out>
Concepts
- conf.py + .rst files source dir
- Doctrees cached environment
- Output html, latex, man, text...
Project setup
sphinx-quickstart
sphinx-quickstart -q -p <name> -a <author> -v
<ver>
sphinx-quickstart --sep
sphinx-build --version
Building
sphinx-build -b html <src> <out>
sphinx-build -M html <src> <out>
make htmlmake clean-W-a-E-j auto-n-T-w <file>-D <key>=<value>
Builders
-b html-b dirhtml-b singlehtml-b latexmake latexpdf-b linkcheck-b dummy-b doctest-b coverage-b gettextconf.py essentials
project = "<name>"
author = "<name>"
release = "<x.y.z>"
extensions = ["<ext>"]
html_theme = "<theme>"
html_static_path = ["_static"]
exclude_patterns = ["<glob>"]
nitpicky = Truesys.path.insert(0, os.path.abspath(".."))
linkcheck_ignore = [r"<regex>"]
reST basics
Title\n=====*em* / **strong** / ``code``
* item / 1. item / #. item
`text <https://url>`__
.. code-block:: <lang>
paragraph::.. image:: <path>
.. note::.. toctree::.. literalinclude:: <file>
Cross-references
.. _<label>:
:ref:`<label>`
:ref:`text <label>`
:doc:`<path>`
:py:func:`~pkg.mod.func`
intersphinx_mapping = {...}
Autodoc and apidoc
extensions = ["sphinx.ext.autodoc"]
.. automodule:: <pkg.mod>
:members: :undoc-members:
.. autoclass:: <pkg.Class>
:show-inheritance:
.. autofunction:: <pkg.func>
autodoc_default_options = {...}
autodoc_member_order = "bysource"
autodoc_typehints = "description"
autodoc_mock_imports = ["<mod>"]
sphinx-apidoc -o <out> <pkg>
sphinx-apidoc -f
sphinx.ext.napoleon
Recipes
sphinx-build -W --keep-going -n -b html \ docs docs/_build/html
sphinx-quickstart -q docs -p MyPkg -a Me -v 1.0 \ --ext-autodoc --extensions=sphinx.ext.napoleonsphinx-apidoc -o docs/api src/mypkgmake -C docs html
sphinx-build -b linkcheck docs docs/_build/lcmake -C docs latexpdf
import os, syssys.path.insert(0, os.path.abspath("../src"))extensions = ["sphinx.ext.autodoc", "sphinx.ext.intersphinx"]intersphinx_mapping = { "python": ("https://docs.python.org/3", None)}



