mkdocs-llms-source 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mkdocs_llms_source-0.1.0/.github/copilot-instructions.md +65 -0
- mkdocs_llms_source-0.1.0/.github/workflows/ci.yml +30 -0
- mkdocs_llms_source-0.1.0/.github/workflows/publish.yml +20 -0
- mkdocs_llms_source-0.1.0/.gitignore +38 -0
- mkdocs_llms_source-0.1.0/LICENSE +21 -0
- mkdocs_llms_source-0.1.0/PKG-INFO +121 -0
- mkdocs_llms_source-0.1.0/README.md +90 -0
- mkdocs_llms_source-0.1.0/agent-docs/progress.md +21 -0
- mkdocs_llms_source-0.1.0/agent-docs/todo.md +26 -0
- mkdocs_llms_source-0.1.0/docs/configuration.md +73 -0
- mkdocs_llms_source-0.1.0/docs/development.md +63 -0
- mkdocs_llms_source-0.1.0/docs/index.md +41 -0
- mkdocs_llms_source-0.1.0/docs/quickstart.md +65 -0
- mkdocs_llms_source-0.1.0/mkdocs.yml +16 -0
- mkdocs_llms_source-0.1.0/pyproject.toml +66 -0
- mkdocs_llms_source-0.1.0/src/mkdocs_llms_source/__init__.py +6 -0
- mkdocs_llms_source-0.1.0/src/mkdocs_llms_source/_version.py +34 -0
- mkdocs_llms_source-0.1.0/src/mkdocs_llms_source/plugin.py +196 -0
- mkdocs_llms_source-0.1.0/tests/__init__.py +0 -0
- mkdocs_llms_source-0.1.0/tests/conftest.py +19 -0
- mkdocs_llms_source-0.1.0/tests/fixtures/basic-site/docs/guide.md +16 -0
- mkdocs_llms_source-0.1.0/tests/fixtures/basic-site/docs/index.md +7 -0
- mkdocs_llms_source-0.1.0/tests/fixtures/basic-site/mkdocs.yml +9 -0
- mkdocs_llms_source-0.1.0/tests/test_plugin.py +183 -0
- mkdocs_llms_source-0.1.0/uv.lock +870 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Copilot Instructions for mkdocs-llms-source
|
|
2
|
+
|
|
3
|
+
## Repository Overview
|
|
4
|
+
|
|
5
|
+
This is a MkDocs plugin that generates /llms.txt files following the
|
|
6
|
+
[llmstxt.org](https://llmstxt.org/) specification. It makes MkDocs documentation
|
|
7
|
+
sites easily consumable by LLMs and AI coding tools.
|
|
8
|
+
|
|
9
|
+
## Tech Stack
|
|
10
|
+
|
|
11
|
+
- Python 3.10+, MkDocs plugin API
|
|
12
|
+
- Build: hatchling
|
|
13
|
+
- Test: pytest
|
|
14
|
+
- Lint: ruff
|
|
15
|
+
- Docs: MkDocs Material (dogfooding this plugin)
|
|
16
|
+
|
|
17
|
+
## How to Build / Test / Run
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Install in dev mode
|
|
21
|
+
uv sync --all-extras
|
|
22
|
+
|
|
23
|
+
# Run tests
|
|
24
|
+
uv run pytest
|
|
25
|
+
|
|
26
|
+
# Lint
|
|
27
|
+
uv run ruff check src/ tests/
|
|
28
|
+
|
|
29
|
+
# Build docs (dogfooding)
|
|
30
|
+
uv run mkdocs build
|
|
31
|
+
|
|
32
|
+
# Serve docs locally
|
|
33
|
+
uv run mkdocs serve
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Architecture
|
|
37
|
+
|
|
38
|
+
- `src/mkdocs_llms_source/plugin.py` — Main plugin class using MkDocs hook API
|
|
39
|
+
- Plugin hooks used: on_config, on_files, on_nav, on_page_markdown, on_post_build
|
|
40
|
+
- Source-first approach: uses original markdown, no HTML→MD conversion
|
|
41
|
+
- Auto-derives llms.txt sections from MkDocs nav config (zero-config)
|
|
42
|
+
|
|
43
|
+
## Key Design Decisions
|
|
44
|
+
|
|
45
|
+
- **Source-first**: We use the original .md source, not HTML→Markdown conversion.
|
|
46
|
+
This is simpler and more reliable. Trade-off: dynamically generated content
|
|
47
|
+
(API docs, executed code blocks) won't appear in the markdown output.
|
|
48
|
+
- **Nav-derived sections**: By default, the llms.txt H2 sections mirror the
|
|
49
|
+
MkDocs nav structure. No duplicate config needed.
|
|
50
|
+
- **Three outputs**: /llms.txt (index), /llms-full.txt (all content), per-page
|
|
51
|
+
.md files (individual pages).
|
|
52
|
+
|
|
53
|
+
## Documentation Structure
|
|
54
|
+
|
|
55
|
+
- `docs/` — Human-facing docs published via MkDocs
|
|
56
|
+
- `agent-docs/` — Agent working notes (NOT published). Check todo.md at session
|
|
57
|
+
start, update progress.md after milestones.
|
|
58
|
+
- `.github/copilot-instructions.md` — This file. Auto-loaded by Copilot.
|
|
59
|
+
|
|
60
|
+
## Common Pitfalls
|
|
61
|
+
|
|
62
|
+
- `site_url` must be set in mkdocs.yml for absolute URLs in llms.txt
|
|
63
|
+
- `use_directory_urls` affects where .md files get written in site output
|
|
64
|
+
- The plugin entry point in pyproject.toml must match the class path exactly
|
|
65
|
+
- When editing plugin.py, remember that MkDocs calls hooks in a specific order: on_config → on_files → on_nav → on_page_markdown (per page) → on_post_build
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: astral-sh/setup-uv@v5
|
|
15
|
+
- run: uvx ruff check src/ tests/
|
|
16
|
+
|
|
17
|
+
test:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
strategy:
|
|
20
|
+
matrix:
|
|
21
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
with:
|
|
25
|
+
fetch-depth: 0
|
|
26
|
+
- uses: astral-sh/setup-uv@v5
|
|
27
|
+
with:
|
|
28
|
+
python-version: ${{ matrix.python-version }}
|
|
29
|
+
- run: uv sync --all-extras
|
|
30
|
+
- run: uv run python -m pytest --cov=mkdocs_llms_source
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
id-token: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
environment: pypi
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
with:
|
|
17
|
+
fetch-depth: 0
|
|
18
|
+
- uses: astral-sh/setup-uv@v5
|
|
19
|
+
- run: uv build
|
|
20
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
*.egg
|
|
11
|
+
|
|
12
|
+
# Auto-generated version file
|
|
13
|
+
src/mkdocs_llms_source/_version.py
|
|
14
|
+
|
|
15
|
+
# Virtual environments
|
|
16
|
+
.venv/
|
|
17
|
+
venv/
|
|
18
|
+
|
|
19
|
+
# IDE
|
|
20
|
+
.idea/
|
|
21
|
+
.vscode/
|
|
22
|
+
*.swp
|
|
23
|
+
*.swo
|
|
24
|
+
|
|
25
|
+
# MkDocs build output
|
|
26
|
+
site/
|
|
27
|
+
|
|
28
|
+
# Testing
|
|
29
|
+
.coverage
|
|
30
|
+
htmlcov/
|
|
31
|
+
.pytest_cache/
|
|
32
|
+
|
|
33
|
+
# Other repos used for E2E testing
|
|
34
|
+
other_repos/
|
|
35
|
+
|
|
36
|
+
# OS
|
|
37
|
+
.DS_Store
|
|
38
|
+
Thumbs.db
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tim Child
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mkdocs-llms-source
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MkDocs plugin to generate /llms.txt files for LLM-friendly documentation
|
|
5
|
+
Project-URL: Homepage, https://github.com/TimChild/mkdocs-llms-source
|
|
6
|
+
Project-URL: Documentation, https://github.com/TimChild/mkdocs-llms-source
|
|
7
|
+
Project-URL: Repository, https://github.com/TimChild/mkdocs-llms-source
|
|
8
|
+
Project-URL: Issues, https://github.com/TimChild/mkdocs-llms-source/issues
|
|
9
|
+
Author: Tim Child
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,documentation,llms,llmstxt,mkdocs
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Documentation
|
|
22
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: mkdocs>=1.5
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: mkdocs-material>=9.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# mkdocs-llms-source
|
|
33
|
+
|
|
34
|
+
[](https://github.com/TimChild/mkdocs-llms-source/actions/workflows/ci.yml)
|
|
35
|
+
[](https://pypi.org/project/mkdocs-llms-source/)
|
|
36
|
+
[](https://pypi.org/project/mkdocs-llms-source/)
|
|
37
|
+
|
|
38
|
+
MkDocs plugin to generate [`/llms.txt`](https://llmstxt.org/) files for LLM-friendly documentation.
|
|
39
|
+
|
|
40
|
+
## What It Does
|
|
41
|
+
|
|
42
|
+
Generates three outputs from your MkDocs site:
|
|
43
|
+
|
|
44
|
+
1. **`/llms.txt`** — A curated index following the [llmstxt.org spec](https://llmstxt.org/) with links to per-page markdown files
|
|
45
|
+
2. **`/llms-full.txt`** — All documentation concatenated into a single file (for stuffing into LLM context windows)
|
|
46
|
+
3. **Per-page `.md` files** — Raw markdown accessible at the same URL path as HTML pages
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
uv add mkdocs-llms-source
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
Add to your `mkdocs.yml`:
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
site_name: My Project
|
|
60
|
+
site_url: https://docs.example.com
|
|
61
|
+
site_description: Documentation for My Project
|
|
62
|
+
|
|
63
|
+
plugins:
|
|
64
|
+
- search
|
|
65
|
+
- llms-source
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Build your site:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
mkdocs build
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The plugin auto-derives the llms.txt section structure from your MkDocs `nav` — zero extra configuration needed.
|
|
75
|
+
|
|
76
|
+
## Configuration
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
plugins:
|
|
80
|
+
- llms-source:
|
|
81
|
+
full_output: true # Generate llms-full.txt (default: true)
|
|
82
|
+
markdown_urls: true # Copy .md source files to output (default: true)
|
|
83
|
+
description: "Override description for llms.txt header"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## How It Works
|
|
87
|
+
|
|
88
|
+
**Source-first approach**: The plugin uses your original markdown source files directly — no HTML-to-Markdown conversion. This is simpler, more reliable, and preserves your intended formatting.
|
|
89
|
+
|
|
90
|
+
The llms.txt sections are automatically derived from your MkDocs `nav` configuration, so top-level nav items become H2 sections in the output.
|
|
91
|
+
|
|
92
|
+
## Example Output
|
|
93
|
+
|
|
94
|
+
Given this nav:
|
|
95
|
+
|
|
96
|
+
```yaml
|
|
97
|
+
nav:
|
|
98
|
+
- Home: index.md
|
|
99
|
+
- Guides:
|
|
100
|
+
- Getting Started: guides/setup.md
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The generated `/llms.txt`:
|
|
104
|
+
|
|
105
|
+
```markdown
|
|
106
|
+
# My Project
|
|
107
|
+
|
|
108
|
+
> Documentation for My Project
|
|
109
|
+
|
|
110
|
+
## Home
|
|
111
|
+
|
|
112
|
+
- [My Project](https://docs.example.com/index.md)
|
|
113
|
+
|
|
114
|
+
## Guides
|
|
115
|
+
|
|
116
|
+
- [Getting Started](https://docs.example.com/guides/setup.md)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# mkdocs-llms-source
|
|
2
|
+
|
|
3
|
+
[](https://github.com/TimChild/mkdocs-llms-source/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/mkdocs-llms-source/)
|
|
5
|
+
[](https://pypi.org/project/mkdocs-llms-source/)
|
|
6
|
+
|
|
7
|
+
MkDocs plugin to generate [`/llms.txt`](https://llmstxt.org/) files for LLM-friendly documentation.
|
|
8
|
+
|
|
9
|
+
## What It Does
|
|
10
|
+
|
|
11
|
+
Generates three outputs from your MkDocs site:
|
|
12
|
+
|
|
13
|
+
1. **`/llms.txt`** — A curated index following the [llmstxt.org spec](https://llmstxt.org/) with links to per-page markdown files
|
|
14
|
+
2. **`/llms-full.txt`** — All documentation concatenated into a single file (for stuffing into LLM context windows)
|
|
15
|
+
3. **Per-page `.md` files** — Raw markdown accessible at the same URL path as HTML pages
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
uv add mkdocs-llms-source
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Add to your `mkdocs.yml`:
|
|
26
|
+
|
|
27
|
+
```yaml
|
|
28
|
+
site_name: My Project
|
|
29
|
+
site_url: https://docs.example.com
|
|
30
|
+
site_description: Documentation for My Project
|
|
31
|
+
|
|
32
|
+
plugins:
|
|
33
|
+
- search
|
|
34
|
+
- llms-source
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Build your site:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
mkdocs build
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The plugin auto-derives the llms.txt section structure from your MkDocs `nav` — zero extra configuration needed.
|
|
44
|
+
|
|
45
|
+
## Configuration
|
|
46
|
+
|
|
47
|
+
```yaml
|
|
48
|
+
plugins:
|
|
49
|
+
- llms-source:
|
|
50
|
+
full_output: true # Generate llms-full.txt (default: true)
|
|
51
|
+
markdown_urls: true # Copy .md source files to output (default: true)
|
|
52
|
+
description: "Override description for llms.txt header"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## How It Works
|
|
56
|
+
|
|
57
|
+
**Source-first approach**: The plugin uses your original markdown source files directly — no HTML-to-Markdown conversion. This is simpler, more reliable, and preserves your intended formatting.
|
|
58
|
+
|
|
59
|
+
The llms.txt sections are automatically derived from your MkDocs `nav` configuration, so top-level nav items become H2 sections in the output.
|
|
60
|
+
|
|
61
|
+
## Example Output
|
|
62
|
+
|
|
63
|
+
Given this nav:
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
nav:
|
|
67
|
+
- Home: index.md
|
|
68
|
+
- Guides:
|
|
69
|
+
- Getting Started: guides/setup.md
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The generated `/llms.txt`:
|
|
73
|
+
|
|
74
|
+
```markdown
|
|
75
|
+
# My Project
|
|
76
|
+
|
|
77
|
+
> Documentation for My Project
|
|
78
|
+
|
|
79
|
+
## Home
|
|
80
|
+
|
|
81
|
+
- [My Project](https://docs.example.com/index.md)
|
|
82
|
+
|
|
83
|
+
## Guides
|
|
84
|
+
|
|
85
|
+
- [Getting Started](https://docs.example.com/guides/setup.md)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Progress
|
|
2
|
+
|
|
3
|
+
## 2026-03-22 — Initial scaffolding
|
|
4
|
+
|
|
5
|
+
- Created full project structure with pyproject.toml, src/, tests/, docs/, agent-docs/
|
|
6
|
+
- Implemented MVP plugin with all core MkDocs hooks:
|
|
7
|
+
- `on_config` — validates site_url
|
|
8
|
+
- `on_files` — tracks source files
|
|
9
|
+
- `on_nav` — walks nav tree to build section structure
|
|
10
|
+
- `on_page_markdown` — captures raw markdown per page
|
|
11
|
+
- `on_post_build` — writes llms.txt, llms-full.txt, copies .md files
|
|
12
|
+
- Wrote integration test suite covering:
|
|
13
|
+
- Basic build verification
|
|
14
|
+
- llms.txt content/structure
|
|
15
|
+
- llms-full.txt generation
|
|
16
|
+
- Per-page .md file copying
|
|
17
|
+
- Config options (full_output, markdown_urls, description)
|
|
18
|
+
- Edge cases (trailing slash, nested nav, no site_url)
|
|
19
|
+
- Created docs (index, quickstart, configuration, development)
|
|
20
|
+
- Set up CI workflows (lint+test on PR, publish on release)
|
|
21
|
+
- Created .github/copilot-instructions.md for agent context
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# TODO
|
|
2
|
+
|
|
3
|
+
## Phase 1 — MVP
|
|
4
|
+
- [x] Scaffold project structure (pyproject.toml, src/, tests/)
|
|
5
|
+
- [x] Implement basic plugin: on_config, on_files, on_nav, on_page_markdown, on_post_build
|
|
6
|
+
- [x] Auto-derive sections from MkDocs nav
|
|
7
|
+
- [x] Generate /llms.txt with proper spec format
|
|
8
|
+
- [x] Generate /llms-full.txt with all content
|
|
9
|
+
- [x] Copy per-page .md files to site output
|
|
10
|
+
- [x] Write integration tests with a fixture MkDocs site
|
|
11
|
+
- [ ] Dogfood: use plugin on its own docs site
|
|
12
|
+
- [ ] Publish v0.1.0 to PyPI
|
|
13
|
+
|
|
14
|
+
## Phase 2 — Polish
|
|
15
|
+
- [ ] Explicit `sections` config with glob support
|
|
16
|
+
- [ ] `optional` section support
|
|
17
|
+
- [ ] Handle `use_directory_urls: false`
|
|
18
|
+
- [ ] Handle missing site_url gracefully (✓ partial — logs warning, uses relative)
|
|
19
|
+
- [ ] CI workflow (lint + test on PR)
|
|
20
|
+
- [ ] Publish workflow (PyPI on release tag)
|
|
21
|
+
|
|
22
|
+
## Phase 3 — Advanced
|
|
23
|
+
- [ ] Optional HTML→Markdown fallback for generated pages (API docs, macros)
|
|
24
|
+
- [ ] Preprocessing hooks (custom transforms)
|
|
25
|
+
- [ ] `base_url` override (for versioned docs / Read the Docs)
|
|
26
|
+
- [ ] Per-page description annotations (via frontmatter)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Configuration Reference
|
|
2
|
+
|
|
3
|
+
All configuration options are set under the `llms-source` plugin in `mkdocs.yml`.
|
|
4
|
+
|
|
5
|
+
## Options
|
|
6
|
+
|
|
7
|
+
### `full_output`
|
|
8
|
+
|
|
9
|
+
- **Type**: `bool`
|
|
10
|
+
- **Default**: `true`
|
|
11
|
+
|
|
12
|
+
Generate `/llms-full.txt` containing all documentation content concatenated.
|
|
13
|
+
|
|
14
|
+
```yaml
|
|
15
|
+
plugins:
|
|
16
|
+
- llms-source:
|
|
17
|
+
full_output: false # Disable llms-full.txt generation
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### `markdown_urls`
|
|
21
|
+
|
|
22
|
+
- **Type**: `bool`
|
|
23
|
+
- **Default**: `true`
|
|
24
|
+
|
|
25
|
+
Copy source `.md` files into the site output directory, making them accessible at the same URL path as the HTML pages but with a `.md` extension.
|
|
26
|
+
|
|
27
|
+
```yaml
|
|
28
|
+
plugins:
|
|
29
|
+
- llms-source:
|
|
30
|
+
markdown_urls: false # Don't copy .md files to output
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### `description`
|
|
34
|
+
|
|
35
|
+
- **Type**: `str`
|
|
36
|
+
- **Default**: `""` (uses `site_description` from mkdocs.yml)
|
|
37
|
+
|
|
38
|
+
Override the description shown in the llms.txt blockquote header.
|
|
39
|
+
|
|
40
|
+
```yaml
|
|
41
|
+
plugins:
|
|
42
|
+
- llms-source:
|
|
43
|
+
description: "Custom description for LLM consumers"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Full Example
|
|
47
|
+
|
|
48
|
+
```yaml
|
|
49
|
+
site_name: My Project
|
|
50
|
+
site_url: https://docs.example.com
|
|
51
|
+
site_description: Documentation for My Project
|
|
52
|
+
|
|
53
|
+
plugins:
|
|
54
|
+
- search
|
|
55
|
+
- llms-source:
|
|
56
|
+
full_output: true
|
|
57
|
+
markdown_urls: true
|
|
58
|
+
description: "API and usage docs for My Project"
|
|
59
|
+
|
|
60
|
+
nav:
|
|
61
|
+
- Home: index.md
|
|
62
|
+
- Guides:
|
|
63
|
+
- Getting Started: guides/getting-started.md
|
|
64
|
+
- Advanced Usage: guides/advanced.md
|
|
65
|
+
- API Reference:
|
|
66
|
+
- Overview: api/index.md
|
|
67
|
+
- Endpoints: api/endpoints.md
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Requirements
|
|
71
|
+
|
|
72
|
+
- **`site_url`** must be set in `mkdocs.yml` for absolute URLs in `llms.txt`. Without it, the plugin falls back to relative paths and logs a warning.
|
|
73
|
+
- **`nav`** should be defined for best results. The plugin auto-derives llms.txt sections from the nav structure. Without nav, MkDocs auto-generates one from the file structure.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Development
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
Clone the repository and install in development mode:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/TimChild/mkdocs-llms-source.git
|
|
9
|
+
cd mkdocs-llms-source
|
|
10
|
+
uv sync --all-extras
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Running Tests
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pytest
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
With coverage:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pytest --cov=mkdocs_llms_source
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Linting
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
ruff check src/ tests/
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Auto-fix:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
ruff check --fix src/ tests/
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Building Docs
|
|
38
|
+
|
|
39
|
+
The project dogfoods its own plugin:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
mkdocs serve # Local dev server
|
|
43
|
+
mkdocs build # Build static site
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Project Structure
|
|
47
|
+
|
|
48
|
+
- `src/mkdocs_llms_source/plugin.py` — Main plugin implementation
|
|
49
|
+
- `tests/` — Test suite with fixtures
|
|
50
|
+
- `docs/` — Human-facing documentation (published via MkDocs)
|
|
51
|
+
- `agent-docs/` — Agent working notes (not published)
|
|
52
|
+
|
|
53
|
+
## Architecture
|
|
54
|
+
|
|
55
|
+
The plugin hooks into MkDocs' build lifecycle:
|
|
56
|
+
|
|
57
|
+
1. **`on_config`** — Validates that `site_url` is set
|
|
58
|
+
2. **`on_files`** — Tracks available source files
|
|
59
|
+
3. **`on_nav`** — Walks the nav tree to build llms.txt section structure
|
|
60
|
+
4. **`on_page_markdown`** — Captures raw markdown content for each page
|
|
61
|
+
5. **`on_post_build`** — Writes `llms.txt`, `llms-full.txt`, and copies `.md` files
|
|
62
|
+
|
|
63
|
+
Key design decision: **source-first** — we use original markdown source files, not HTML-to-Markdown conversion. This is simpler and preserves author formatting.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# mkdocs-llms-source
|
|
2
|
+
|
|
3
|
+
MkDocs plugin to generate `/llms.txt` files for LLM-friendly documentation.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
mkdocs-llms-source generates [llms.txt](https://llmstxt.org/) files from your MkDocs documentation site so that AI tools can efficiently consume your docs without parsing HTML.
|
|
8
|
+
|
|
9
|
+
The plugin produces three outputs:
|
|
10
|
+
|
|
11
|
+
1. **`/llms.txt`** — A curated index following the llmstxt.org spec with links to per-page markdown files
|
|
12
|
+
2. **`/llms-full.txt`** — All documentation concatenated into a single file
|
|
13
|
+
3. **Per-page `.md` files** — Raw markdown at the same URL path as HTML pages
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
Install the plugin:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install mkdocs-llms-source
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Add it to your `mkdocs.yml`:
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
plugins:
|
|
27
|
+
- search
|
|
28
|
+
- llms-source
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Build your site:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
mkdocs build
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
That's it! Your site will now include `/llms.txt`, `/llms-full.txt`, and per-page `.md` files.
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
See the [configuration reference](configuration.md) for all options.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Quick Start
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
uv add mkdocs-llms-source
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Basic Usage
|
|
10
|
+
|
|
11
|
+
Add the plugin to your `mkdocs.yml`:
|
|
12
|
+
|
|
13
|
+
```yaml
|
|
14
|
+
site_name: My Project
|
|
15
|
+
site_url: https://docs.example.com
|
|
16
|
+
site_description: Documentation for My Project
|
|
17
|
+
|
|
18
|
+
plugins:
|
|
19
|
+
- search
|
|
20
|
+
- llms-source
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Important**: Set `site_url` in your `mkdocs.yml` — the llms.txt spec requires absolute URLs.
|
|
24
|
+
|
|
25
|
+
Build your site as usual:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
mkdocs build
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The plugin will generate:
|
|
32
|
+
|
|
33
|
+
- `site/llms.txt` — Index file following the llmstxt.org spec
|
|
34
|
+
- `site/llms-full.txt` — All docs concatenated into one file
|
|
35
|
+
- `site/*.md` — Per-page markdown files alongside the HTML
|
|
36
|
+
|
|
37
|
+
## How It Works
|
|
38
|
+
|
|
39
|
+
The plugin uses a **source-first** approach:
|
|
40
|
+
|
|
41
|
+
1. It reads your original markdown source files (no HTML-to-Markdown conversion)
|
|
42
|
+
2. It auto-derives the llms.txt section structure from your MkDocs `nav` configuration
|
|
43
|
+
3. It generates the output files during the MkDocs build process
|
|
44
|
+
|
|
45
|
+
This means zero extra configuration is needed for most sites.
|
|
46
|
+
|
|
47
|
+
## Verify
|
|
48
|
+
|
|
49
|
+
After building, check that the files were created:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
cat site/llms.txt
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
You should see something like:
|
|
56
|
+
|
|
57
|
+
```markdown
|
|
58
|
+
# My Project
|
|
59
|
+
|
|
60
|
+
> Documentation for My Project
|
|
61
|
+
|
|
62
|
+
## Home
|
|
63
|
+
|
|
64
|
+
- [My Project](https://docs.example.com/index.md)
|
|
65
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
site_name: mkdocs-llms-source
|
|
2
|
+
site_url: https://TimChild.github.io/mkdocs-llms-source
|
|
3
|
+
site_description: MkDocs plugin to generate /llms.txt files for LLM-friendly documentation
|
|
4
|
+
|
|
5
|
+
theme:
|
|
6
|
+
name: material
|
|
7
|
+
|
|
8
|
+
plugins:
|
|
9
|
+
- search
|
|
10
|
+
- llms-source
|
|
11
|
+
|
|
12
|
+
nav:
|
|
13
|
+
- Home: index.md
|
|
14
|
+
- Quick Start: quickstart.md
|
|
15
|
+
- Configuration: configuration.md
|
|
16
|
+
- Development: development.md
|