|
36 | 36 | from .renderer import Renderer
|
37 | 37 | from .structure.listing.manager import ListingManager
|
38 | 38 | from .structure.mapping.manager import MappingManager
|
39 |
| -from .structure.mapping.storage import MappingStorage |
40 | 39 |
|
41 | 40 | # -----------------------------------------------------------------------------
|
42 | 41 | # Classes
|
|
45 | 44 | class TagsPlugin(BasePlugin[TagsConfig]):
|
46 | 45 | """
|
47 | 46 | A tags plugin.
|
48 |
| -
|
49 |
| - This plugin collects tags from the front matter of pages, and builds a tag |
50 |
| - structure from them. The tag structure can be used to render listings on |
51 |
| - pages, or to just create a site-wide tags index and export all tags and |
52 |
| - mappings to a JSON file for consumption in another project. |
53 | 47 | """
|
54 | 48 |
|
55 | 49 | supports_multiple_instances = True
|
@@ -129,12 +123,6 @@ def on_config(self, config: MkDocsConfig) -> None:
|
129 | 123 | else:
|
130 | 124 | config.markdown_extensions.append("attr_list")
|
131 | 125 |
|
132 |
| - # If the author only wants to extract and export mappings, we allow to |
133 |
| - # disable the rendering of all tags and listings with a single setting |
134 |
| - if self.config.export_only: |
135 |
| - self.config.tags = False |
136 |
| - self.config.listings = False |
137 |
| - |
138 | 126 | @event_priority(-50)
|
139 | 127 | def on_page_markdown(
|
140 | 128 | self, markdown: str, *, page: Page, config: MkDocsConfig, **kwargs
|
@@ -163,10 +151,6 @@ def on_page_markdown(
|
163 | 151 | if self.config.tags_file:
|
164 | 152 | markdown = self._handle_deprecated_tags_file(page, markdown)
|
165 | 153 |
|
166 |
| - # Handle deprecation of `tags_extra_files` setting |
167 |
| - if self.config.tags_extra_files: |
168 |
| - markdown = self._handle_deprecated_tags_extra_files(page, markdown) |
169 |
| - |
170 | 154 | # Collect tags from page
|
171 | 155 | try:
|
172 | 156 | self.mappings.add(page, markdown)
|
@@ -202,15 +186,6 @@ def on_env(
|
202 | 186 | # Populate and render all listings
|
203 | 187 | self.listings.populate_all(self.mappings, Renderer(env, config))
|
204 | 188 |
|
205 |
| - # Export mappings to file, if enabled |
206 |
| - if self.config.export: |
207 |
| - path = os.path.join(config.site_dir, self.config.export_file) |
208 |
| - path = os.path.normpath(path) |
209 |
| - |
210 |
| - # Serialize mappings and save to file |
211 |
| - storage = MappingStorage(self.config) |
212 |
| - storage.save(path, self.mappings) |
213 |
| - |
214 | 189 | def on_page_context(
|
215 | 190 | self, context: TemplateContext, *, page: Page, **kwargs
|
216 | 191 | ) -> None:
|
@@ -268,38 +243,6 @@ def _handle_deprecated_tags_file(
|
268 | 243 | # Return markdown
|
269 | 244 | return markdown
|
270 | 245 |
|
271 |
| - def _handle_deprecated_tags_extra_files( |
272 |
| - self, page: Page, markdown: str |
273 |
| - ) -> str: |
274 |
| - """ |
275 |
| - Handle deprecation of `tags_extra_files` setting. |
276 |
| -
|
277 |
| - Arguments: |
278 |
| - page: The page. |
279 |
| - """ |
280 |
| - directive = self.config.listings_directive |
281 |
| - if page.file.src_uri not in self.config.tags_extra_files: |
282 |
| - return markdown |
283 |
| - |
284 |
| - # Compute tags to render on page |
285 |
| - tags = self.config.tags_extra_files[page.file.src_uri] |
286 |
| - if tags: |
287 |
| - directive += f" {{ include: [{', '.join(tags)}] }}" |
288 |
| - |
289 |
| - # Try to find the legacy tags marker and replace with directive |
290 |
| - if "[TAGS]" in markdown: |
291 |
| - markdown = markdown.replace( |
292 |
| - "[TAGS]", f"<!-- {directive} -->" |
293 |
| - ) |
294 |
| - |
295 |
| - # Try to find the directive and add it if not present |
296 |
| - pattern = r"<!--\s+{directive}".format(directive = re.escape(directive)) |
297 |
| - if not re.search(pattern, markdown): |
298 |
| - markdown += f"\n<!-- {directive} -->" |
299 |
| - |
300 |
| - # Return markdown |
301 |
| - return markdown |
302 |
| - |
303 | 246 | # -----------------------------------------------------------------------------
|
304 | 247 | # Data
|
305 | 248 | # -----------------------------------------------------------------------------
|
|
0 commit comments