doc/conf.py: use "sphinx_rtd_theme" only if it is installed

Don't fail at build time only because the RTD scheme is not installed.
Such a problem should be detected at configure time.
This commit is contained in:
Max Kellermann
2025-03-13 14:41:16 +01:00
parent f6337dd95e
commit e6a25e7e0b
2 changed files with 8 additions and 0 deletions

View File

@@ -105,6 +105,13 @@ todo_include_todos = False
#
html_theme = 'sphinx_rtd_theme'
try:
__import__(html_theme)
except ModuleNotFoundError:
import sys
print(f"Warning: Sphinx theme {html_theme!r} not available, falling back to the default theme", file=sys.stderr)
del html_theme
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.