Skip to content

Commit 6b47c95

Browse files
committed
fix(startup): move per-build variables under on_startup event
1 parent 5e78405 commit 6b47c95

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

mkdocs_rss_plugin/plugin.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,33 @@ class GitRssPlugin(BasePlugin[RssPluginConfig]):
5555
# allow to set the plugin multiple times in the same mkdocs config
5656
supports_multiple_instances = True
5757

58-
def __init__(self):
58+
def __init__(self, *args, **kwargs):
5959
"""Instantiation."""
6060
# pages storage
61-
self.pages_to_filter: List[PageInformation] = []
62-
# prepare output feeds
63-
self.feed_created: dict = {}
64-
self.feed_updated: dict = {}
65-
# flag used command to disable some actions if serve is used
66-
self.cmd_is_serve: bool = False
61+
super().__init__(*args, **kwargs)
6762

6863
def on_startup(
6964
self, *, command: Literal["build", "gh-deploy", "serve"], dirty: bool
7065
) -> None:
7166
"""The `startup` event runs once at the very beginning of an `mkdocs` invocation.
67+
Note that for initializing variables, the __init__ method is still preferred.
68+
For initializing per-build variables (and whenever in doubt), use the
69+
on_config event.
7270
7371
See: https://www.mkdocs.org/user-guide/plugins/#on_startup
7472
7573
Args:
7674
command: the command that MkDocs was invoked with, e.g. "serve" for `mkdocs serve`.
7775
dirty: whether `--dirty` flag was passed.
7876
"""
77+
# flag used command to disable some actions if serve is used
7978
self.cmd_is_serve = command == "serve"
8079

80+
self.pages_to_filter: List[PageInformation] = []
81+
# prepare output feeds
82+
self.feed_created: dict = {}
83+
self.feed_updated: dict = {}
84+
8185
def on_config(self, config: MkDocsConfig) -> MkDocsConfig:
8286
"""The config event is the first event called on build and
8387
is run immediately after the user configuration is loaded and validated.

0 commit comments

Comments
 (0)