mirror of
https://github.com/nlohmann/json.git
synced 2026-07-09 03:55:09 +00:00
7c9208bfb3
Implement the scoped agent-readiness subset for json.nlohmann.me: - Add the mkdocs-llmstxt plugin to generate llms.txt from the nav (full_output/llms-full.txt deliberately omitted to avoid dumping 500+ API reference pages into one giant file). - Add a permissive robots.txt with a Sitemap reference. - Add a build hook (hooks/copy_markdown_source.py) that copies each page's Markdown source into the built site as a `<path>.md` sibling of its HTML output, so agents/tools can fetch raw Markdown directly. sitemap.xml was already emitted by default and needed no change. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
26 lines
752 B
Python
26 lines
752 B
Python
"""Copy each documentation page's Markdown source into the built site."""
|
|
|
|
# Creates a `<path>.md` sibling of each HTML output (for example,
|
|
# `features/comments/` becomes `features/comments.md`) so agents and tools can
|
|
# fetch the raw Markdown directly instead of parsing rendered HTML.
|
|
|
|
import os
|
|
import shutil
|
|
|
|
_pages = []
|
|
|
|
|
|
def on_files(files, config):
|
|
global _pages
|
|
_pages = [f for f in files if f.is_documentation_page()]
|
|
return files
|
|
|
|
|
|
def on_post_build(config):
|
|
site_dir = config["site_dir"]
|
|
for file in _pages:
|
|
url = file.url.rstrip("/")
|
|
target = os.path.join(site_dir, (url or "index") + ".md")
|
|
os.makedirs(os.path.dirname(target), exist_ok=True)
|
|
shutil.copyfile(file.abs_src_path, target)
|