Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ updates:
actions-deps:
patterns:
- "*"
# docs/tutorials/notebooks -> scverse/spatialdata-tutorials
- package-ecosystem: gitsubmodule
directory: /
schedule:
interval: weekly
29 changes: 29 additions & 0 deletions docs/extensions/tutorials_edit_link.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""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/<ref>/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/"
REPO = "scverse/spatialdata-tutorials"


def _edit_link(app: Sphinx, pagename: str, templatename: str, context: dict, doctree: object) -> None:
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]:
app.connect("html-page-context", _edit_link)
return {"parallel_read_safe": True, "parallel_write_safe": True}
Loading