NVIDIA Sphinx Theme
The `nvidia-sphinx-theme` provides a modern, opinionated Sphinx theme specifically designed for NVIDIA projects, focusing on clean aesthetics and user experience. It is currently at version 0.0.9.post1 and follows an irregular release cadence, with updates typically coinciding with feature additions or Sphinx compatibility requirements.
Common errors
-
sphinx.errors.ThemeError: The 'nvidia_sphinx_theme' theme is not installed.
cause The `nvidia-sphinx-theme` package has not been installed in the Python environment where Sphinx is being run, or the environment is not active.fixRun `pip install nvidia-sphinx-theme` in your active Python environment. If using a virtual environment, ensure it is activated. -
ERROR: Package 'nvidia-sphinx-theme' requires a different Python: X.Y.Z is not in '>=3.10'
cause Your current Python version (X.Y.Z) is older than the minimum required version (3.10) for `nvidia-sphinx-theme`.fixUpgrade your Python environment to version 3.10 or newer. Consider using a tool like `pyenv` or `conda` to manage multiple Python versions. -
TypeError: 'version_info' object is not subscriptable
cause This error can occur when using an older Sphinx version (e.g., Sphinx 5.x) with a theme designed for Sphinx 6.x or newer, due to changes in how Sphinx accesses version information.fixUpgrade Sphinx to version 6.x or newer. Run `pip install --upgrade sphinx`.
Warnings
- breaking The `nvidia-sphinx-theme` requires Sphinx version 6.x or newer. Using older versions of Sphinx will result in build errors or incorrect rendering.
- gotcha Python 3.10 or newer is required to install and use `nvidia-sphinx-theme`. Attempting to install on older Python versions will fail.
- gotcha If you are running `sphinx-build` inside a virtual environment, ensure `nvidia-sphinx-theme` is installed within that specific environment. If it's installed globally but not in the active venv, Sphinx will not find it.
Install
-
pip install nvidia-sphinx-theme
Imports
- html_theme
html_theme = 'nvidia_sphinx_theme'
Quickstart
# conf.py
import os
import sys
# -- Project information -----------------------------------------------------
project = 'My NVIDIA Docs'
copyright = '2023, NVIDIA'
author = 'NVIDIA'
# -- General configuration ---------------------------------------------------
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode'
]
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
html_theme = 'nvidia_sphinx_theme'
html_static_path = ['_static']
# Theme options are specific to the theme. Consult the theme's documentation
# for options available. For example:
# html_theme_options = {
# "navbar_left_text": "NVIDIA",
# "logo_link": "https://www.nvidia.com",
# }