Skip to content

Commit

Permalink
Let plugins put strings into warnings
Browse files Browse the repository at this point in the history
even though they should be 2-tuples.

Fixes #3014
  • Loading branch information
oprypin committed Oct 21, 2022
1 parent 0584e51 commit 427d553
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mkdocs/config/config_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,11 +996,19 @@ def load_plugin(self, name: str, config) -> plugins.BasePlugin:
if hasattr(plugin, 'on_startup') or hasattr(plugin, 'on_shutdown'):
self.plugin_cache[name] = plugin

errors, warnings = plugin.load_config(
errors, warns = plugin.load_config(
config, self._config.config_file_path if self._config else None
)
self.warnings.extend(f"Plugin '{name}' value: '{x}'. Warning: {y}" for x, y in warnings)
errors_message = '\n'.join(f"Plugin '{name}' value: '{x}'. Error: {y}" for x, y in errors)
for warning in warns:
if isinstance(warning, str):
self.warnings.append(f"Plugin '{name}'. Warning: {warning}")
else:
key, msg = warning
self.warnings.append(f"Plugin '{name}' value: '{key}'. Warning: {msg}")

errors_message = '\n'.join(
f"Plugin '{name}' value: '{key}'. Error: {msg}" for key, msg in errors
)
if errors_message:
raise ValidationError(errors_message)
return plugin
Expand Down

0 comments on commit 427d553

Please sign in to comment.