MkDocs plugin that renders .lex files natively, with no precompilation step.
Project description
mkdocs-lex
A native Lex parser and integration for MkDocs.
This plugin allows MkDocs to seamlessly parse and render .lex files as part of your documentation site. It acts as a transparent adapter—MkDocs treats your .lex files as native Markdown pages, meaning all of your favorite MkDocs features, themes, and plugins will continue to work perfectly!
[!NOTE] This plugin needs the
lexdCLI to convert your.lexfiles. By default it will download the right binary for your platform from the latestlex-fmt/lexrelease on first run and cache it under.mkdocs_lex_cache/— no manual install needed. If you already havelexdon yourPATH, it'll use that instead.
Installation
Install the package via pip:
pip install mkdocs-lex-plugin
Usage
To enable the plugin, add lex to the plugins section of your mkdocs.yml:
site_name: My Documentation
plugins:
- search
- lex
Configuration Options
| Option | Default | Description |
|---|---|---|
download_if_missing |
true |
When lexd isn't on PATH, fetch the latest matching binary from the lex-fmt/lex GitHub releases and cache it under .mkdocs_lex_cache/. Set to false to require a pre-installed lexd and error out if it's missing. |
plugins:
- search
- lex:
download_if_missing: false # require pre-installed lexd
Navigation Configuration
Because the plugin tricks MkDocs into treating your .lex files as Markdown, your mkdocs.yml navigation must point to .md extensions, even though the files on disk are .lex.
For example, if you have docs/getting-started.lex and docs/index.lex:
nav:
- Home: index.md
- Getting Started: getting-started.md
Development Setup
If you want to contribute or test this plugin locally:
- Clone the repository:
git clone https://github.com/lex-fmt/mkdocs-lex - Run the development setup script:
bash scripts/setup-dev-env.sh - Activate the virtual environment:
source .venv/bin/activate - Run integration tests:
pytest tests/
How it works
MkDocs is fundamentally a Markdown engine. This plugin integrates cleanly by:
- Identifying
.lexfiles in yourdocs/folder. - Tricking MkDocs' internal engine into believing they are
.mdpages. - Intercepting the file-read hook (
on_page_read_source) to perform a just-in-time conversion of Lex to Markdown using thelexd convertcapability.
This means no temporary .md files clutter your repo, and live-reloading (mkdocs serve) works natively when you edit a .lex file!
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs_lex_plugin-0.2.0.tar.gz.
File metadata
- Download URL: mkdocs_lex_plugin-0.2.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5847e09971a8a5890f68406f498b88c8f2beb6bdb9561aa267e16ee2cc3c313
|
|
| MD5 |
300d965cc2ff247a1c1cfc973b949ba7
|
|
| BLAKE2b-256 |
f2670e576c9f6d93ebdee74d8d0d920f6c5f71fa726e0ba019fd78c6f9267d7e
|
File details
Details for the file mkdocs_lex_plugin-0.2.0-py3-none-any.whl.
File metadata
- Download URL: mkdocs_lex_plugin-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6055f6f77095c858bc0c7ebe264c5e51042dea8e1e9d2c5e76728cc6899b927b
|
|
| MD5 |
903ab62d09fd287274b5b2b09a5c4d03
|
|
| BLAKE2b-256 |
fe51210c7e59d2fda5c0ce94b8ca4476ecd3145f2ba0be0c756905ddb42d90de
|