Prevent a confusing stack trace when theme config fails validation

Caused by previous commit.
When, for example, the chosen theme is not installed, a stack trace would be shown instead of a proper error. Because then somehow the theme config remains a dict but validation moves on anyway.
This commit is contained in:
Oleh Prypin
2022-10-14 00:23:55 +02:00
parent 6fca6b59a2
commit 6b7d0a55e0
2 changed files with 2 additions and 2 deletions

View File

@@ -966,7 +966,7 @@ class Plugins(OptionallyRequired[plugins.PluginCollection]):
else:
# Attempt to load with prepended namespace for the current theme.
if self.theme_key and self._config:
current_theme = self._config[self.theme_key].name
current_theme = self._config[self.theme_key]['name']
if current_theme:
expanded_name = f'{current_theme}/{name}'
if expanded_name in self.installed_plugins:

View File

@@ -31,7 +31,7 @@ class Theme:
def __init__(self, name: Optional[str] = None, **user_config) -> None:
self.name = name
self._vars = {'locale': 'en'}
self._vars = {'name': name, 'locale': 'en'}
# MkDocs provided static templates are always included
package_dir = os.path.abspath(os.path.dirname(__file__))