Skip to content

Commit 3799832

Browse files
kwagyemanclaude
andcommitted
docs/conf: Pin source links to parent's build SHA.
Resolves "Edit this page" + AI-dropdown source links to the user-facing openmv/openmv-doc repo at the parent's build-time HEAD commit (so links are immutable per build). Falls back to "master" when git isn't reachable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c5507f8 commit 3799832

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

docs/conf.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import sys
1717
import os
18+
import subprocess
1819

1920
# If extensions (or modules to document with autodoc) are in another directory,
2021
# add these directories to sys.path here. If the directory is relative to the
@@ -37,19 +38,37 @@
3738
build_date = _dt.date.today().strftime("%d %b %Y")
3839

3940
# Values exposed to topindex.html and footer templates.
41+
# Resolve the parent (openmv-doc) repo's HEAD SHA at build time so
42+
# "Edit this page" and the AI dropdown's raw-source link both pin to
43+
# the exact commit that produced the page. Falls back to "master" if
44+
# `git` isn't available (e.g. shallow tarball checkouts).
45+
try:
46+
_parent_repo = os.path.abspath(
47+
os.path.join(os.path.dirname(__file__), "..", "..")
48+
)
49+
source_version = subprocess.check_output(
50+
["git", "rev-parse", "HEAD"],
51+
cwd=_parent_repo,
52+
stderr=subprocess.DEVNULL,
53+
).decode().strip()
54+
except Exception:
55+
source_version = "master"
56+
4057
html_context = {
4158
"openmv_version": openmv_version,
4259
"micropython_version": micropython_version,
4360
"build_date": build_date,
44-
# Tells Shibuya where the page source lives — used as a fallback
45-
# for the "Copy page" / "Open in ChatGPT/Claude/Perplexity" links
46-
# when html_baseurl isn't set (in which case Shibuya reads from
47-
# the deployed site's /_sources/ tree instead).
61+
# Tells Shibuya where the page source lives — used by the "Edit
62+
# this page" link, and as a fallback for the AI dropdown's
63+
# "Open in ChatGPT/Claude/Perplexity" raw-source links when
64+
# html_baseurl isn't reachable. Points at the user-facing
65+
# openmv-doc parent repo (GitHub renders submodule contents
66+
# through the parent's path).
4867
"source_type": "github",
4968
"source_user": "openmv",
5069
"source_repo": "openmv-doc",
5170
"source_docs_path": "/micropython/docs/",
52-
"source_version": "master",
71+
"source_version": source_version,
5372
}
5473

5574
# Site root — used by sphinx-llms-txt to emit absolute URLs in

0 commit comments

Comments
 (0)