8000 Fix #10061: html theme: Confvals added by themes are not initialized · sphinx-doc/sphinx@2a3ea2e · GitHub
[go: up one dir, main page]

8000 Skip to content

Commit 2a3ea2e

Browse files
committed
Fix #10061: html theme: Confvals added by themes are not initialized
1 parent 87eda92 commit 2a3ea2e

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ Bugs fixed
5858
* #9878: mathjax: MathJax configuration is placed after loading MathJax itself
5959
* #9857: Generated RFC links use outdated base url
6060
* #9909: HTML, prevent line-wrapping in literal text.
61+
* #10061: html theme: Configuration values added by themes are not be able to
62+
override from conf.py
6163
* #9925: LaTeX: prohibit also with ``'xelatex'`` line splitting at dashes of
6264
inline and parsed literals
6365
* #9944: LaTeX: extra vertical whitespace for some nested declarations

sphinx/config.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,17 @@ def init_values(self) -> None:
251251
if name in self.values:
252252
self.__dict__[name] = config[name]
253253

254+
def post_init_values(self) -> None:
255+
"""
256+
Initialize additional config variables that are added after init_values() called.
257+
"""
258+
config = self._raw_config
259+
for name in config:
260+
if name not in self.__dict__ and name in self.values:
261+
self.__dict__[name] = config[name]
262+
263+
check_confval_types(None, self)
264+
254265
def __getattr__(self, name: str) -> Any:
255266
if name.startswith('_'):
256267
raise AttributeError(name)
@@ -427,7 +438,7 @@ def check_confval_types(app: "Sphinx", config: Config) -> None:
427438
"but `{current}` is given.")
428439
logger.warning(msg.format(name=confval.name,
429440
current=confval.value,
430-
candidates=annotations.candidates))
441+
candidates=annotations.candidates), once=True)
431442
else:
432443
if type(confval.value) is type(default):
433444
continue
@@ -452,13 +463,13 @@ def check_confval_types(app: "Sphinx", config: Config) -> None:
452463
permitted = " or ".join(wrapped_annotations)
453464
logger.warning(msg.format(name=confval.name,
454465
current=type(confval.value),
455-
permitted=permitted))
466+
permitted=permitted), once=True)
456467
else:
457468
msg = __("The config value `{name}' has type `{current.__name__}', "
458469
"defaults to `{default.__name__}'.")
459470
logger.warning(msg.format(name=confval.name,
460471
current=type(confval.value),
461-
default=type(default)))
472+
default=type(default)), once=True)
462473

463474

464475
def check_primary_domain(app: "Sphinx", config: Config) -> None:

sphinx/theming.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def load_external_theme(self, name: str) -> None:
208208
try:
209209
entry_point = theme_entry_points[name]
210210
self.app.registry.load_extension(self.app, entry_point.module)
211+
self.app.config.post_init_values()
211212
return
212213
except KeyError:
213214
pass

0 commit comments

Comments
 (0)
0