diff options
-rw-r--r-- | sphinx/builders/html.py | 6 | ||||
-rw-r--r-- | sphinx/jinja2glue.py | 2 | ||||
-rw-r--r-- | sphinx/theming.py | 19 | ||||
-rw-r--r-- | tests/test_theming.py | 10 |
4 files changed, 11 insertions, 26 deletions
diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index c1a1ae9d5..a9e5e543c 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -209,7 +209,7 @@ class StandaloneHTMLBuilder(Builder): if self.config.pygments_style is not None: style = self.config.pygments_style elif self.theme: - style = self.theme.get_confstr('theme', 'pygments_style', 'none') + style = self.theme.get_config('theme', 'pygments_style', 'none') else: style = 'sphinx' self.highlighter = PygmentsBridge('html', style, @@ -387,7 +387,7 @@ class StandaloneHTMLBuilder(Builder): if self.config.html_style is not None: stylename = self.config.html_style elif self.theme: - stylename = self.theme.get_confstr('theme', 'stylesheet') + stylename = self.theme.get_config('theme', 'stylesheet') else: stylename = 'default.css' @@ -690,7 +690,7 @@ class StandaloneHTMLBuilder(Builder): # then, copy over theme-supplied static files if self.theme: - for theme_path in self.theme.get_dirchain()[::-1]: + for theme_path in self.theme.get_theme_dirs()[::-1]: entry = path.join(theme_path, 'static') copy_asset(entry, path.join(self.outdir, '_static'), excluded=DOTFILES, context=ctx, renderer=self.templates) diff --git a/sphinx/jinja2glue.py b/sphinx/jinja2glue.py index 43e5c89b4..ec0435f2e 100644 --- a/sphinx/jinja2glue.py +++ b/sphinx/jinja2glue.py @@ -135,7 +135,7 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader): # create a chain of paths to search if theme: # the theme's own dir and its bases' dirs - pathchain = theme.get_dirchain() + pathchain = theme.get_theme_dirs() # the loader dirs: pathchain + the parent directories for all themes loaderchain = pathchain + [path.join(p, '..') for p in pathchain] elif dirs: diff --git a/sphinx/theming.py b/sphinx/theming.py index 7bf8a1399..c9fe904ea 100644 --- a/sphinx/theming.py +++ b/sphinx/theming.py @@ -81,8 +81,7 @@ class Theme(object): raise ThemeError(_('no theme named %r found, inherited by %r') % (inherit, name)) - @property - def dirs(self): + def get_theme_dirs(self): # type: () -> List[unicode] """Return a list of theme directories, beginning with this theme's, then the base theme's, then that one's base theme's, etc. @@ -90,14 +89,7 @@ class Theme(object): if self.base is None: return [self.themedir] else: - return [self.themedir] + self.base.get_dirchain() - - def get_dirchain(self): - # type: () -> List[unicode] - """Return a list of theme directories, beginning with this theme's, - then the base theme's, then that one's base theme's, etc. - """ - return self.dirs + return [self.themedir] + self.base.get_theme_dirs() def get_config(self, section, name, default=NODEFAULT): # type: (unicode, unicode, Any) -> Any @@ -116,13 +108,6 @@ class Theme(object): else: return default - def get_confstr(self, section, name, default=NODEFAULT): - # type: (unicode, unicode, Any) -> Any - """Return the value for a theme configuration setting, searching the - base theme chain. - """ - return self.get_config(section, name, default) - def get_options(self, overrides={}): # type: (Dict[unicode, Any]) -> Dict[unicode, Any] """Return a dictionary of theme options and their values.""" diff --git a/tests/test_theming.py b/tests/test_theming.py index ae4c396f2..ef9656bc5 100644 --- a/tests/test_theming.py +++ b/tests/test_theming.py @@ -35,16 +35,16 @@ def test_theme_api(app, status, warning): assert theme.name == 'ziptheme' themedir = theme.themedir assert theme.base.name == 'basic' - assert len(theme.get_dirchain()) == 2 + assert len(theme.get_theme_dirs()) == 2 # direct setting - assert theme.get_confstr('theme', 'stylesheet') == 'custom.css' + assert theme.get_config('theme', 'stylesheet') == 'custom.css' # inherited setting - assert theme.get_confstr('options', 'nosidebar') == 'false' + assert theme.get_config('options', 'nosidebar') == 'false' # nonexisting setting - assert theme.get_confstr('theme', 'foobar', 'def') == 'def' + assert theme.get_config('theme', 'foobar', 'def') == 'def' with pytest.raises(ThemeError): - theme.get_confstr('theme', 'foobar') + theme.get_config('theme', 'foobar') # options API with pytest.raises(ThemeError): |