Skip to main content

File filter plugin for mkdocs

select-files is a mkdocs plugin that filters out files (pages) using a parametrized regular expression.

The main use case for this plugin is to prepare lectures or assignments and only publishing them at a given date.

Quick start

  1. Install the module using pip: pip3 install mkdocs-select-files

  2. In your project, add a plugin configuration to mkdocs.yml:

    plugins:
      - select-files:
       select: '^s(\d+)'
       where: 'lambda x : int(x) <= 5'
    

This would search for files named sNN... and select only those where NN is less than or equal to 5.

In the where expression, you can use the following declared variables

  • now : represent the current time in ISO format
  • sfc : The value of the SELECT_FILE_CONDITION environment variable.

The modules os and datetime are imported, so you can use methods from them.

Disabling the plugin

You can disable the plugin using an environment variable. For example, you could configure your site this way:

plugins:
  - select-files:
  select: '^s(\d+)'
  where: 'lambda x : int(x) <= 5'
  disabled_if_env: SELECT_FILES_DISABLED

and then, running mkdocs with SELECT_FILES_DISABLED set to 1 would disable this plugin and let all pages be processed:

SELECT_FILES_DISABLED=1 mkdocs ...

Credits

Thank you to Lucy Linder for her great idea of using parametrized regular expressions.

Similar plugins

  • mkdocs-exclude : exclude arbitrary file paths and patterns from the input

Metadata

Release files for mkdocs-select-files 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkdocs-select-files 0.4.0
File Size Uploaded
mkdocs-select-files-0.4.0.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-select-files 0.4.0
File Interpreter ABI Platform
mkdocs_select_files-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.2 kB

Release files / mkdocs-select-files-0.4.0.tar.gz

Download URL mkdocs-select-files-0.4.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
cfb08a02cd47227dc7fb26ce7cb5d586c26262a0782c93977d142184743f74c1
BLAKE2b-256 checksum
How to use checksums
7441c70ba895af7bd7066e37b31c182048faa34de9f403d10fd6bbb47163a161
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

Release files / mkdocs_select_files-0.4.0-py3-none-any.whl

Download URL mkdocs_select_files-0.4.0-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e2f187ab0d5d3bf79b3020e0ae633865a357462883d4667978cb6b6bce58e3a
BLAKE2b-256 checksum
How to use checksums
b6d4f9a022275712b24059b11634f0b8b540727e63030d848006eeece4609345
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.6

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page