Skip to content

Commit 256c8f9

Browse files
committed
Define theme properties on the Theme object
1 parent fda9a31 commit 256c8f9

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

sphinx/theming.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ def __init__(self, name: str, theme_path: str, theme_factory: HTMLThemeFactory)
8888
raise ThemeError(__('theme %r doesn\'t have "inherit" setting') % name) from exc
8989
self._load_ancestor_theme(inherit, theme_factory, name)
9090

91+
try:
92+
self._options = dict(self.config.items('options'))
93+
except configparser.NoSectionError:
94+
self._options = {}
95+
96+
self.inherit = inherit
97+
try:
98+
self.stylesheet = self.get_config('theme', 'stylesheet')
99+
except configparser.NoOptionError:
100+
msg = __("No loaded theme defines 'theme.stylesheet' in the configuration")
101+
raise ThemeError(msg) from None
102+
self.sidebars = self.get_config('theme', 'sidebars', None)
103+
self.pygments_style = self.get_config('theme', 'pygments_style', None)
104+
self.pygments_dark_style = self.get_config('theme', 'pygments_dark_style', None)
105+
91106
def _load_ancestor_theme(
92107
self,
93108
inherit: str,
@@ -130,13 +145,11 @@ def get_options(self, overrides: dict[str, Any] | None = None) -> dict[str, Any]
130145
if overrides is None:
131146
overrides = {}
132147

133-
if self._base:
148+
if self._base is not None:
134149
options = self._base.get_options()
135150
else:
136151
options = {}
137-
138-
with contextlib.suppress(configparser.NoSectionError):
139-
options.update(self.config.items('options'))
152+
options |= self._options
140153

141154
for option, value in overrides.items():
142155
if option not in options:

0 commit comments

Comments
 (0)