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

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.0.tar.gz (6.6 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.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

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

Hashes for mkdocs_lex_plugin-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d5847e09971a8a5890f68406f498b88c8f2beb6bdb9561aa267e16ee2cc3c313
MD5 300d965cc2ff247a1c1cfc973b949ba7
BLAKE2b-256 f2670e576c9f6d93ebdee74d8d0d920f6c5f71fa726e0ba019fd78c6f9267d7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mkdocs_lex_plugin-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6055f6f77095c858bc0c7ebe264c5e51042dea8e1e9d2c5e76728cc6899b927b
MD5 903ab62d09fd287274b5b2b09a5c4d03
BLAKE2b-256 fe51210c7e59d2fda5c0ce94b8ca4476ecd3145f2ba0be0c756905ddb42d90de

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