From ce48fd34ef9347947206c23f13332e6e32fe0be0 Mon Sep 17 00:00:00 2001 From: Yuriy Andamasov Date: Sat, 2 May 2026 22:40:29 +0300 Subject: feat(conf): copy .md sources into HTML output for plain-text serving MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a build-finished hook that mirrors every .md file from the Sphinx source tree into the HTML output directory verbatim, making unrendered MyST sources accessible alongside HTML renders at the same URL path. 🤖 Generated by [robots](https://vyos.io) --- docs/conf.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'docs/conf.py') diff --git a/docs/conf.py b/docs/conf.py index c13397a9..ed3cc734 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,6 +13,7 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. # import os +import shutil import sys sys.path.append(os.path.abspath("./_ext")) @@ -242,5 +243,18 @@ def _prefer_webp(app): app.builder.supported_image_types = ['image/webp'] + types +def _copy_md_sources(app, exception): + """Copy .md source files verbatim into the HTML output tree.""" + if exception is not None: + return + src = pathlib.Path(app.srcdir) + out = pathlib.Path(app.outdir) + for path in src.rglob("*.md"): + dest = out / path.relative_to(src) + dest.parent.mkdir(parents=True, exist_ok=True) + shutil.copy2(path, dest) + + def setup(app): app.connect('builder-inited', _prefer_webp) + app.connect('build-finished', _copy_md_sources) -- cgit v1.2.3