Skip to content

Commit f5a9746

Browse files
committed
feature(plugin): add a flag attribute to acts depending on the used mkdocs command
1 parent 97ce5dd commit f5a9746

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

mkdocs_rss_plugin/plugin.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from email.utils import formatdate
1212
from pathlib import Path
1313
from re import compile as re_compile
14-
from typing import List, Optional
14+
from typing import List, Literal, Optional
1515

1616
# 3rd party
1717
from jinja2 import Environment, FileSystemLoader, select_autoescape
@@ -62,6 +62,21 @@ def __init__(self):
6262
# prepare output feeds
6363
self.feed_created: dict = {}
6464
self.feed_updated: dict = {}
65+
# flag used command to disable some actions if serve is used
66+
self.cmd_is_serve: bool = False
67+
68+
def on_startup(
69+
self, *, command: Literal["build", "gh-deploy", "serve"], dirty: bool
70+
) -> None:
71+
"""The `startup` event runs once at the very beginning of an `mkdocs` invocation.
72+
73+
See: https://www.mkdocs.org/user-guide/plugins/#on_startup
74+
75+
Args:
76+
command: the command that MkDocs was invoked with, e.g. "serve" for `mkdocs serve`.
77+
dirty: whether `--dirty` flag was passed.
78+
"""
79+
self.cmd_is_serve = command == "serve"
6580

6681
def on_config(self, config: MkDocsConfig) -> MkDocsConfig:
6782
"""The config event is the first event called on build and

0 commit comments

Comments
 (0)