From fa6dfd0191811f6fe6643228351787786b179132 Mon Sep 17 00:00:00 2001 From: Evan Binu Chirayath <143860161+EvanBinu@users.noreply.github.com> Date: Mon, 12 May 2025 22:46:55 +0530 Subject: [PATCH] Update edit-source-links-sphinx.rst Edit Source link for Gitea, Forgejo, or other self-hosted online repository #12117 --- docs/user/guides/edit-source-links-sphinx.rst | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/docs/user/guides/edit-source-links-sphinx.rst b/docs/user/guides/edit-source-links-sphinx.rst index 7976ba0f731..e1342850ff2 100644 --- a/docs/user/guides/edit-source-links-sphinx.rst +++ b/docs/user/guides/edit-source-links-sphinx.rst @@ -80,3 +80,40 @@ Additional variables -------------------- * ``'pagename'`` - Sphinx variable representing the name of the page you're on. + + + +Other Hosting Platforms +------ +To support custom or lesser-known repository hosting platforms (such as Gitea, Forgejo, or Codeberg), you can configure the `html_context` in your `conf.py` file using the following variables: + +``` +html_context = { + "display_repo": True, # Enable generic repo integration + "repo_host": "codeberg.org", # Host (e.g., gitea.example.com, codeberg.org) + "repo_user": "MyUserName", # Username or organization + "repo_slug": "MyDoc", # Repository name + "repo_version": "main", # Branch or tag name + "conf_src_path": "/src/branch/", # Path between repo and version (Gitea uses /src/branch/) + "conf_py_path": "/docs/", # Path to docs root in repository + "suffix": ".rst", # File suffix, e.g. .rst or .md +} +``` + +You can then use it in your theme template like this: + +``` +{% if display_repo %} + Edit Source +{% endif %} +``` + +This generic method supports any Git-based repository that has a URL structure similar to: + +``` +https://///src/branch// +``` + +