Skip to content

Commit

Permalink
feature(plugin): add a flag attribute to acts depending on the used m…
Browse files Browse the repository at this point in the history
…kdocs command
  • Loading branch information
Guts committed Jun 25, 2024
1 parent 97ce5dd commit f5a9746
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion mkdocs_rss_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from email.utils import formatdate
from pathlib import Path
from re import compile as re_compile
from typing import List, Optional
from typing import List, Literal, Optional

# 3rd party
from jinja2 import Environment, FileSystemLoader, select_autoescape
Expand Down Expand Up @@ -62,6 +62,21 @@ def __init__(self):
# prepare output feeds
self.feed_created: dict = {}
self.feed_updated: dict = {}
# flag used command to disable some actions if serve is used
self.cmd_is_serve: bool = False

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.
See: https://www.mkdocs.org/user-guide/plugins/#on_startup
Args:
command: the command that MkDocs was invoked with, e.g. "serve" for `mkdocs serve`.
dirty: whether `--dirty` flag was passed.
"""
self.cmd_is_serve = command == "serve"

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

0 comments on commit f5a9746

Please sign in to comment.