Skip to main content

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 lexd CLI to convert your .lex files. By default it will download the right binary for your platform from the latest lex-fmt/lex release on first run and cache it under .mkdocs_lex_cache/ — no manual install needed. If you already have lexd on your PATH, 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

Deployment

To publish a mkdocs-lex site:

Full overview and trade-offs: docs/deployment/.

Development Setup

If you want to contribute or test this plugin locally:

  1. Clone the repository: git clone https://github.com/lex-fmt/mkdocs-lex
  2. Run the development setup script: bash scripts/setup-dev-env.sh
  3. Activate the virtual environment: source .venv/bin/activate
  4. Run integration tests: pytest tests/

How it works

MkDocs is fundamentally a Markdown engine. This plugin integrates cleanly by:

  1. Identifying .lex files in your docs/ folder.
  2. Tricking MkDocs' internal engine into believing they are .md pages.
  3. Intercepting the file-read hook (on_page_read_source) to perform a just-in-time conversion of Lex to Markdown using the lexd convert capability.

This means no temporary .md files clutter your repo, and live-reloading (mkdocs serve) works natively when you edit a .lex file!

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

mkdocs_lex_plugin-0.2.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocs_lex_plugin-0.2.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_lex_plugin-0.2.1.tar.gz.

File metadata

  • Download URL: mkdocs_lex_plugin-0.2.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mkdocs_lex_plugin-0.2.1.tar.gz
Algorithm Hash digest
SHA256 6b800b9eaf54ced57cead1c74d57fd546044e75ba278babf64510f69a3be34f6
MD5 0bc25f93db179670bff5088cd41f4230
BLAKE2b-256 c63d6f2db386d46c211a98c5e55e359dee2e591c9139a0a45970da999d01e7ae

See more details on using hashes here.

File details

Details for the file mkdocs_lex_plugin-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: mkdocs_lex_plugin-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mkdocs_lex_plugin-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dd452470957925048ee187aab4cac78d81663dd2600b3c5093bb6d1c115c24cc
MD5 c73f0995c9fe39f87de82091cdacce4f
BLAKE2b-256 f907cf62f781dbd2a26564224dbccce4827da743aa97c265c734840f389ac298

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page