From ad3edd924cd0a76747a8f8c713f0f3559053b9da Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 23 Feb 2021 20:37:30 +0900 Subject: [PATCH] Fix #8915: html theme: The translation of sphinx_rtd_theme does not work Since sphinx_rtd_theme-0.5.0, it supports translations. But Sphinx core disallows to enable it because theming framework gives special treatment for the theme for a long time. This goes to load it via setuptools at first to enable the translations. Note: The special treatment for sphinx_rtd_theme (< 0.2.5) is not removed yet. But it will be removed in the future release. --- CHANGES | 2 ++ sphinx/theming.py | 16 +++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 9dfca4ee3a1..798ddb0fca8 100644 --- a/CHANGES +++ b/CHANGES @@ -30,6 +30,7 @@ Incompatible changes * html theme: Move a script tag for documentation_options.js in basic/layout.html to ``script_files`` variable * html theme: Move CSS tags in basic/layout.html to ``css_files`` variable +* #8915: html theme: Emit a warning for sphinx_rtd_theme-0.2.4 or older * #8508: LaTeX: uplatex becomes a default setting of latex_engine for Japanese documents * #5977: py domain: ``:var:``, ``:cvar:`` and ``:ivar:`` fields do not create @@ -69,6 +70,7 @@ Bugs fixed ---------- * #8380: html search: Paragraphs in search results are not identified as ``

`` +* #8915: html theme: The translation of sphinx_rtd_theme does not work * #8342: Emit a warning if a unknown domain is given for directive or role (ex. ``:unknown:doc:``) * #8711: LaTeX: backticks in code-blocks trigger latexpdf build warning (and font diff --git a/sphinx/theming.py b/sphinx/theming.py index e84f5ae49fc..bba47b3441d 100644 --- a/sphinx/theming.py +++ b/sphinx/theming.py @@ -178,8 +178,6 @@ def load_extra_theme(self, name: str) -> None: """Try to load a theme having specifed name.""" if name == 'alabaster': self.load_alabaster_theme() - elif name == 'sphinx_rtd_theme': - self.load_sphinx_rtd_theme() else: self.load_external_theme(name) @@ -237,13 +235,13 @@ def create(self, name: str) -> Theme: if name not in self.themes: self.load_extra_theme(name) + if name not in self.themes and name == 'sphinx_rtd_theme': + # sphinx_rtd_theme (< 0.2.5) # RemovedInSphinx60Warning + logger.warning(__('sphinx_rtd_theme (< 0.3.0) found. ' + 'It will not be available since Sphinx-6.0')) + self.load_sphinx_rtd_theme() + if name not in self.themes: - if name == 'sphinx_rtd_theme': - raise ThemeError(__('sphinx_rtd_theme is no longer a hard dependency ' - 'since version 1.4.0. Please install it manually.' - '(pip install sphinx_rtd_theme)')) - else: - raise ThemeError(__('no theme named %r found ' - '(missing theme.conf?)') % name) + raise ThemeError(__('no theme named %r found (missing theme.conf?)') % name) return Theme(name, self.themes[name], factory=self)