diff options
| author | Yuriy Andamasov <yuriy@vyos.io> | 2026-05-06 23:24:45 +0300 |
|---|---|---|
| committer | Yuriy Andamasov <yuriy@vyos.io> | 2026-05-06 23:24:45 +0300 |
| commit | 89f86b481456437f3e9f16895e7408fe460de3f3 (patch) | |
| tree | f1bb09b203d56234c4518e6ab2d7fa5ca8610dec /docs/conf.py | |
| parent | 6ce9145fa101e623c61f009c9cf5bb75a8a4a108 (diff) | |
| parent | 7cf51e1c2901f6d1b01e9bff194f7188bc29e417 (diff) | |
| download | vyos-documentation-89f86b481456437f3e9f16895e7408fe460de3f3.tar.gz vyos-documentation-89f86b481456437f3e9f16895e7408fe460de3f3.zip | |
Merge remote-tracking branch 'origin/current' into feat/docs-llms-txt-current
# Conflicts:
# docs/conf.py
Diffstat (limited to 'docs/conf.py')
| -rw-r--r-- | docs/conf.py | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/docs/conf.py b/docs/conf.py index 72c4595a..34cb88b0 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")) @@ -66,6 +67,9 @@ autosectionlabel_prefix_document = True # source_suffix = ['.rst', '.md'] source_suffix = ['.rst', '.md'] +myst_enable_extensions = ["colon_fence", "deflist", "fieldlist", "substitution"] +myst_fence_as_directive = ["cfgcmd", "opcmd", "cmdincludemd"] + # The master toctree document. master_doc = 'index' @@ -85,7 +89,17 @@ gettext_uuid = False # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path . -exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store', '_include/vyos-1x'] +exclude_patterns = [ + u'_build', 'Thumbs.db', '.DS_Store', '_include/vyos-1x', + 'rst-*.rst', '**/rst-*.rst', +] + +import pathlib +_build = pathlib.Path(__file__).parent / '_build' +if (_build / '_rst_override_state.json').exists() and (_build / '_md_exclude.txt').exists(): + exclude_patterns.extend( + s for s in (line.strip() for line in (_build / '_md_exclude.txt').read_text().splitlines()) if s + ) # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' @@ -115,6 +129,21 @@ html_extra_path = ['_html_extra'] html_baseurl = 'https://docs.vyos.io/en/rolling/' +_rtd_version_type = os.environ.get('READTHEDOCS_VERSION_TYPE', '') +_github_version = ( + os.environ.get('READTHEDOCS_GIT_COMMIT_HASH', 'current') + if _rtd_version_type == 'external' + else os.environ.get('READTHEDOCS_GIT_IDENTIFIER', 'current') +) + +html_context = { + 'display_github': True, + 'github_user': 'vyos', + 'github_repo': 'vyos-documentation', + 'github_version': _github_version, + 'conf_py_path': '/docs/', +} + # sphinx-sitemap: baseurl already includes /en/rolling/, so skip lang+version sitemap_url_scheme = '{link}' @@ -244,6 +273,19 @@ def _write_llms_txt(app, exception): out_path.write_text(rendered, encoding='utf-8') +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) app.connect('build-finished', _write_llms_txt) |
