diff --git a/.gitignore b/.gitignore index e82ff19..46513b7 100644 --- a/.gitignore +++ b/.gitignore @@ -33,7 +33,6 @@ MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest *.spec # Installer logs diff --git a/mkdocs.yml b/mkdocs.yml index 2330344..a3d5a0a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -10,9 +10,10 @@ plugins: merge_docs_dir: false ignore_folders: [build, dist, tests] include_extensions: [LICENSE] - semiliterate: - - pattern: '(\.md)$' + report_docs_build: true + extract_standard_markdown: replace: [['^(.*).*(.*\s*)$', '\1\2\3']] + semiliterate: - pattern: '(\.py)$' start: '"""\smd' stop: '"""' diff --git a/mkdocs_semiliterate/plugin.py b/mkdocs_semiliterate/plugin.py index f1079d0..9eb0d4a 100644 --- a/mkdocs_semiliterate/plugin.py +++ b/mkdocs_semiliterate/plugin.py @@ -127,28 +127,54 @@ default values in parentheses at the beginning of each entry. start: '[*]SimplePlugin.config_scheme' terminate: '^\s*\)' replace: - - ['\(.(.*)., config_options.Type\(.*, default=(.*)\)\)', '\1\n: (\2)'] + - ["\\('(.*)',\\s*$", '\1\n'] + - ['config_options.Type.*?default=([^\)]*)', ': (\1)'] - '^\s*#(.*\s*)$' !} - -extract_standard_markdown -: (true) To be implemented and documented """ config_scheme = ( + # Note documentation of each new parameter **follows** the parameter. *SimplePlugin.config_scheme, - ('copy_standard_markdown', config_options.Type(bool, default=False)) + ('copy_standard_markdown', + config_options.Type(bool, default=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. + # because of the following `extract_standard_markdown` parameter. + ('extract_standard_markdown', + config_options.Type(dict, default={})), + # If the `enable` key of this dict parameter is true + # (which it defaults to), + # it adds a semiliterate block causing extraction (and hence + # include-directive processing) from all standard Markdown files + # (as defined by MkDocs). The remaining keys of this parameter are + # included as parameters of that semiliterate block. Thus, the + # default value of the parameter arranges for Markdown file to be + # copied "as-is", except possibly for embedded inclusions. + # On the other hand, setting it to `{enable: false}` will prevent + # automatic extraction from standard Markdown files. + ('report_docs_build', + config_options.Type(bool, default=False)) + # If true, the name of the temporary directory to which generated docs + # files are copied/extracted will be written to standard output + # (even if the `-v` verbose option to mkdocs is not specified). ) def build_docs(self): + if self.config['report_docs_build']: + utils.log.info( + f"semiliterate: generating docs in {self.build_docs_dir}") if not self.config['copy_standard_markdown']: self.include_extensions = self.config['include_extensions'] + if self.config['extract_standard_markdown'].get('enable', True): + ext_pat = '|'.join(re.escape(s) for s in utils.markdown_extensions) + self.semiliterate.append(dict( + pattern=re.compile(f"^(.*(?:{ext_pat}))$"), + destination=r'\1', + **self.config['extract_standard_markdown'])) return super().build_docs() # FIXME: This method is copied from simple, just to insert a control diff --git a/setup.cfg b/setup.cfg index 665b8c7..c9da074 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = mkdocs-semiliterate -version = 0.0.7 +version = 0.0.8 [options] packages = mkdocs_semiliterate diff --git a/tests/bootstrap.manifest b/tests/bootstrap.manifest new file mode 100644 index 0000000..77da37a --- /dev/null +++ b/tests/bootstrap.manifest @@ -0,0 +1,18 @@ +site +site/404.html +site/css +site/css/theme.css +site/css/theme_extra.css +site/drone_develop +site/drone_develop/index.html +site/drone_install +site/drone_install/index.html +site/index.html +site/LICENSE +site/mkdocs_semiliterate +site/mkdocs_semiliterate/plugin +site/mkdocs_semiliterate/plugin/index.html +site/search +site/search.html +site/sitemap.xml +site/sitemap.xml.gz