mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Drop old methods
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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."""
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user