From c31ef005b4fd791c48381694c68fb6f9701e72c7 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Thu, 19 Jan 2023 20:56:15 +0100 Subject: [PATCH] Disabled info plugin on serve by default --- material/plugins/info/plugin.py | 12 ++++++++++++ src/plugins/info/plugin.py | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/material/plugins/info/plugin.py b/material/plugins/info/plugin.py index ea419e011..eaa12b81d 100644 --- a/material/plugins/info/plugin.py +++ b/material/plugins/info/plugin.py @@ -43,6 +43,7 @@ from zipfile import ZipFile, ZIP_DEFLATED # Info plugin configuration scheme class InfoPluginConfig(Config): enabled = opt.Type(bool, default = True) + enabled_on_serve = opt.Type(bool, default = False) # Options for archive archive = opt.Type(bool, default = True) @@ -54,6 +55,17 @@ class InfoPluginConfig(Config): # Info plugin class InfoPlugin(BasePlugin[InfoPluginConfig]): + # Determine whether we're serving + def on_startup(self, *, command, dirty): + 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): diff --git a/src/plugins/info/plugin.py b/src/plugins/info/plugin.py index ea419e011..eaa12b81d 100644 --- a/src/plugins/info/plugin.py +++ b/src/plugins/info/plugin.py @@ -43,6 +43,7 @@ from zipfile import ZipFile, ZIP_DEFLATED # Info plugin configuration scheme class InfoPluginConfig(Config): enabled = opt.Type(bool, default = True) + enabled_on_serve = opt.Type(bool, default = False) # Options for archive archive = opt.Type(bool, default = True) @@ -54,6 +55,17 @@ class InfoPluginConfig(Config): # Info plugin class InfoPlugin(BasePlugin[InfoPluginConfig]): + # Determine whether we're serving + def on_startup(self, *, command, dirty): + 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):