diff options
| author | Yuriy Andamasov <yuriy@vyos.io> | 2026-05-07 09:52:17 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-07 09:52:17 +0300 |
| commit | 7415ae8d15acea28f4910e6c4fd052aaab7985ed (patch) | |
| tree | a5c57fcffc2c571a825a42c00066e8f79c6346d4 /docs | |
| parent | b8fc0b98dadc8eabf584ed9db599c37f454dfaaf (diff) | |
| parent | 310cf6a0b7f532fd7f2de7c8a6c2006838b7f838 (diff) | |
| download | vyos-documentation-7415ae8d15acea28f4910e6c4fd052aaab7985ed.tar.gz vyos-documentation-7415ae8d15acea28f4910e6c4fd052aaab7985ed.zip | |
Merge pull request #1903 from vyos/feat/docs-llms-txt-render-circinus
docs: render llms.txt at build time (circinus)
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/_html_extra/llms.txt | 52 | ||||
| -rw-r--r-- | docs/_templates/llms.txt.j2 | 52 | ||||
| -rw-r--r-- | docs/conf.py | 58 |
3 files changed, 108 insertions, 54 deletions
diff --git a/docs/_html_extra/llms.txt b/docs/_html_extra/llms.txt deleted file mode 100644 index 03d8562d..00000000 --- a/docs/_html_extra/llms.txt +++ /dev/null @@ -1,52 +0,0 @@ -# VyOS - -> VyOS is a free, open-source network operating system based on Debian GNU/Linux. -> It provides routing, firewall, and VPN functionality via a unified CLI using -> `set`/`delete`/`show` command hierarchy. This documentation covers 1.5.x (circinus). - -VyOS configuration follows a tree structure. All configuration commands start with -`set` (to add/change) or `delete` (to remove). Changes are staged and applied with -`commit`. The CLI hierarchy maps directly to the documentation structure. - -## Quick Start - -- [Quick Start Guide](https://docs.vyos.io/en/1.5/quick-start.html): Minimal setup walkthrough -- [CLI Overview](https://docs.vyos.io/en/1.5/cli.html): Command-line interface usage - -## Configuration - -- [Firewall](https://docs.vyos.io/en/1.5/configuration/firewall/index.html): Zone-based firewall, rules, groups -- [Interfaces](https://docs.vyos.io/en/1.5/configuration/interfaces/index.html): Ethernet, bonding, bridge, VLAN, tunnel, wireless -- [Protocols](https://docs.vyos.io/en/1.5/configuration/protocols/index.html): BGP, OSPF, IS-IS, static routing, MPLS -- [VPN](https://docs.vyos.io/en/1.5/configuration/vpn/index.html): IPsec, OpenVPN, WireGuard, L2TP, PPTP -- [NAT](https://docs.vyos.io/en/1.5/configuration/nat/index.html): Source NAT, destination NAT, NAT66 -- [System](https://docs.vyos.io/en/1.5/configuration/system/index.html): DNS, NTP, syslog, users, task scheduler -- [High Availability](https://docs.vyos.io/en/1.5/configuration/highavailability/index.html): VRRP -- [Load Balancing](https://docs.vyos.io/en/1.5/configuration/loadbalancing/index.html): WAN and reverse proxy -- [Containers](https://docs.vyos.io/en/1.5/configuration/container/index.html): Podman-based container support -- [PKI](https://docs.vyos.io/en/1.5/configuration/pki/index.html): Certificate management -- [Policy](https://docs.vyos.io/en/1.5/configuration/policy/index.html): Route maps, prefix lists, access lists -- [Traffic Policy](https://docs.vyos.io/en/1.5/configuration/trafficpolicy/index.html): QoS and shaping -- [Service](https://docs.vyos.io/en/1.5/configuration/service/index.html): DHCP, DNS forwarding, SNMP, SSH, HTTPS API -- [VRF](https://docs.vyos.io/en/1.5/configuration/vrf/index.html): Virtual routing and forwarding - -## Operations - -- [Operational Commands](https://docs.vyos.io/en/1.5/operation/index.html): Show, monitor, restart commands - -## Installation - -- [Installation Guide](https://docs.vyos.io/en/1.5/installation/index.html): Bare metal, virtual, cloud deployments - -## Automation - -- [Automation](https://docs.vyos.io/en/1.5/automation/index.html): Ansible, Terraform, HTTP API, NETCONF - -## Configuration Examples - -- [Blueprints](https://docs.vyos.io/en/1.5/configexamples/index.html): Real-world topology examples - -## Optional - -- [Contributing](https://docs.vyos.io/en/1.5/contributing/index.html): Development workflow -- [VPP](https://docs.vyos.io/en/1.5/vpp/index.html): Vector Packet Processing integration diff --git a/docs/_templates/llms.txt.j2 b/docs/_templates/llms.txt.j2 new file mode 100644 index 00000000..1c6a3900 --- /dev/null +++ b/docs/_templates/llms.txt.j2 @@ -0,0 +1,52 @@ +# VyOS + +> VyOS is a free, open-source network operating system based on Debian GNU/Linux. +> It provides routing, firewall, and VPN functionality via a unified CLI using +> `set`/`delete`/`show` command hierarchy. This documentation covers {{ release }}. + +VyOS configuration follows a tree structure. All configuration commands start with +`set` (to add/change) or `delete` (to remove). Changes are staged and applied with +`commit`. The CLI hierarchy maps directly to the documentation structure. + +## Quick Start + +- [Quick Start Guide]({{ baseurl }}quick-start.md): Minimal setup walkthrough +- [CLI Overview]({{ baseurl }}cli.md): Command-line interface usage + +## Configuration + +- [Firewall]({{ baseurl }}configuration/firewall/index.md): Zone-based firewall, rules, groups +- [Interfaces]({{ baseurl }}configuration/interfaces/index.md): Ethernet, bonding, bridge, VLAN, tunnel, wireless +- [Protocols]({{ baseurl }}configuration/protocols/index.md): BGP, OSPF, IS-IS, static routing, MPLS +- [VPN]({{ baseurl }}configuration/vpn/index.md): IPsec, OpenVPN, WireGuard, L2TP, PPTP +- [NAT]({{ baseurl }}configuration/nat/index.md): Source NAT, destination NAT, NAT66 +- [System]({{ baseurl }}configuration/system/index.md): DNS, NTP, syslog, users, task scheduler +- [High Availability]({{ baseurl }}configuration/highavailability/index.md): VRRP +- [Load Balancing]({{ baseurl }}configuration/loadbalancing/index.md): WAN and reverse proxy +- [Containers]({{ baseurl }}configuration/container/index.md): Podman-based container support +- [PKI]({{ baseurl }}configuration/pki/index.md): Certificate management +- [Policy]({{ baseurl }}configuration/policy/index.md): Route maps, prefix lists, access lists +- [Traffic Policy]({{ baseurl }}configuration/trafficpolicy/index.md): QoS and shaping +- [Service]({{ baseurl }}configuration/service/index.md): DHCP, DNS forwarding, SNMP, SSH, HTTPS API +- [VRF]({{ baseurl }}configuration/vrf/index.md): Virtual routing and forwarding + +## Operations + +- [Operational Commands]({{ baseurl }}operation/index.md): Show, monitor, restart commands + +## Installation + +- [Installation Guide]({{ baseurl }}installation/index.md): Bare metal, virtual, cloud deployments + +## Automation + +- [Automation]({{ baseurl }}automation/index.md): Ansible, Terraform, HTTP API, NETCONF + +## Configuration Examples + +- [Blueprints]({{ baseurl }}configexamples/index.md): Real-world topology examples + +## Optional + +- [Contributing]({{ baseurl }}contributing/index.md): Development workflow +- [VPP]({{ baseurl }}vpp/index.md): Vector Packet Processing integration diff --git a/docs/conf.py b/docs/conf.py index 23c76d3e..5ede415e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -147,8 +147,10 @@ html_context = { # sphinx-sitemap: baseurl already includes /en/1.5/, so skip lang+version sitemap_url_scheme = '{link}' -# sphinx-llms-txt: disable auto-generated llms.txt, keep curated one from -# _html_extra; llms-full.txt is still auto-generated +# sphinx-llms-txt: disable the package's auto-generated index llms.txt. +# The curated llms.txt is rendered at build time from +# _templates/llms.txt.j2 by the _write_llms_txt() build-finished hook +# below; llms-full.txt is still auto-generated by sphinx-llms-txt. llms_txt_file = False # Custom sidebar templates, must be a dictionary that maps document names @@ -258,6 +260,58 @@ def _copy_md_sources(app, exception): shutil.copy2(path, dest) +def _write_llms_txt(app, exception): + """Render the curated llms.txt at build-finished time. + + Reads ``_templates/llms.txt.j2``, interpolates ``html_baseurl`` and + ``release``, and writes ``<outdir>/llms.txt``. ``llms-full.txt`` is + handled separately by the ``sphinx_llms_txt`` extension. + """ + # Skip dirhtml: production publishes via the `html` / `readthedocs` + # builders only. The `.md` links in the curated template do + # actually resolve under `dirhtml` (`_copy_md_sources` puts `.md` + # files at their source-relative paths regardless of builder), but + # we still don't render llms.txt for builds we don't ship — local + # `make dirhtml` is a developer convenience, not a publish target. + if exception is not None or app.builder.name not in ( + 'html', 'readthedocs'): + return + if not app.config.html_baseurl: + # Fail loudly rather than rendering /quick-start.md etc. as a + # silently-broken root-relative URL — every supported branch + # sets html_baseurl, so a missing value is a regression. + raise RuntimeError( + 'html_baseurl must be set to render llms.txt') + from pathlib import Path + from jinja2 import Environment, FileSystemLoader, StrictUndefined + tpl_dir = Path(app.srcdir) / '_templates' + out_path = Path(app.outdir) / 'llms.txt' + baseurl = app.config.html_baseurl.rstrip('/') + '/' + # FileSystemLoader + get_template (rather than from_string) makes + # Jinja tracebacks reference the real template filename and line + # number — useful when StrictUndefined trips on a typo in + # llms.txt.j2. StrictUndefined: missing template variables raise + # rather than silently render as empty strings, so a typo in + # llms.txt.j2 fails the build instead of shipping a half-blank + # llms.txt. + env = Environment( + loader=FileSystemLoader(str(tpl_dir)), + undefined=StrictUndefined, + keep_trailing_newline=True, + # Plain-text template (not HTML), so HTML autoescape is not + # appropriate. Setting autoescape=False explicitly to silence + # bandit/ruff S701 and document the intent. + autoescape=False, + ) + template = env.get_template('llms.txt.j2') + rendered = template.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', _copy_md_sources) + app.connect('build-finished', _write_llms_txt) |
