From ad6c47ddb6cbcca3526ab55005aa22700f35403d Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sat, 28 Jan 2023 12:21:04 +0100 Subject: [PATCH] Fixed info plugin terminating on subsequent reload when serving --- material/plugins/info/plugin.py | 13 ++++++------- src/plugins/info/plugin.py | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/material/plugins/info/plugin.py b/material/plugins/info/plugin.py index eaa12b81d..f8aadb590 100644 --- a/material/plugins/info/plugin.py +++ b/material/plugins/info/plugin.py @@ -57,19 +57,18 @@ class InfoPlugin(BasePlugin[InfoPluginConfig]): # Determine whether we're serving def on_startup(self, *, command, dirty): + self.is_serve = (command == "serve") + + # Initialize plugin (run earliest) + @event_priority(100) + def on_config(self, config): if not self.config.enabled: return # By default, the plugin is disabled when the documentation is served, # but not when it is built. This should nicely align with the expected # user experience when creating reproductions. - if not self.config.enabled_on_serve: - self.config.enabled = command != "serve" - - # Initialize plugin (run earliest) - @event_priority(100) - def on_config(self, config): - if not self.config.enabled: + if not self.config.enabled_on_serve and self.is_serve: return # Resolve latest version diff --git a/src/plugins/info/plugin.py b/src/plugins/info/plugin.py index eaa12b81d..f8aadb590 100644 --- a/src/plugins/info/plugin.py +++ b/src/plugins/info/plugin.py @@ -57,19 +57,18 @@ class InfoPlugin(BasePlugin[InfoPluginConfig]): # Determine whether we're serving def on_startup(self, *, command, dirty): + self.is_serve = (command == "serve") + + # Initialize plugin (run earliest) + @event_priority(100) + def on_config(self, config): if not self.config.enabled: return # By default, the plugin is disabled when the documentation is served, # but not when it is built. This should nicely align with the expected # user experience when creating reproductions. - if not self.config.enabled_on_serve: - self.config.enabled = command != "serve" - - # Initialize plugin (run earliest) - @event_priority(100) - def on_config(self, config): - if not self.config.enabled: + if not self.config.enabled_on_serve and self.is_serve: return # Resolve latest version