From e9aa1cfb93d936edc5184f124e41a5b9ce114ac0 Mon Sep 17 00:00:00 2001 From: Jan Gleixner Date: Tue, 17 Nov 2026 17:11:13 +0100 Subject: [PATCH 1/2] docs: weekly Dependabot bumps of the tutorials submodule, fix 'Edit on GitHub' on tutorial pages (SIT-446) --- .github/dependabot.yml | 5 +++++ docs/extensions/tutorials_edit_link.py | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 docs/extensions/tutorials_edit_link.py diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ec8c9b46e..d13eff43a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -19,3 +19,8 @@ updates: actions-deps: patterns: - "*" + # docs/tutorials/notebooks -> scverse/spatialdata-tutorials + - package-ecosystem: gitsubmodule + directory: / + schedule: + interval: weekly diff --git a/docs/extensions/tutorials_edit_link.py b/docs/extensions/tutorials_edit_link.py new file mode 100644 index 000000000..1c9212669 --- /dev/null +++ b/docs/extensions/tutorials_edit_link.py @@ -0,0 +1,23 @@ +"""Point "Edit on GitHub" on tutorial pages at scverse/spatialdata-tutorials. + +The tutorials are a git submodule at ``docs/tutorials/notebooks``, so the default +edit link (``spatialdata/edit//docs/tutorials/notebooks/...``) is a 404. +Edits go to the tutorials' ``main``, not to the pinned commit. +""" + +from sphinx.application import Sphinx + +PREFIX = "tutorials/notebooks/" +TUTORIALS_EDIT_URL = "https://github.com/scverse/spatialdata-tutorials/edit/main/" + + +def _edit_link(app: Sphinx, pagename: str, templatename: str, context: dict, doctree: object) -> None: + if pagename.startswith(PREFIX): + # pydata-sphinx-theme renders this template lazily; it must contain `file_name`. + context["edit_page_provider_name"] = "GitHub" + context["edit_page_url_template"] = TUTORIALS_EDIT_URL + "{{ file_name | replace('" + PREFIX + "', '', 1) }}" + + +def setup(app: Sphinx) -> dict[str, bool]: + app.connect("html-page-context", _edit_link) + return {"parallel_read_safe": True, "parallel_write_safe": True} From aa076ff8a8a5dbef1abc6e109d683a7ba5ebd46b Mon Sep 17 00:00:00 2001 From: Jan Gleixner Date: Tue, 17 Nov 2026 17:38:09 +0100 Subject: [PATCH 2/2] docs: open tutorial notebooks in github.dev (GitHub's editor shows raw JSON) --- docs/extensions/tutorials_edit_link.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/extensions/tutorials_edit_link.py b/docs/extensions/tutorials_edit_link.py index 1c9212669..ce83db09f 100644 --- a/docs/extensions/tutorials_edit_link.py +++ b/docs/extensions/tutorials_edit_link.py @@ -3,19 +3,25 @@ The tutorials are a git submodule at ``docs/tutorials/notebooks``, so the default edit link (``spatialdata/edit//docs/tutorials/notebooks/...``) is a 404. Edits go to the tutorials' ``main``, not to the pinned commit. +Notebooks open in github.dev, which edits them as cells; GitHub's own editor shows raw JSON. """ from sphinx.application import Sphinx PREFIX = "tutorials/notebooks/" -TUTORIALS_EDIT_URL = "https://github.com/scverse/spatialdata-tutorials/edit/main/" +REPO = "scverse/spatialdata-tutorials" def _edit_link(app: Sphinx, pagename: str, templatename: str, context: dict, doctree: object) -> None: - if pagename.startswith(PREFIX): - # pydata-sphinx-theme renders this template lazily; it must contain `file_name`. - context["edit_page_provider_name"] = "GitHub" - context["edit_page_url_template"] = TUTORIALS_EDIT_URL + "{{ file_name | replace('" + PREFIX + "', '', 1) }}" + if not pagename.startswith(PREFIX): + return + if context.get("page_source_suffix") == ".ipynb": + base = f"https://github.dev/{REPO}/blob/main/" + else: + base = f"https://github.com/{REPO}/edit/main/" + # pydata-sphinx-theme renders this template lazily; it must contain `file_name`. + context["edit_page_provider_name"] = "GitHub" + context["edit_page_url_template"] = base + "{{ file_name | replace('" + PREFIX + "', '', 1) }}" def setup(app: Sphinx) -> dict[str, bool]: