From ab178b2bc221603321bfdbf88ea5baa347d1fd63 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Mon, 24 Jul 2023 12:29:16 +0100 Subject: [PATCH] Improve plugin inter-op with external tools like mike --- material/plugins/blog/plugin.py | 10 +++++++++- material/plugins/info/plugin.py | 7 +++++++ material/plugins/search/plugin.py | 12 +++++++++--- src/plugins/blog/plugin.py | 10 +++++++++- src/plugins/info/plugin.py | 7 +++++++ src/plugins/search/plugin.py | 12 +++++++++--- 6 files changed, 50 insertions(+), 8 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index fe365ba2c..c456336c5 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -52,10 +52,18 @@ from material.plugins.blog.config import BlogConfig class BlogPlugin(BasePlugin[BlogConfig]): supports_multiple_instances = True + # Initialize plugin + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + # Initialize variables for incremental builds + self.is_serve = False + self.is_dirtyreload = False + self.is_dirty = False + # Determine whether we're running under dirty reload def on_startup(self, *, command, dirty): self.is_serve = (command == "serve") - self.is_dirtyreload = False self.is_dirty = dirty # Initialize plugin diff --git a/material/plugins/info/plugin.py b/material/plugins/info/plugin.py index f6cdc704a..b3b82e435 100644 --- a/material/plugins/info/plugin.py +++ b/material/plugins/info/plugin.py @@ -42,6 +42,13 @@ from material.plugins.info.config import InfoConfig # Info plugin class InfoPlugin(BasePlugin[InfoConfig]): + # Initialize plugin + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + # Initialize variables for incremental builds + self.is_serve = False + # Determine whether we're serving def on_startup(self, *, command, dirty): self.is_serve = (command == "serve") diff --git a/material/plugins/search/plugin.py b/material/plugins/search/plugin.py index 731d653b0..b1103b10e 100644 --- a/material/plugins/search/plugin.py +++ b/material/plugins/search/plugin.py @@ -42,14 +42,20 @@ except ImportError: # Search plugin class SearchPlugin(BasePlugin[SearchConfig]): - # Determine whether we're running under dirty reload - def on_startup(self, *, command, dirty): + # Initialize plugin + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + # Initialize variables for incremental builds self.is_dirtyreload = False - self.is_dirty = dirty # Initialize search index cache self.search_index_prev = None + # Determine whether we're serving + def on_startup(self, *, command, dirty): + self.is_dirty = dirty + # Initialize plugin def on_config(self, config): if not self.config.lang: diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index fe365ba2c..c456336c5 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -52,10 +52,18 @@ from material.plugins.blog.config import BlogConfig class BlogPlugin(BasePlugin[BlogConfig]): supports_multiple_instances = True + # Initialize plugin + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + # Initialize variables for incremental builds + self.is_serve = False + self.is_dirtyreload = False + self.is_dirty = False + # Determine whether we're running under dirty reload def on_startup(self, *, command, dirty): self.is_serve = (command == "serve") - self.is_dirtyreload = False self.is_dirty = dirty # Initialize plugin diff --git a/src/plugins/info/plugin.py b/src/plugins/info/plugin.py index f6cdc704a..b3b82e435 100644 --- a/src/plugins/info/plugin.py +++ b/src/plugins/info/plugin.py @@ -42,6 +42,13 @@ from material.plugins.info.config import InfoConfig # Info plugin class InfoPlugin(BasePlugin[InfoConfig]): + # Initialize plugin + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + # Initialize variables for incremental builds + self.is_serve = False + # Determine whether we're serving def on_startup(self, *, command, dirty): self.is_serve = (command == "serve") diff --git a/src/plugins/search/plugin.py b/src/plugins/search/plugin.py index 731d653b0..b1103b10e 100644 --- a/src/plugins/search/plugin.py +++ b/src/plugins/search/plugin.py @@ -42,14 +42,20 @@ except ImportError: # Search plugin class SearchPlugin(BasePlugin[SearchConfig]): - # Determine whether we're running under dirty reload - def on_startup(self, *, command, dirty): + # Initialize plugin + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + # Initialize variables for incremental builds self.is_dirtyreload = False - self.is_dirty = dirty # Initialize search index cache self.search_index_prev = None + # Determine whether we're serving + def on_startup(self, *, command, dirty): + self.is_dirty = dirty + # Initialize plugin def on_config(self, config): if not self.config.lang: