Disabled info plugin on serve by default

This commit is contained in:
squidfunk 2023-01-19 20:56:15 +01:00
parent 6119df5d56
commit c31ef005b4
2 changed files with 24 additions and 0 deletions

View File

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

View File

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