From 1d72ecbad5afafe9fa9c5b0b6f0ba1a646148d57 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 21 Sep 2022 14:59:56 +0200 Subject: [PATCH] Support custom URL for edit button link. Fixes: #195. Related to: #374. Signed-off-by: Martin Liska --- docs/customisation/edit-button.md | 8 ++++++++ src/furo/theme/furo/components/edit-this-page.html | 2 ++ src/furo/theme/furo/theme.conf | 1 + 3 files changed, 11 insertions(+) diff --git a/docs/customisation/edit-button.md b/docs/customisation/edit-button.md index 840c98a39..19b205ea2 100644 --- a/docs/customisation/edit-button.md +++ b/docs/customisation/edit-button.md @@ -12,6 +12,14 @@ html_theme_options = { } ``` +Alternatively, you can manually set an URL that will be used for the edit button link: + +```python +html_theme_options = { + "source_edit_link": "_sources/{filename}.txt", +} +``` + ## Disabling on Read the Docs If you're building documentation on Read the Docs using a GitHub repository as the source, the edit button is enabled by default. If you wish to disable this, use {ref}`top_of_page_button`. diff --git a/src/furo/theme/furo/components/edit-this-page.html b/src/furo/theme/furo/components/edit-this-page.html index 6945488d3..8b034f1b6 100644 --- a/src/furo/theme/furo/components/edit-this-page.html +++ b/src/furo/theme/furo/components/edit-this-page.html @@ -24,4 +24,6 @@ {%- elif READTHEDOCS and conf_py_path and page_source_suffix and github_user != "None" and github_repo != "None" and github_version %} {% set url = "https://github.com/" + github_user + "/" + github_repo + "/edit/" + github_version + conf_py_path + pagename + page_source_suffix %} {{ furo_edit_button(url) }} +{%- elif page_source_suffix %} + {{ furo_edit_button(determine_page_edit_link()) }} {%- endif -%} diff --git a/src/furo/theme/furo/theme.conf b/src/furo/theme/furo/theme.conf index c9f2eefd8..dd3606d6d 100644 --- a/src/furo/theme/furo/theme.conf +++ b/src/furo/theme/furo/theme.conf @@ -26,3 +26,4 @@ top_of_page_button = edit source_repository = source_branch = source_directory = +source_edit_link =