Return the default value for unsupported theme configuration sections

This commit is contained in:
Adam Turner 2024-04-19 02:14:12 +01:00
parent 62c3bad0da
commit 4a0c9ddc7b
2 changed files with 14 additions and 2 deletions

View File

@ -7,7 +7,9 @@ Bugs fixed
* #12299: Defer loading themes defined via entry points until
their explicit use by the user or a child theme.
Patch by Adam Turner.
* #12305: Return the default value for ``theme.get_config()`` with
an unsupported theme configuration section.
Patch by Adam Turner.
Release 7.3.6 (released Apr 17, 2024)
=====================================

View File

@ -121,7 +121,17 @@ class Theme:
elif section == 'options':
value = self._options.get(name, default)
else:
value = _NO_DEFAULT
# 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)'
)
logger.info(msg % section)
value = default
if value is _NO_DEFAULT:
msg = __('setting %s.%s occurs in none of the searched theme configs') % (
section,