diff --git a/docs/img/plugin-events.py b/docs/img/plugin-events.py
index 8e8cfbc4c6..0ad1f982a3 100644
--- a/docs/img/plugin-events.py
+++ b/docs/img/plugin-events.py
@@ -87,7 +87,7 @@ def placeholder_cluster(g, name):
node(c, f"placeholder_{name}", label="...", fillcolor="transparent", color="transparent")
-event(graph, "on_startup", "command")
+event(graph, "on_startup", "command dirty")
with cluster(graph, "cluster_build", bgcolor="#dddddd11") as g:
event(g, "on_config", "config")
diff --git a/docs/img/plugin-events.svg b/docs/img/plugin-events.svg
index da2e08bd52..6fc4702b10 100644
--- a/docs/img/plugin-events.svg
+++ b/docs/img/plugin-events.svg
@@ -8,8 +8,8 @@
cluster_on_startup
-
-on_startup
+
+on_startup
@@ -24,32 +24,32 @@
cluster_on_config
-
-on_config
+
+on_config
cluster_on_pre_build
-
-on_pre_build
+
+on_pre_build
cluster_on_files
-
-on_files
+
+on_files
cluster_on_nav
-
-on_nav
+
+on_nav
@@ -185,8 +185,10 @@
on_startup
-
-command
+
+command
+
+dirty
@@ -194,8 +196,8 @@
load_config
-
-load_config
+
+load_config
@@ -204,8 +206,8 @@
on_config
-
-config
+
+config
@@ -213,8 +215,8 @@
on_pre_build
-
-config
+
+config
@@ -222,8 +224,8 @@
on_config:s->on_pre_build:n
-
-
+
+
@@ -231,8 +233,8 @@
get_files
-
-get_files
+
+get_files
@@ -240,8 +242,8 @@
on_config:s->get_files
-
-
+
+
@@ -249,10 +251,10 @@
on_files
-
-files
-
-config
+
+files
+
+config
@@ -261,12 +263,12 @@
on_nav
-
-nav
-
-config
-
-files
+
+nav
+
+config
+
+files
@@ -274,8 +276,8 @@
on_files:s->on_nav:n
-
-
+
+
@@ -283,8 +285,8 @@
get_nav
-
-get_nav
+
+get_nav
@@ -292,8 +294,8 @@
on_files:s->get_nav
-
-
+
+
@@ -311,7 +313,7 @@
pages_point_a
-
+
@@ -319,7 +321,7 @@
on_nav:s->pages_point_a
-
+
@@ -336,7 +338,7 @@
on_nav:s->get_context
-
+
@@ -345,8 +347,8 @@
load_config->on_config:n
-
-
+
+
@@ -354,8 +356,8 @@
get_files->on_files:n
-
-
+
+
@@ -363,8 +365,8 @@
get_nav->on_nav:n
-
-
+
+
@@ -493,7 +495,7 @@
pages_point_a->on_pre_page:n
-
+
@@ -502,8 +504,8 @@
pages_point_a->render_p
-
-
+
+
@@ -520,8 +522,8 @@
pages_point_a->placeholder_cluster_populate_page_2:n
-
-
+
+
@@ -538,7 +540,7 @@
pages_point_a->placeholder_cluster_populate_page_3:n
-
+
diff --git a/mkdocs/__main__.py b/mkdocs/__main__.py
index 8b6066cbaf..5208da5f43 100644
--- a/mkdocs/__main__.py
+++ b/mkdocs/__main__.py
@@ -241,7 +241,7 @@ def build_command(clean, **kwargs):
_enable_warnings()
cfg = config.load_config(**kwargs)
- cfg['plugins'].run_event('startup', command='build')
+ cfg['plugins'].run_event('startup', command='build', dirty=not clean)
try:
build.build(cfg, dirty=not clean)
finally:
@@ -268,7 +268,7 @@ def gh_deploy_command(
_enable_warnings()
cfg = config.load_config(remote_branch=remote_branch, remote_name=remote_name, **kwargs)
- cfg['plugins'].run_event('startup', command='gh-deploy')
+ cfg['plugins'].run_event('startup', command='gh-deploy', dirty=not clean)
try:
build.build(cfg, dirty=not clean)
finally:
diff --git a/mkdocs/commands/serve.py b/mkdocs/commands/serve.py
index 7d44fed6b3..75f72e5496 100644
--- a/mkdocs/commands/serve.py
+++ b/mkdocs/commands/serve.py
@@ -54,6 +54,9 @@ def mount_path(config):
**kwargs,
)
+ live_server = livereload in ('dirty', 'livereload')
+ dirty = livereload == 'dirty'
+
def builder(config=None):
log.info("Building documentation...")
if config is None:
@@ -68,12 +71,10 @@ def builder(config=None):
# Override a few config settings after validation
config['site_url'] = 'http://{}{}'.format(config['dev_addr'], mount_path(config))
- live_server = livereload in ['dirty', 'livereload']
- dirty = livereload == 'dirty'
build(config, live_server=live_server, dirty=dirty)
config = get_config()
- config['plugins'].run_event('startup', command='serve')
+ config['plugins'].run_event('startup', command='serve', dirty=dirty)
try:
# Perform the initial build
@@ -93,7 +94,7 @@ def error_handler(code):
server.error_handler = error_handler
- if livereload in ['livereload', 'dirty']:
+ if live_server:
# Watch the documentation files, the config file and the theme files.
server.watch(config['docs_dir'])
server.watch(config['config_file_path'])
diff --git a/mkdocs/plugins.py b/mkdocs/plugins.py
index e7341a3878..b38e4ff7be 100644
--- a/mkdocs/plugins.py
+++ b/mkdocs/plugins.py
@@ -68,7 +68,7 @@ def load_config(
# One-time events
- def on_startup(self, command: Literal['build', 'gh-deploy', 'serve']) -> None:
+ def on_startup(self, command: Literal['build', 'gh-deploy', 'serve'], dirty: bool) -> None:
"""
The `startup` event runs once at the very beginning of an `mkdocs` invocation.
@@ -82,6 +82,7 @@ def on_startup(self, command: Literal['build', 'gh-deploy', 'serve']) -> None:
Parameters:
command: the command that MkDocs was invoked with, e.g. "serve" for `mkdocs serve`.
+ dirty: whether `--dirtyreload` or `--dirty` flags were passed.
"""
def on_shutdown(self) -> None: