diff --git a/material/plugins/tags/plugin.py b/material/plugins/tags/plugin.py index b4143becaf9..ec6d6ba2841 100644 --- a/material/plugins/tags/plugin.py +++ b/material/plugins/tags/plugin.py @@ -36,7 +36,6 @@ from .renderer import Renderer from .structure.listing.manager import ListingManager from .structure.mapping.manager import MappingManager -from .structure.mapping.storage import MappingStorage # ----------------------------------------------------------------------------- # Classes @@ -45,11 +44,6 @@ class TagsPlugin(BasePlugin[TagsConfig]): """ A tags plugin. - - This plugin collects tags from the front matter of pages, and builds a tag - structure from them. The tag structure can be used to render listings on - pages, or to just create a site-wide tags index and export all tags and - mappings to a JSON file for consumption in another project. """ supports_multiple_instances = True @@ -129,12 +123,6 @@ def on_config(self, config: MkDocsConfig) -> None: else: config.markdown_extensions.append("attr_list") - # If the author only wants to extract and export mappings, we allow to - # disable the rendering of all tags and listings with a single setting - if self.config.export_only: - self.config.tags = False - self.config.listings = False - @event_priority(-50) def on_page_markdown( self, markdown: str, *, page: Page, config: MkDocsConfig, **kwargs @@ -163,10 +151,6 @@ def on_page_markdown( if self.config.tags_file: markdown = self._handle_deprecated_tags_file(page, markdown) - # Handle deprecation of `tags_extra_files` setting - if self.config.tags_extra_files: - markdown = self._handle_deprecated_tags_extra_files(page, markdown) - # Collect tags from page try: self.mappings.add(page, markdown) @@ -202,15 +186,6 @@ def on_env( # Populate and render all listings self.listings.populate_all(self.mappings, Renderer(env, config)) - # Export mappings to file, if enabled - if self.config.export: - path = os.path.join(config.site_dir, self.config.export_file) - path = os.path.normpath(path) - - # Serialize mappings and save to file - storage = MappingStorage(self.config) - storage.save(path, self.mappings) - def on_page_context( self, context: TemplateContext, *, page: Page, **kwargs ) -> None: @@ -268,38 +243,6 @@ def _handle_deprecated_tags_file( # Return markdown return markdown - def _handle_deprecated_tags_extra_files( - self, page: Page, markdown: str - ) -> str: - """ - Handle deprecation of `tags_extra_files` setting. - - Arguments: - page: The page. - """ - directive = self.config.listings_directive - if page.file.src_uri not in self.config.tags_extra_files: - return markdown - - # Compute tags to render on page - tags = self.config.tags_extra_files[page.file.src_uri] - if tags: - directive += f" {{ include: [{', '.join(tags)}] }}" - - # Try to find the legacy tags marker and replace with directive - if "[TAGS]" in markdown: - markdown = markdown.replace( - "[TAGS]", f"" - ) - - # Try to find the directive and add it if not present - pattern = r"" - - # Return markdown - return markdown - # ----------------------------------------------------------------------------- # Data # ----------------------------------------------------------------------------- diff --git a/material/plugins/tags/structure/listing/manager/toc.py b/material/plugins/tags/structure/listing/manager/toc.py index 7c8e4275abf..e9970c0305e 100644 --- a/material/plugins/tags/structure/listing/manager/toc.py +++ b/material/plugins/tags/structure/listing/manager/toc.py @@ -81,10 +81,7 @@ def populate(listing: Listing, slugify: Slugify) -> dict[Tag, AnchorLink]: # Filter top-level anchor links and insert them into the page children = [anchors[tag] for tag in anchors if not tag.parent] - if listing.config.toc: - host.children[at:at + 1] = children - else: - host.children.pop(at) + host.children[at:at + 1] = children # Return mapping of tags to anchor links return anchors diff --git a/src/plugins/tags/plugin.py b/src/plugins/tags/plugin.py index b4143becaf9..ec6d6ba2841 100644 --- a/src/plugins/tags/plugin.py +++ b/src/plugins/tags/plugin.py @@ -36,7 +36,6 @@ from .renderer import Renderer from .structure.listing.manager import ListingManager from .structure.mapping.manager import MappingManager -from .structure.mapping.storage import MappingStorage # ----------------------------------------------------------------------------- # Classes @@ -45,11 +44,6 @@ class TagsPlugin(BasePlugin[TagsConfig]): """ A tags plugin. - - This plugin collects tags from the front matter of pages, and builds a tag - structure from them. The tag structure can be used to render listings on - pages, or to just create a site-wide tags index and export all tags and - mappings to a JSON file for consumption in another project. """ supports_multiple_instances = True @@ -129,12 +123,6 @@ def on_config(self, config: MkDocsConfig) -> None: else: config.markdown_extensions.append("attr_list") - # If the author only wants to extract and export mappings, we allow to - # disable the rendering of all tags and listings with a single setting - if self.config.export_only: - self.config.tags = False - self.config.listings = False - @event_priority(-50) def on_page_markdown( self, markdown: str, *, page: Page, config: MkDocsConfig, **kwargs @@ -163,10 +151,6 @@ def on_page_markdown( if self.config.tags_file: markdown = self._handle_deprecated_tags_file(page, markdown) - # Handle deprecation of `tags_extra_files` setting - if self.config.tags_extra_files: - markdown = self._handle_deprecated_tags_extra_files(page, markdown) - # Collect tags from page try: self.mappings.add(page, markdown) @@ -202,15 +186,6 @@ def on_env( # Populate and render all listings self.listings.populate_all(self.mappings, Renderer(env, config)) - # Export mappings to file, if enabled - if self.config.export: - path = os.path.join(config.site_dir, self.config.export_file) - path = os.path.normpath(path) - - # Serialize mappings and save to file - storage = MappingStorage(self.config) - storage.save(path, self.mappings) - def on_page_context( self, context: TemplateContext, *, page: Page, **kwargs ) -> None: @@ -268,38 +243,6 @@ def _handle_deprecated_tags_file( # Return markdown return markdown - def _handle_deprecated_tags_extra_files( - self, page: Page, markdown: str - ) -> str: - """ - Handle deprecation of `tags_extra_files` setting. - - Arguments: - page: The page. - """ - directive = self.config.listings_directive - if page.file.src_uri not in self.config.tags_extra_files: - return markdown - - # Compute tags to render on page - tags = self.config.tags_extra_files[page.file.src_uri] - if tags: - directive += f" {{ include: [{', '.join(tags)}] }}" - - # Try to find the legacy tags marker and replace with directive - if "[TAGS]" in markdown: - markdown = markdown.replace( - "[TAGS]", f"" - ) - - # Try to find the directive and add it if not present - pattern = r"" - - # Return markdown - return markdown - # ----------------------------------------------------------------------------- # Data # ----------------------------------------------------------------------------- diff --git a/src/plugins/tags/structure/listing/manager/toc.py b/src/plugins/tags/structure/listing/manager/toc.py index 7c8e4275abf..e9970c0305e 100644 --- a/src/plugins/tags/structure/listing/manager/toc.py +++ b/src/plugins/tags/structure/listing/manager/toc.py @@ -81,10 +81,7 @@ def populate(listing: Listing, slugify: Slugify) -> dict[Tag, AnchorLink]: # Filter top-level anchor links and insert them into the page children = [anchors[tag] for tag in anchors if not tag.parent] - if listing.config.toc: - host.children[at:at + 1] = children - else: - host.children.pop(at) + host.children[at:at + 1] = children # Return mapping of tags to anchor links return anchors