A mkdocs plugin that excludes assets that are unused (orphaned) from being included in the final mkdocs output.
Project description
MkDocs Exclude Unused (orphaned) Files
A simple plugin for excluding files from being included in the mkdocs output if they are not referenced on other pages.
Installation
Run pip install --upgrade mkdocs-exclude-unused-files
Configuration
Basic Configuration in the mkdocs.yml
file:
plugins:
- exclude-unused-files:
file_types_to_check: ["png", "jpg", "jpeg", "gif"]
enabled: !ENV [CI, false]
This configuration will exclude all files from the final mkdocs output that has one of the configured file endings and are not referenced/linked to other pages.
Default types
The plugin uses a default set of file types:
png, jpg, jpeg, gif, pdf, ico, drawio, tif, tiff, zip, tar.gz, rar, ogg, mp3, mp4, vtt , ogv, mov, svg, pot, potx, ppsx, ppt, pptx, xlt, xltx, xls, xlsx, doc, docx, dot, dotx, vst, vstx, vsd, vsdx
All Configuration Options
Setting | Default | Description |
---|---|---|
enabled | True |
Whether the plugin is enabled when building your project. If you want to switch the plugin off, e.g. for local builds, use an environment variables. |
enabled_on_serve | False |
Whether the plugin is enabled when serving your project. It does not apply if enabled is False. It's just to explicitly enable the plugin during mkdocs serve. |
dry_run | False |
Only print output into the command line and don't actually delete anything |
silent | False |
Don't print out the found orphan files in the build process |
force_delete | False |
By default the plugin only deletes files that are actually in the configured mkdocs output directory (site_dir). If you want to delete these files anyways due to your setup, enable this flag |
file_types_to_check | [] |
Only check these file types for their usage and delete them if necessary. |
file_types_override_mode | replace |
Behavior of file_types_to_check towards default types: replace - uses only defined types, append - adds additional types to default list, remove - removes specified types from default. |
file_names_to_never_remove | ["favicon"] |
Files with these names will never get deleted, even if no usage is detected. |
folders_to_never_remove_from | ["assets"] |
Files in these folders will never get deleted, even if no usage is detected. Useful for always including specific static files. |
file_name_suffixes_to_trim | ["#only-light", "#only-dark"] |
Trim-away suffixes in this list when checking if a file-name is used. This is used for ignoring material-mkdoc's color-palette-toggle instructions (see Issue-4). |
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mkdocs_exclude_unused_files-1.4.0.tar.gz
.
File metadata
- Download URL: mkdocs_exclude_unused_files-1.4.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f22ba540f5c184f3e874a0b85fb3987dcea985bb3e3fb2a21b48364486adeec |
|
MD5 | 90bccdf5d903b009c4d23a2269411bb9 |
|
BLAKE2b-256 | af0555be1d8d6f1504d65e129dab0c7230ae4aaa29c8af46959d92dad69defe1 |
File details
Details for the file mkdocs_exclude_unused_files-1.4.0-py3-none-any.whl
.
File metadata
- Download URL: mkdocs_exclude_unused_files-1.4.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 975486b65e9b8f1bb51c89b1c1dabbbbe23e339a5fae5aa29a7a588b2d40a382 |
|
MD5 | 07a2b2b792b00ed1f95132127dd79657 |
|
BLAKE2b-256 | 687e595615ddb4431d333822ea9ac3e8ccfdd33d02a1eda0b07c435cda54ab04 |