From cf4d538fd09e7a471f92847820639f4a3faadf3a Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Fri, 8 Jan 2021 10:40:06 -0800 Subject: [PATCH] feat: Add copy_standard_markdown parameter to plugin This parameter controls whether the standard markdown extensions will be added to the include_extensions or not. Resolves #1. --- mkdocs.yml | 13 +++++++++---- mkdocs_semiliterate/plugin.py | 35 ++++++++++++++++++++++++++++++++--- setup.cfg | 2 +- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index f322ab0..7b1e9df 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -6,13 +6,18 @@ plugins: - search - semiliterate: merge_docs_dir: false - ignore_folders: [dist] + ignore_folders: [dist, build] include_extensions: [LICENSE] -# semiliterate: -# - pattern: '(\.md)$' -# replace: [['^(.*).*(.*\s*)$', '\1\2\3']] + semiliterate: + - pattern: '(\.md)$' + start: '^(.*\s*)' + replace: [['^(.*).*(.*\s*)$', '\1\2\3']] + - pattern: '(\.py)$' + start: '"""\smd' + stop: '"""' markdown_extensions: - abbr +- def_list theme: name: readthedocs docs_dir: mkdocs_semiliterate # dummy diff --git a/mkdocs_semiliterate/plugin.py b/mkdocs_semiliterate/plugin.py index cce1b36..ce454d3 100644 --- a/mkdocs_semiliterate/plugin.py +++ b/mkdocs_semiliterate/plugin.py @@ -3,8 +3,11 @@ Once this plugin is [installed](../README.md#installation), in your `mkdocs.yml` file just replace the plugin name `simple` with `semiliterate`. It accepts all -of the same parameters as `simple`, so `mkdocs` will still work as before, and -you will have immediate access to all of the following extensions: +of the same parameters, so `mkdocs` will still work as before, and +you will have immediate access to all of the following extensions. (Note that this +documentation assumes a familiarity with the +[usage](https://athackst.github.io/mkdocs-simple-plugin/mkdocs_simple_plugin/plugin/) +of the `simple` plugin.) ### Inclusion syntax @@ -16,4 +19,30 @@ from mkdocs.config import config_options from mkdocs_simple_plugin.plugin import SimplePlugin class SemiliteratePlugin(SimplePlugin): - """ So far, just an alias for simple """ + """ md An extension of the mkdocs-simple-plugin +### Additional plugin parameters + +`semiliterate` adds a couple of new plugin parameters to further tailor its +behavior as compared to `simple`. They are described in this section, with their +default values in parentheses at the beginning of each entry. + +copy_standard_markdown +: (false) Whether to add MkDocs' list of standard Markdown extensions to the + `include_extensions` parameter so that Markdown files will be directly copied + to the docsite. Note that the `simple` behavior corresponds to a _true_ value + for `copy_standard_markdown`, but `semiliterate` still incorporates all + standard Markdown files because of the `extract_standard_markdown` default. + +extract_standard_markdown +: (true) To be implemented and documented + """ + + config_scheme = ( + *SimplePlugin.config_scheme, + ('copy_standard_markdown', config_options.Type(bool, default=False)) + ) + + def copy_doc_files(self, destination_directory): + if not self.config['copy_standard_markdown']: + self.include_extensions = self.config['include_extensions'] + return super().copy_doc_files(destination_directory) diff --git a/setup.cfg b/setup.cfg index 4f88e92..1af9286 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = mkdocs-semiliterate -version = 0.0.1 +version = 0.0.3 [options] packages = mkdocs_semiliterate