feat: Add extract_on_copy
option
Previously, mkdocs_semiliterate would always attempt to extract documentation from a file, even if it matched the `include_extensions` pattern for files to be copied to the documentation site verbatim. Now, by default, such files are not considered candidates for extraction, even if they match a semiliterate pattern. Adds a configuration option `extract_on_copy` which can be set to `true` to restore the prior behavior. Also adds tests for the behavior with and without `extract_on_copy` and makes all `mkdocs build` commands in the tests strict, which they always should have been. Resolves #17.
This commit is contained in:
parent
06cce2edc3
commit
9d75fefb81
27 changed files with 1285 additions and 8 deletions
|
@ -320,7 +320,7 @@ terminate: '^\s*\)'
|
|||
# `semiliterate` still incorporates all standard Markdown files
|
||||
# because of the following `extract_standard_markdown` parameter.
|
||||
('extract_standard_markdown',
|
||||
config_options.Type(dict, default={}))
|
||||
config_options.Type(dict, default={})),
|
||||
# If the `enable` key of this dict parameter is true
|
||||
# (it defaults to the opposite of `copy_standard_markdown`),
|
||||
# it adds a semiliterate block causing extraction (and hence
|
||||
|
@ -333,6 +333,10 @@ terminate: '^\s*\)'
|
|||
# (which is also the default when `copy_standard_markdown` is true)
|
||||
# will prevent automatic extraction (and hence disable
|
||||
# inclusion-directive processing) from standard Markdown files.
|
||||
('extract_on_copy',
|
||||
config_options.Type(bool, default=False)),
|
||||
# Whether to also attempt extraction from a file that is copied
|
||||
# verbatim (because of matching the `include_extensions`).
|
||||
)
|
||||
|
||||
def on_config(self, config, **kwargs):
|
||||
|
@ -365,6 +369,8 @@ terminate: '^\s*\)'
|
|||
def extract_from(self, from_directory, name, to_directory):
|
||||
if any(ext in name for ext in self.exclude_extensions):
|
||||
return False
|
||||
if not self.config['extract_on_copy'] and self.in_extensions(name):
|
||||
return False
|
||||
return super().extract_from(from_directory, name, to_directory)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue