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):