feat: add exclude_extensions plugin parameter
This commit is contained in:
parent
d0904e40cb
commit
e84dee4757
@ -14,6 +14,7 @@ from mkdocs import utils
|
|||||||
from mkdocs.config import config_options
|
from mkdocs.config import config_options
|
||||||
from mkdocs_simple_plugin.plugin import SimplePlugin, StreamExtract
|
from mkdocs_simple_plugin.plugin import SimplePlugin, StreamExtract
|
||||||
|
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
@ -136,6 +137,12 @@ terminate: '^\s*\)'
|
|||||||
config_scheme = (
|
config_scheme = (
|
||||||
# Note documentation of each new parameter **follows** the parameter.
|
# Note documentation of each new parameter **follows** the parameter.
|
||||||
*altered_config_scheme,
|
*altered_config_scheme,
|
||||||
|
('exclude_extensions',
|
||||||
|
config_options.Type(list, default=['.o'])),
|
||||||
|
# Files whose name contains a string in this list will not be processed
|
||||||
|
# by `semiliterate`, regardless of whether they might match
|
||||||
|
# `include_extensions`, the `semiliterate` patterns, or standard
|
||||||
|
# Markdown.
|
||||||
('copy_standard_markdown',
|
('copy_standard_markdown',
|
||||||
config_options.Type(bool, default=False)),
|
config_options.Type(bool, default=False)),
|
||||||
# Whether to add MkDocs' list of standard Markdown extensions to the
|
# Whether to add MkDocs' list of standard Markdown extensions to the
|
||||||
@ -168,6 +175,7 @@ terminate: '^\s*\)'
|
|||||||
if self.config['report_docs_build']:
|
if self.config['report_docs_build']:
|
||||||
utils.log.info(
|
utils.log.info(
|
||||||
f"semiliterate: generating docs in {self.build_docs_dir}")
|
f"semiliterate: generating docs in {self.build_docs_dir}")
|
||||||
|
self.exclude_extensions = self.config['exclude_extensions']
|
||||||
dflt_enable = False
|
dflt_enable = False
|
||||||
if not self.config['copy_standard_markdown']:
|
if not self.config['copy_standard_markdown']:
|
||||||
self.include_extensions = self.config['include_extensions']
|
self.include_extensions = self.config['include_extensions']
|
||||||
@ -178,7 +186,18 @@ terminate: '^\s*\)'
|
|||||||
pattern=re.compile(f"^(.*(?:{ext_pat}))$"),
|
pattern=re.compile(f"^(.*(?:{ext_pat}))$"),
|
||||||
destination=r'\1',
|
destination=r'\1',
|
||||||
**self.config['extract_standard_markdown']))
|
**self.config['extract_standard_markdown']))
|
||||||
return super().build_docs()
|
paths = []
|
||||||
|
for root, directories, files in os.walk("."):
|
||||||
|
if self.in_include_directory(root):
|
||||||
|
document_root = self.build_docs_dir + root[1:]
|
||||||
|
for f in files:
|
||||||
|
if any(ext in f for ext in self.exclude_extensions):
|
||||||
|
continue
|
||||||
|
paths.extend(self.copy_file(root, f, document_root))
|
||||||
|
paths.extend(self.extract_from(root, f, document_root))
|
||||||
|
directories[:] = [d for d in directories
|
||||||
|
if self.in_search_directory(d, root)]
|
||||||
|
return paths
|
||||||
|
|
||||||
def try_extraction(self, original_file, root, new_file, **kwargs):
|
def try_extraction(self, original_file, root, new_file, **kwargs):
|
||||||
extraction = StreamInclusion(
|
extraction = StreamInclusion(
|
||||||
|
Loading…
Reference in New Issue
Block a user