pradyunsg / furo

A clean customizable documentation theme for Sphinx
https://pradyunsg.me/furo/quickstart
MIT License
2.65k stars 304 forks source link

Fix edit button on Read the Docs with stable branch builds #668

Open pradyunsg opened 1 year ago

pradyunsg commented 1 year ago

What's happening?

The current logic for computing the GitHub URLs in Furo, when on RTD is:

https://github.com/pradyunsg/furo/blob/490527b2aef00b1198770c3389a1979911ee1fcb/src/furo/theme/furo/components/edit-this-page.html#L24

This differs from sphinx-rtd-theme (https://github.com/readthedocs/sphinx_rtd_theme/blob/9899ee4ee2f547f81e51297dc12317f018e62fdd/sphinx_rtd_theme/breadcrumbs.html#L39) and should be fixed to align with that.

Reproducer

  1. Build Sphinx documentation set on RTD, with a stable branch or tag.
  2. See the edit page button's URL -- it has the commit hash rather than the source ref.

Expectation

The generated URL should point to the source ref.

Code of Conduct

matthewhughes934 commented 2 weeks ago

Is there anything blocking changing this? Is it as simple as updating the path you linked:

diff --git a/src/furo/theme/furo/components/edit-this-page.html b/src/furo/theme/furo/components/edit-this-page.html
index c61b17b..e8dc5f7 100644
--- a/src/furo/theme/furo/components/edit-this-page.html
+++ b/src/furo/theme/furo/components/edit-this-page.html
@@ -17,7 +17,7 @@
 {% block link_not_available %}
 {# Make nice things happen, on Read the Docs #}
 {%- if READTHEDOCS and conf_py_path and page_source_suffix and github_user != "None" and github_repo != "None" and github_version and pagename and page_source_suffix %}
-  {% set url = "https://github.com/" + github_user + "/" + github_repo + "/edit/" + github_version + conf_py_path + pagename + page_source_suffix %}
+  {% set url = "https://github.com/" + github_user + "/" + github_repo + "/blob/" + github_version + conf_py_path + pagename + page_source_suffix %}
   {{ furo_edit_button(url) }}
 {%- endif -%}
 {% endblock %}
pradyunsg commented 2 weeks ago

That is not gonna work since blob links are not what we wanna link to and those pages also don’t have an edit button. What we need to change to is linked inOP. It’s a matter of someone investigating and making the relevant changes.