mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Define theme properties on the `Theme
` object
This commit is contained in:
parent
fda9a313a6
commit
256c8f9de0
@ -88,6 +88,21 @@ class Theme:
|
|||||||
raise ThemeError(__('theme %r doesn\'t have "inherit" setting') % name) from exc
|
raise ThemeError(__('theme %r doesn\'t have "inherit" setting') % name) from exc
|
||||||
self._load_ancestor_theme(inherit, theme_factory, name)
|
self._load_ancestor_theme(inherit, theme_factory, name)
|
||||||
|
|
||||||
|
try:
|
||||||
|
self._options = dict(self.config.items('options'))
|
||||||
|
except configparser.NoSectionError:
|
||||||
|
self._options = {}
|
||||||
|
|
||||||
|
self.inherit = inherit
|
||||||
|
try:
|
||||||
|
self.stylesheet = self.get_config('theme', 'stylesheet')
|
||||||
|
except configparser.NoOptionError:
|
||||||
|
msg = __("No loaded theme defines 'theme.stylesheet' in the configuration")
|
||||||
|
raise ThemeError(msg) from None
|
||||||
|
self.sidebars = self.get_config('theme', 'sidebars', None)
|
||||||
|
self.pygments_style = self.get_config('theme', 'pygments_style', None)
|
||||||
|
self.pygments_dark_style = self.get_config('theme', 'pygments_dark_style', None)
|
||||||
|
|
||||||
def _load_ancestor_theme(
|
def _load_ancestor_theme(
|
||||||
self,
|
self,
|
||||||
inherit: str,
|
inherit: str,
|
||||||
@ -130,13 +145,11 @@ class Theme:
|
|||||||
if overrides is None:
|
if overrides is None:
|
||||||
overrides = {}
|
overrides = {}
|
||||||
|
|
||||||
if self._base:
|
if self._base is not None:
|
||||||
options = self._base.get_options()
|
options = self._base.get_options()
|
||||||
else:
|
else:
|
||||||
options = {}
|
options = {}
|
||||||
|
options |= self._options
|
||||||
with contextlib.suppress(configparser.NoSectionError):
|
|
||||||
options.update(self.config.items('options'))
|
|
||||||
|
|
||||||
for option, value in overrides.items():
|
for option, value in overrides.items():
|
||||||
if option not in options:
|
if option not in options:
|
||||||
|
Loading…
Reference in New Issue
Block a user