PyDoc: support building without sphinx_rtd_theme

This is no longer bundled with sphinx, support building without it.
This commit is contained in:
Campbell Barton 2020-10-08 12:31:26 +11:00
parent 9c8334acc1
commit 0b4aeffda9

@ -1672,8 +1672,19 @@ def write_sphinx_conf_py(basepath):
fw("]\n\n")
fw("html_title = 'Blender Python API'\n")
fw("html_theme = 'sphinx_rtd_theme'\n")
fw("html_theme_options = {\n")
fw("html_theme = 'default'\n")
# The theme 'sphinx_rtd_theme' is no longer distributed with sphinx by default, only use when available.
fw(r"""
try:
__import__('sphinx_rtd_theme')
html_theme = 'sphinx_rtd_theme'
except ModuleNotFoundError:
pass
""")
fw("if html_theme == 'sphinx_rtd_theme':\n")
fw(" html_theme_options = {\n")
fw(" 'canonical_url': 'https://docs.blender.org/api/current/',\n")
# fw(" 'analytics_id': '',\n")
# fw(" 'collapse_navigation': True,\n")