mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-07-24 23:04:32 -04:00
Restructured documentation (#5692)
This commit is contained in:
@@ -80,6 +80,10 @@ class InfoPlugin(BasePlugin[InfoConfig]):
|
||||
log.error("Please upgrade to the latest version.")
|
||||
self._help_on_versions_and_exit(present, current)
|
||||
|
||||
# Exit if archive creation is disabled
|
||||
if not self.config.archive:
|
||||
sys.exit(1)
|
||||
|
||||
# Print message that we're creating a bug report
|
||||
log.info("Started archive creation for bug report")
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ pipeline = ("stemmer", "stopWordFilter", "trimmer")
|
||||
|
||||
# Search plugin configuration
|
||||
class SearchConfig(Config):
|
||||
enabled = Type(bool, default = True)
|
||||
|
||||
# Settings for search
|
||||
lang = Optional(LangOption())
|
||||
separator = Optional(Type(str))
|
||||
pipeline = ListOfItems(Choice(pipeline), default = [])
|
||||
|
||||
@@ -58,6 +58,10 @@ class SearchPlugin(BasePlugin[SearchConfig]):
|
||||
|
||||
# Initialize plugin
|
||||
def on_config(self, config):
|
||||
if not self.config.enabled:
|
||||
return
|
||||
|
||||
# Retrieve default value for language
|
||||
if not self.config.lang:
|
||||
self.config.lang = [self._translate(
|
||||
config, "search.config.lang"
|
||||
@@ -104,6 +108,10 @@ class SearchPlugin(BasePlugin[SearchConfig]):
|
||||
|
||||
# Add page to search index
|
||||
def on_page_context(self, context, *, page, config, nav):
|
||||
if not self.config.enabled:
|
||||
return
|
||||
|
||||
# Index page
|
||||
self.search_index.add_entry_from_context(page)
|
||||
page.content = re.sub(
|
||||
r"\s?data-search-\w+=\"[^\"]+\"",
|
||||
@@ -113,6 +121,10 @@ class SearchPlugin(BasePlugin[SearchConfig]):
|
||||
|
||||
# Generate search index
|
||||
def on_post_build(self, *, config):
|
||||
if not self.config.enabled:
|
||||
return
|
||||
|
||||
# Write search index
|
||||
base = os.path.join(config.site_dir, "search")
|
||||
path = os.path.join(base, "search_index.json")
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ class SocialPlugin(BasePlugin[SocialConfig]):
|
||||
if "Image" not in globals():
|
||||
raise PluginError(
|
||||
"Required dependencies of \"social\" plugin not found. "
|
||||
"Install with: pip install pillow cairosvg"
|
||||
"Install with: pip install \"mkdocs-material[imaging]\""
|
||||
)
|
||||
|
||||
# Move color options
|
||||
|
||||
Reference in New Issue
Block a user