From 29bbae2ffec7b7d2a8262f745329475f13f5bbb6 Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Sat, 1 Oct 2022 17:26:09 -0400 Subject: [PATCH] test: Extend the custom extraction test (#405) Adds a portion of mkdocs-test.yml from the source of mkdocs-semiliterate, in an effort to help ensure that future revisions of mkdocs-simple-plugin will support the features used in the mkdocs-semiliterate derivative of this plugin. --- examples/ok-mkdocs-custom-extract/drone.yml | 32 +++++++++++++++++++ .../drone_develop.grepout | 10 ++++++ .../ok-mkdocs-custom-extract/mkdocs-test.yml | 12 +++++++ tests/integration_test.bats | 4 ++- 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 examples/ok-mkdocs-custom-extract/drone.yml create mode 100644 examples/ok-mkdocs-custom-extract/drone_develop.grepout diff --git a/examples/ok-mkdocs-custom-extract/drone.yml b/examples/ok-mkdocs-custom-extract/drone.yml new file mode 100644 index 00000000..6219dbd5 --- /dev/null +++ b/examples/ok-mkdocs-custom-extract/drone.yml @@ -0,0 +1,32 @@ +--- +### develop +# ## Developing +# +# You can clone the repository with +# ``` +# git clone https://this_is_a_dummy_url +# ``` +### +kind: pipeline +name: bootstrap +steps: + - name: fetch tags + image: alpine/git + commands: + - git fetch --tags + + - name: build_install_test + image: python + commands: + - python --version + - pwd + - pip install flake8 +### develop +# You can build the distribution with +# ``` + - pip install build + - python -m build . +# ``` +# That will produce a `.whl` file in the `dist` subdirectory. +### + - flake8 --max-line-length=80 --extend-exclude=build diff --git a/examples/ok-mkdocs-custom-extract/drone_develop.grepout b/examples/ok-mkdocs-custom-extract/drone_develop.grepout new file mode 100644 index 00000000..6867cfc0 --- /dev/null +++ b/examples/ok-mkdocs-custom-extract/drone_develop.grepout @@ -0,0 +1,10 @@ +

Developing

+

+

You can clone the repository with

+
git clone https://this_is_a_dummy_url
+
+

You can build the distribution with

+
 pip install build
+ python -m build .
+
+

That will produce a .whl file in the dist subdirectory.

diff --git a/examples/ok-mkdocs-custom-extract/mkdocs-test.yml b/examples/ok-mkdocs-custom-extract/mkdocs-test.yml index 56790d12..6eedd531 100644 --- a/examples/ok-mkdocs-custom-extract/mkdocs-test.yml +++ b/examples/ok-mkdocs-custom-extract/mkdocs-test.yml @@ -4,6 +4,12 @@ # everything from the beginning of the file to the first line of code # (a line indented by at least four spaces), together with any later Markdown # block preceded by a comment containing `# DOCPAGE`. +# +# Similarly, you may want to have to have a custom extraction even for a +# standard file pattern, or for one particular file; the `drone.yml` pattern +# could for example extract development documentation from a Drone yml file. +# Note this latter pattern takes advantage of the fact that you can have just +# a single top-level block of parameters in an `extract:` section. site_name: ok-mkdocs-custom-extract plugins: - simple: @@ -12,3 +18,9 @@ plugins: extract: - {stop: '^\s{4,}\S'} # No start, so active from beginning - {start: '# DOCPAGE', stop: '^\s{4,}\S'} + - pattern: 'drone.yml' + destination: 'drone_develop.md' + extract: + start: '### develop' + stop: '^\s*###' + replace: ['^# (.*\s*)$', '^\s*-(.*\s*)$'] diff --git a/tests/integration_test.bats b/tests/integration_test.bats index 2e5684f5..acf620b9 100755 --- a/tests/integration_test.bats +++ b/tests/integration_test.bats @@ -176,6 +176,8 @@ teardown() { assertValidSite assertFileExists site/fibo/index.html assertParGrep fibo + assertFileExists site/drone_develop/index.html + assertParGrep drone_develop } @test "ignore site directory" { @@ -237,7 +239,7 @@ teardown() { assertParGrep module } -@test "build a site with iniline settings" { +@test "build a site with inline settings" { cd ${fixturesDir}/ok-mkdocs-inline-settings assertGen assertValidSite