mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Disabled info plugin on serve by default
This commit is contained in:
parent
6119df5d56
commit
c31ef005b4
@ -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):
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user