From ccd7e73c1962f43250313a1d8e1554c987ec5c05 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 5 Apr 2015 15:10:49 +0900 Subject: [PATCH] Fix #1794: custom theme extended from alabaster or sphinx_rtd_theme can't find base theme. --- CHANGES | 3 +++ sphinx/theming.py | 38 +++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/CHANGES b/CHANGES index c25407e31..6e56620c9 100644 --- a/CHANGES +++ b/CHANGES @@ -8,6 +8,9 @@ Bugs fixed * #1789: ``:pyobject:`` option of ``literalinclude`` directive includes following lines after class definitions * #1790: ``literalinclude`` strips empty lines at the head and tail +* #1802: load plugin themes automatically when theme.conf use it as 'inherit'. Thanks to + Takayuki Hirai. +* #1794: custom theme extended from alabaster or sphinx_rtd_theme can't find base theme. Release 1.3.1 (released Mar 17, 2015) diff --git a/sphinx/theming.py b/sphinx/theming.py index 33a53c7fe..f2935e142 100644 --- a/sphinx/theming.py +++ b/sphinx/theming.py @@ -71,28 +71,28 @@ class Theme(object): @classmethod def load_extra_theme(cls, name): - if name == 'alabaster': - cls.themes[name] = (os.path.join(alabaster.get_path(), name), None) - # alabaster theme also requires 'alabaster' extension, it will be loaded at - # sphinx.******* module. - return + if name in ('alabaster', 'sphinx_rtd_theme'): + if name == 'alabaster': + themedir = alabaster.get_path() + # alabaster theme also requires 'alabaster' extension, it will be loaded + # at sphinx.application module. + elif name == 'sphinx_rtd_theme': + themedir = sphinx_rtd_theme.get_html_theme_path() + else: + raise NotImplementedError('Programming Error') - if name == 'sphinx_rtd_theme': - cls.themes[name] = ( - os.path.join(sphinx_rtd_theme.get_html_theme_path(), name), None) - return - - for themedir in load_theme_plugins(): - if not path.isdir(themedir): - continue - for theme in os.listdir(themedir): - if theme != name: - continue - if not path.isfile(path.join(themedir, theme, THEMECONF)): - continue - cls.themes[theme] = (path.join(themedir, theme), None) + else: + for themedir in load_theme_plugins(): + if path.isfile(path.join(themedir, name, THEMECONF)): + break + else: + # specified theme is not found return + cls.themepath.append(themedir) + cls.themes[name] = (path.join(themedir, name), None) + return + def __init__(self, name, warn=None): if name not in self.themes: self.load_extra_theme(name)