From ddace9739ffa43b26285e82ea70c8ff0d0e719af Mon Sep 17 00:00:00 2001 From: Tim Vink Date: Fri, 13 Sep 2024 13:13:18 +0000 Subject: [PATCH 1/2] remove property on register methods --- mkdocs_macros/plugin.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/mkdocs_macros/plugin.py b/mkdocs_macros/plugin.py index 729c687..7b35672 100644 --- a/mkdocs_macros/plugin.py +++ b/mkdocs_macros/plugin.py @@ -327,7 +327,6 @@ def raw_markdown(self, value): # ---------------------------------- # Hooks for other applications # ---------------------------------- - @property def register_macro(self, items:dict): """ Register macros (hook for other plugins). @@ -341,7 +340,6 @@ def register_macro(self, items:dict): # before on_config: store for later self._add_macros += items - @property def register_filters(self, items:dict): """ Register filters (hook for other plugins). @@ -355,7 +353,6 @@ def register_filters(self, items:dict): # before on_config: store for later self._add_filters += items - @property def register_variables(self, items:dict): """ Register variables (hook for other plugins). From 03f5e89acfa246439cc877cc83c386cdebb1b21f Mon Sep 17 00:00:00 2001 From: Tim Vink Date: Fri, 13 Sep 2024 14:11:00 +0000 Subject: [PATCH 2/2] Fix registration system --- mkdocs_macros/plugin.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mkdocs_macros/plugin.py b/mkdocs_macros/plugin.py index 7b35672..62becb2 100644 --- a/mkdocs_macros/plugin.py +++ b/mkdocs_macros/plugin.py @@ -327,7 +327,7 @@ def raw_markdown(self, value): # ---------------------------------- # Hooks for other applications # ---------------------------------- - def register_macro(self, items:dict): + def register_macros(self, items:dict): """ Register macros (hook for other plugins). These will be added last, and raise an exception if already present. @@ -336,9 +336,11 @@ def register_macro(self, items:dict): # after on_config self._macros register_items('macro', self.macros, items) + self.variables["macros"].update(self.macros) + self.env.globals.update(self.macros) except AttributeError: # before on_config: store for later - self._add_macros += items + self._add_macros.update(items) def register_filters(self, items:dict): """ @@ -346,12 +348,13 @@ def register_filters(self, items:dict): These will be added last, and raise an exception if already present. """ try: - # after on_config self._filters register_items('filter', self.filters, items) + self.variables["filters"].update(self.filters) + self.env.filters.update(self.filters) except AttributeError: # before on_config: store for later - self._add_filters += items + self._add_filters.update(items) def register_variables(self, items:dict): """ @@ -364,7 +367,7 @@ def register_variables(self, items:dict): register_items('variables', self.variables, items) except AttributeError: # before on_config: store for later - self._add_variables += items + self._add_variables.update(items) # ---------------------------------- # Function lists, for later events