Skip to main content

MkDocs plugin to generate an /llms.txt file.

Project description

mkdocs-llmstxt

ci documentation pypi version gitter

MkDocs plugin to generate an /llms.txt file.

/llms.txt - A proposal to standardise on using an /llms.txt file to provide information to help LLMs use a website at inference time.

See our own dynamically generated /llms.txt as a demonstration.

Installation

pip install mkdocs-llmstxt

Usage

Enable the plugin in mkdocs.yml:

site_name: My project
site_description: Description of my project.
site_url: https://myproject.com/  # Required for the llmstxt plugin to work.

plugins:
- llmstxt:
    markdown_description: Long description of my project.
    sections:
      Usage documentation:
      - file1.md: Description of file1
      - file2.md  # Descriptions are optional.

The resulting /llms.txt file will be available at the root of your documentation. With the previous example, it will be accessible at https://myproject.com/llms.txt and will contain the following:

# My project

> Description of my project.

Long description of my project.

## Usage documentation

- [File1 title](https://myproject.com/file1.md): Description of file1
- [File2 title](https://myproject.com/file2.md)

Each source file included in sections will have its own Markdown file available at the specified URL in the /llms.txt. See Markdown generation for more details.

File globbing is supported:

plugins:
- llmstxt:
    sections:
      Usage documentation:
      - index.md: Main documentation page
      - usage/*.md

Full output

Although not explicitly written out in the https://llmstxt.org/ guidelines, it is common to output a llms-full.txt file with every page content expanded. This file can be generated by setting the full_output configuration value:

plugins:
- llmstxt:
    full_output: llms-full.txt
    sections:
      Usage documentation:
      - index.md
      - usage/*.md

Markdown generation

To generate a Markdown page from a source file, the plugin will:

Doing so is necessary to ensure that dynamically generated contents (API documentation, executed code blocks, snippets from other files, Jinja macros, etc.) are part of the generated text files.

Credits to Petyo Ivanov for the original idea ✨.

You can disable auto-cleaning of the HTML:

plugins:
- llmstxt:
    autoclean: false

You can also pre-process the HTML before it is converted back to Markdown:

plugins:
- llmstxt:
    preprocess: path/to/script.py

The specified script.py must expose a preprocess function that accepts the soup and output arguments:

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from bs4 import BeautifulSoup

def preprocess(soup: BeautifulSoup, output: str) -> None:
    ...  # modify the soup

The output argument lets you modify the soup depending on which file is being generated.

Have a look at our own cleaning function to get inspiration.

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_llmstxt-0.3.2.tar.gz (31.5 kB view details)

Uploaded Source

Built Distribution

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

mkdocs_llmstxt-0.3.2-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_llmstxt-0.3.2.tar.gz.

File metadata

  • Download URL: mkdocs_llmstxt-0.3.2.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.6

File hashes

Hashes for mkdocs_llmstxt-0.3.2.tar.gz
Algorithm Hash digest
SHA256 dd63acb8257fca3244058fd820acd4700c1626dbe48ad3a1a2cc9c599f8e4b7f
MD5 c8404bb62a8c73843bf283adf29a5a53
BLAKE2b-256 af97f96355dd47223527fff7a3dba220167a71ea5c31259ebde15314fb9b874a

See more details on using hashes here.

File details

Details for the file mkdocs_llmstxt-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: mkdocs_llmstxt-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.6

File hashes

Hashes for mkdocs_llmstxt-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fb363205d6f1452411dc5069f62012cb6b29e1788f6db9cc17793bdca7eabea8
MD5 50c2bbbd9722c0c5458b44367d2a82ad
BLAKE2b-256 1e54ed2319b98349352633b5f9797afe03c45c489422e87584a0283e2f2cc126

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