Welcome to Matplotlib Sphinx Theme’s documentation!

This is the official Sphinx theme for Matplotlib documentation. It extends the pydata_sphinx_theme project, but adds custom styling and a navigation bar.

When creating a Matplotlib subproject you can include this theme by changing this line in your conf.py file

html_theme = 'mpl_sphinx_theme'

And by including mpl_sphinx_theme as a requirement in your documentation installation.

There are three main templates that replace the defaults in pydata-sphinx-theme:

navbar_start = mpl_navbar_logo.html
navbar_center = mpl_nav_bar.html
navbar_end = mpl_icon_links.html

Note that the option html_logo need not be specified as it is included in mpl_sphinx_theme/mpl_navbar_logo.html. The logo is stored at mpl_sphinx_theme/static/images/logo2.svg.

To change the top navbar, edit mpl_sphinx_theme/mpl_nav_bar.html

To change the social icons, edit mpl_sphinx_theme/mpl_icon_links.html

To change the style, edit mpl_sphinx_theme/static/css/style.css

The full conf.py is

import os
import time
import datetime

# Configuration file for the Sphinx documentation builder for
# matplotlib projects.

# Release mode enables optimizations and other related options.
is_release_build = tags.has('release')  # noqa

# Parse year using SOURCE_DATE_EPOCH, falling back to current time.
# https://reproducible-builds.org/specs/source-date-epoch/
build_date = datetime.datetime.utcfromtimestamp(
    int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
)

# -- Project information -----------------------------------------------------

project = "Matplotlib Sphinx Theme"
copyright = (
    f"2012 - {build_date.year} The Matplotlib development team"
)
author = "Matplotlib Developers"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []

# Add any paths that contain templates here, relative to this directory.

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# -- Options for HTML output -------------------------------------------------

html_theme = "mpl_sphinx_theme"
html_favicon = "_static/favicon.ico"
html_theme_options = {
    "logo_link": "https://matplotlib.org/stable/",
    # collapse_navigation in pydata-sphinx-theme is slow, so skipped for local
    # and CI builds https://github.com/pydata/pydata-sphinx-theme/pull/386
    "collapse_navigation": not is_release_build,
    "show_prev_next": False,
    "native_site": False
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# html_static_path = ["static"]