From 768ec1dce349fe4708f6ad68be1ebb3f3dabafa1 Mon Sep 17 00:00:00 2001 From: driazati <9407960+driazati@users.noreply.github.com> Date: Mon, 24 Oct 2022 17:36:08 -0700 Subject: [PATCH] Add hook for changing 'Edit on GitHub' links (#10) These links are fine by default for normal `.rst` pages, but for sphinx gallery pages the link ends up being the `.rst` that was generated from the original `.py`. This adds a hook function that TVM can specify in its `docs/conf.py` to change the URLs to match the repo structure (in this case a 1 line regex replace) --- tlcpack_sphinx_addon/_templates/breadcrumbs.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tlcpack_sphinx_addon/_templates/breadcrumbs.html b/tlcpack_sphinx_addon/_templates/breadcrumbs.html index 0ff6b24..35f1e3e 100644 --- a/tlcpack_sphinx_addon/_templates/breadcrumbs.html +++ b/tlcpack_sphinx_addon/_templates/breadcrumbs.html @@ -44,6 +44,12 @@ {% endfor %}
  • {{ title }}
  • {% endblock %} + {% if suffix %} + {% set _edit_url = 'https://github.com/' + github_user + '/' + github_repo + '/' + theme_vcs_pageview_mode + '/' + github_version + pagename + suffix %} + {% if edit_link_hook_fn %} + {% set _edit_url = edit_link_hook_fn(_edit_url) %} + {% endif %} + {% endif %} {% block breadcrumbs_aside %}
  • {% if hasdoc(pagename) %} @@ -52,7 +58,7 @@ {{ _('Edit on GitHub') }} {% else %} - {{ _('Edit on GitHub') }} + {{ _('Edit on GitHub') }} {% endif %} {% elif display_bitbucket %} {% if check_meta and 'bitbucket_url' in meta %}