Extras#

Here are some cool things you can add to your docs.

Theme#

Sphinx comes with builtin themes. This documentation uses the Sphinx Book Theme.

  1. Add the theme to the requirements and install it,

    echo sphinx-book-theme >> docs/requirements.txt
    pip install sphinx-book-theme
    
  2. Go to the conf.py file and add the following lines,

    html_theme = 'sphinx_book_theme'
    

This theme allows you to add hyperlinks to the source repository and more.

Math#

Render math using the mathjax extension.

conf.py#
extensions = [
    ...,
    'sphinx.ext.mathjax',
]

Here is an example,

\[f(x) = \int_0^\infty x^2 \, dx\]

Generate notebooks#

Use the nbsphinx extension to automatrically generate documentation from Jupyter notebooks.

Intersphinx#

Reference external documentation in your docstrings using the intersphinx extension.