feat: add exclude_extensions plugin parameter
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Glen Whitney 2021-01-28 16:20:06 -08:00
parent d0904e40cb
commit e84dee4757
2 changed files with 21 additions and 2 deletions

View File

@ -14,6 +14,7 @@ from mkdocs import utils
from mkdocs.config import config_options
from mkdocs_simple_plugin.plugin import SimplePlugin, StreamExtract
import os
import re
import yaml
@ -136,6 +137,12 @@ terminate: '^\s*\)'
config_scheme = (
# Note documentation of each new parameter **follows** the parameter.
*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',
config_options.Type(bool, default=False)),
# Whether to add MkDocs' list of standard Markdown extensions to the
@ -168,6 +175,7 @@ terminate: '^\s*\)'
if self.config['report_docs_build']:
utils.log.info(
f"semiliterate: generating docs in {self.build_docs_dir}")
self.exclude_extensions = self.config['exclude_extensions']
dflt_enable = False
if not self.config['copy_standard_markdown']:
self.include_extensions = self.config['include_extensions']
@ -178,7 +186,18 @@ terminate: '^\s*\)'
pattern=re.compile(f"^(.*(?:{ext_pat}))$"),
destination=r'\1',
**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):
extraction = StreamInclusion(

View File

@ -1,6 +1,6 @@
[metadata]
name = mkdocs-semiliterate
version = 0.0.11
version = 0.0.12
[options]
packages = mkdocs_semiliterate