mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Raise `ThemeError` for invalid theme sections
This commit is contained in:
@@ -41,6 +41,8 @@ Incompatible changes
|
||||
Patch by Adam Turner.
|
||||
* #12593: Raise an error for invalid :confval:`html_sidebars` values.
|
||||
Patch by Adam Turner.
|
||||
* #12593: Raise an error in :py:func:`!Theme.get_config` for invalid sections.
|
||||
Patch by Adam Turner.
|
||||
|
||||
Deprecated
|
||||
----------
|
||||
|
||||
@@ -121,17 +121,11 @@ class Theme:
|
||||
elif section == 'options':
|
||||
value = self._options.get(name, default)
|
||||
else:
|
||||
# https://github.com/sphinx-doc/sphinx/issues/12305
|
||||
# For backwards compatibility when attempting to read a value
|
||||
# from an unsupported configuration section.
|
||||
# xref: RemovedInSphinx80Warning
|
||||
msg = __(
|
||||
'Theme configuration sections other than [theme] and [options] '
|
||||
'are not supported, returning the default value instead '
|
||||
'(tried to get a value from %r)'
|
||||
'are not supported (tried to get a value from %r).'
|
||||
)
|
||||
logger.info(msg, section)
|
||||
value = default
|
||||
raise ThemeError(msg)
|
||||
if value is _NO_DEFAULT:
|
||||
msg = __('setting %s.%s occurs in none of the searched theme configs') % (
|
||||
section,
|
||||
|
||||
@@ -72,6 +72,9 @@ def test_theme_api(app, status, warning):
|
||||
assert theme.get_config('theme', 'foobar', 'def') == 'def'
|
||||
with pytest.raises(ThemeError):
|
||||
theme.get_config('theme', 'foobar')
|
||||
# nonexisting section
|
||||
with pytest.raises(ThemeError):
|
||||
theme.get_config('foobar', 'foobar')
|
||||
|
||||
# options API
|
||||
|
||||
|
||||
Reference in New Issue
Block a user