From a03751b72d443bcee94b5a222806915329bfa03e Mon Sep 17 00:00:00 2001 From: Yuriy Andamasov Date: Mon, 4 May 2026 11:02:44 +0300 Subject: docs: render llms.txt at build time from a Jinja template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the static curated llms.txt with a build-time render that interpolates html_baseurl and release into the file, so the file always matches the branch it was built from. llms-full.txt is already auto-generated by sphinx-llms-txt. 🤖 Generated by [robots](https://vyos.io) --- docs/conf.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'docs/conf.py') diff --git a/docs/conf.py b/docs/conf.py index 1c1014e0..942c25c9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -217,5 +217,21 @@ def _prefer_webp(app): app.builder.supported_image_types = ['image/webp'] + types +def _write_llms_txt(app, exception): + if exception is not None or app.builder.name != 'html': + return + from pathlib import Path + from jinja2 import Template + tpl_path = Path(app.srcdir) / '_templates' / 'llms.txt.j2' + out_path = Path(app.outdir) / 'llms.txt' + baseurl = (app.config.html_baseurl or '').rstrip('/') + '/' + rendered = Template(tpl_path.read_text(encoding='utf-8')).render( + baseurl=baseurl, + release=app.config.release, + ) + out_path.write_text(rendered, encoding='utf-8') + + def setup(app): app.connect('builder-inited', _prefer_webp) + app.connect('build-finished', _write_llms_txt) -- cgit v1.2.3