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.
|
Patch by Adam Turner.
|
||||||
* #12593: Raise an error for invalid :confval:`html_sidebars` values.
|
* #12593: Raise an error for invalid :confval:`html_sidebars` values.
|
||||||
Patch by Adam Turner.
|
Patch by Adam Turner.
|
||||||
|
* #12593: Raise an error in :py:func:`!Theme.get_config` for invalid sections.
|
||||||
|
Patch by Adam Turner.
|
||||||
|
|
||||||
Deprecated
|
Deprecated
|
||||||
----------
|
----------
|
||||||
|
|||||||
@@ -121,17 +121,11 @@ class Theme:
|
|||||||
elif section == 'options':
|
elif section == 'options':
|
||||||
value = self._options.get(name, default)
|
value = self._options.get(name, default)
|
||||||
else:
|
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 = __(
|
msg = __(
|
||||||
'Theme configuration sections other than [theme] and [options] '
|
'Theme configuration sections other than [theme] and [options] '
|
||||||
'are not supported, returning the default value instead '
|
'are not supported (tried to get a value from %r).'
|
||||||
'(tried to get a value from %r)'
|
|
||||||
)
|
)
|
||||||
logger.info(msg, section)
|
raise ThemeError(msg)
|
||||||
value = default
|
|
||||||
if value is _NO_DEFAULT:
|
if value is _NO_DEFAULT:
|
||||||
msg = __('setting %s.%s occurs in none of the searched theme configs') % (
|
msg = __('setting %s.%s occurs in none of the searched theme configs') % (
|
||||||
section,
|
section,
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ def test_theme_api(app, status, warning):
|
|||||||
assert theme.get_config('theme', 'foobar', 'def') == 'def'
|
assert theme.get_config('theme', 'foobar', 'def') == 'def'
|
||||||
with pytest.raises(ThemeError):
|
with pytest.raises(ThemeError):
|
||||||
theme.get_config('theme', 'foobar')
|
theme.get_config('theme', 'foobar')
|
||||||
|
# nonexisting section
|
||||||
|
with pytest.raises(ThemeError):
|
||||||
|
theme.get_config('foobar', 'foobar')
|
||||||
|
|
||||||
# options API
|
# options API
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user