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 requires the lexd CLI tool to be installed and available in your PATH.

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

You can configure the plugin to automatically download the lexd CLI if it is not found on the host machine. This is extremely useful for CI/CD pipelines (like GitHub Actions) so you don't have to manually install the Rust binary.

plugins:
  - search
  - lex:
      download_if_missing: true

If set to true, the plugin will query the GitHub API for the latest lex-fmt/lex release, automatically detect your operating system and architecture, download the appropriate binary, and cache it locally in a .mkdocs_lex_cache/ directory.

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.1.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.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mkdocs_lex_plugin-0.1.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.1.0.tar.gz
Algorithm Hash digest
SHA256 d58409ea902192177edcea084973763088bd6ffc306edc6d5f4842ae0945c91a
MD5 7d828036b5dbbe845caa03b0d4ccf6aa
BLAKE2b-256 cdfd164b132e32d5697f3cd80b22550cc634fd403cf9764d24cfa1867fc98e24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mkdocs_lex_plugin-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d39d2042bde15f829979b49c3e0eaf569af387adfdd225de85b4dd8ff9afba3
MD5 a4c026f92340de20865d05e70f436d79
BLAKE2b-256 281b042557d9bb5379f84dc0357b55a11f07f49399fb00cc21317451bf25f0da

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