From b26a59dbfe0a1e96a71cfd8e9f4bf68e20eb14ec Mon Sep 17 00:00:00 2001 From: Yuriy Andamasov Date: Wed, 6 May 2026 16:15:22 +0300 Subject: docs: link "View page source" to GitHub instead of raw text (#1887) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: link "View page source" to GitHub instead of raw text Adds html_context with display_github=True so the sphinx_rtd_theme generates an "Edit on GitHub" link. READTHEDOCS_GIT_IDENTIFIER is used to point at the exact branch/PR ref being built; falls back to "current" for local builds. 🤖 Generated by [robots](https://vyos.io) * docs: fix GitHub source link on RTD PR preview builds On external (PR preview) builds READTHEDOCS_GIT_IDENTIFIER is set to the PR number, which is not a valid GitHub ref. Use the commit hash instead for external builds; branch name for regular builds. 🤖 Generated by [robots](https://vyos.io) --- docs/conf.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'docs/conf.py') diff --git a/docs/conf.py b/docs/conf.py index 1c1014e0..78bc8ec1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -115,6 +115,21 @@ html_extra_path = ['_html_extra'] html_baseurl = 'https://docs.vyos.io/en/latest/' +_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/latest/, so skip lang+version sitemap_url_scheme = '{link}' -- cgit v1.2.3