mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Added missing enabled setting for tags plugin
This commit is contained in:
parent
c0cdb3ca1f
commit
ba90cb1ccd
@ -19,7 +19,6 @@
|
|||||||
# IN THE SOFTWARE.
|
# IN THE SOFTWARE.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
@ -36,6 +35,9 @@ from mkdocs.plugins import BasePlugin
|
|||||||
|
|
||||||
# Tags plugin configuration scheme
|
# Tags plugin configuration scheme
|
||||||
class TagsPluginConfig(Config):
|
class TagsPluginConfig(Config):
|
||||||
|
enabled = opt.Type(bool, default = True)
|
||||||
|
|
||||||
|
# Options for tags
|
||||||
tags_file = opt.Optional(opt.Type(str))
|
tags_file = opt.Optional(opt.Type(str))
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
@ -46,6 +48,10 @@ class TagsPlugin(BasePlugin[TagsPluginConfig]):
|
|||||||
|
|
||||||
# Initialize plugin
|
# Initialize plugin
|
||||||
def on_config(self, config):
|
def on_config(self, config):
|
||||||
|
if not self.config.enabled:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Initialize tags
|
||||||
self.tags = defaultdict(list)
|
self.tags = defaultdict(list)
|
||||||
self.tags_file = None
|
self.tags_file = None
|
||||||
|
|
||||||
@ -64,12 +70,20 @@ class TagsPlugin(BasePlugin[TagsPluginConfig]):
|
|||||||
|
|
||||||
# Hack: 2nd pass for tags index page(s)
|
# Hack: 2nd pass for tags index page(s)
|
||||||
def on_nav(self, nav, config, files):
|
def on_nav(self, nav, config, files):
|
||||||
|
if not self.config.enabled:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Resolve tags index page
|
||||||
file = self.config.tags_file
|
file = self.config.tags_file
|
||||||
if file:
|
if file:
|
||||||
self.tags_file = self._get_tags_file(files, file)
|
self.tags_file = self._get_tags_file(files, file)
|
||||||
|
|
||||||
# Build and render tags index page
|
# Build and render tags index page
|
||||||
def on_page_markdown(self, markdown, page, config, files):
|
def on_page_markdown(self, markdown, page, config, files):
|
||||||
|
if not self.config.enabled:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Render tags index page
|
||||||
if page.file == self.tags_file:
|
if page.file == self.tags_file:
|
||||||
return self._render_tag_index(markdown)
|
return self._render_tag_index(markdown)
|
||||||
|
|
||||||
@ -79,6 +93,10 @@ class TagsPlugin(BasePlugin[TagsPluginConfig]):
|
|||||||
|
|
||||||
# Inject tags into page (after search and before minification)
|
# Inject tags into page (after search and before minification)
|
||||||
def on_page_context(self, context, page, config, nav):
|
def on_page_context(self, context, page, config, nav):
|
||||||
|
if not self.config.enabled:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Provide tags for page
|
||||||
if "tags" in page.meta:
|
if "tags" in page.meta:
|
||||||
context["tags"] = [
|
context["tags"] = [
|
||||||
self._render_tag(tag)
|
self._render_tag(tag)
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
# IN THE SOFTWARE.
|
# IN THE SOFTWARE.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
@ -36,6 +35,9 @@ from mkdocs.plugins import BasePlugin
|
|||||||
|
|
||||||
# Tags plugin configuration scheme
|
# Tags plugin configuration scheme
|
||||||
class TagsPluginConfig(Config):
|
class TagsPluginConfig(Config):
|
||||||
|
enabled = opt.Type(bool, default = True)
|
||||||
|
|
||||||
|
# Options for tags
|
||||||
tags_file = opt.Optional(opt.Type(str))
|
tags_file = opt.Optional(opt.Type(str))
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
@ -46,6 +48,10 @@ class TagsPlugin(BasePlugin[TagsPluginConfig]):
|
|||||||
|
|
||||||
# Initialize plugin
|
# Initialize plugin
|
||||||
def on_config(self, config):
|
def on_config(self, config):
|
||||||
|
if not self.config.enabled:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Initialize tags
|
||||||
self.tags = defaultdict(list)
|
self.tags = defaultdict(list)
|
||||||
self.tags_file = None
|
self.tags_file = None
|
||||||
|
|
||||||
@ -64,12 +70,20 @@ class TagsPlugin(BasePlugin[TagsPluginConfig]):
|
|||||||
|
|
||||||
# Hack: 2nd pass for tags index page(s)
|
# Hack: 2nd pass for tags index page(s)
|
||||||
def on_nav(self, nav, config, files):
|
def on_nav(self, nav, config, files):
|
||||||
|
if not self.config.enabled:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Resolve tags index page
|
||||||
file = self.config.tags_file
|
file = self.config.tags_file
|
||||||
if file:
|
if file:
|
||||||
self.tags_file = self._get_tags_file(files, file)
|
self.tags_file = self._get_tags_file(files, file)
|
||||||
|
|
||||||
# Build and render tags index page
|
# Build and render tags index page
|
||||||
def on_page_markdown(self, markdown, page, config, files):
|
def on_page_markdown(self, markdown, page, config, files):
|
||||||
|
if not self.config.enabled:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Render tags index page
|
||||||
if page.file == self.tags_file:
|
if page.file == self.tags_file:
|
||||||
return self._render_tag_index(markdown)
|
return self._render_tag_index(markdown)
|
||||||
|
|
||||||
@ -79,6 +93,10 @@ class TagsPlugin(BasePlugin[TagsPluginConfig]):
|
|||||||
|
|
||||||
# Inject tags into page (after search and before minification)
|
# Inject tags into page (after search and before minification)
|
||||||
def on_page_context(self, context, page, config, nav):
|
def on_page_context(self, context, page, config, nav):
|
||||||
|
if not self.config.enabled:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Provide tags for page
|
||||||
if "tags" in page.meta:
|
if "tags" in page.meta:
|
||||||
context["tags"] = [
|
context["tags"] = [
|
||||||
self._render_tag(tag)
|
self._render_tag(tag)
|
||||||
|
Loading…
Reference in New Issue
Block a user