From 6bd7de2b379bc513d15c2c7af1bde1cc30124687 Mon Sep 17 00:00:00 2001 From: Eric Norige Date: Thu, 8 Feb 2024 13:42:17 -0800 Subject: [PATCH 1/3] Fix singlehtml target uris to be same-document references Before this change, target_uris would be generated as `index.html#foo`. This makes it difficult to rename the generated document and can require reloading the document when following a link, which can cause problems with JupyterLab hosted documentation. After this change, they are just `#foo`, which avoids the above problems. --- sphinx/builders/singlehtml.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sphinx/builders/singlehtml.py b/sphinx/builders/singlehtml.py index 9addbe23db5..9ca33036b01 100644 --- a/sphinx/builders/singlehtml.py +++ b/sphinx/builders/singlehtml.py @@ -40,8 +40,7 @@ def get_outdated_docs(self) -> str | list[str]: # type: ignore[override] def get_target_uri(self, docname: str, typ: str | None = None) -> str: if docname in self.env.all_docs: # all references are on the same page... - return self.config.root_doc + self.out_suffix + \ - '#document-' + docname + return '#document-' + docname else: # chances are this is a html_additional_page return docname + self.out_suffix From c9b140f47ec24cb4301ad84684be7df135b860e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:35:45 +0200 Subject: [PATCH 2/3] update CHANGES.rst --- CHANGES.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 3becdc1db2d..4b46446e085 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -142,6 +142,9 @@ Bugs fixed * #12040: HTML Search: Ensure that document titles that are partially-matched by the user search query are included in search results. Patch by James Addison. +* #11970: singlehtml builder: make target URIs to be same-document references in + the sense of :rfc:`3986#section-5.1`, e.g., ``index.html#foo`` becomes ``#foo``. + Patch by eanorige. Testing ------- From 8eda4bff969b151ba2afa4de5e10f9a0d5b20513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:46:38 +0200 Subject: [PATCH 3/3] update CHANGES.rst --- CHANGES.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 4b46446e085..066e18778f8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -143,8 +143,8 @@ Bugs fixed the user search query are included in search results. Patch by James Addison. * #11970: singlehtml builder: make target URIs to be same-document references in - the sense of :rfc:`3986#section-5.1`, e.g., ``index.html#foo`` becomes ``#foo``. - Patch by eanorige. + the sense of :rfc:`RFC 3986, ยง4.4 <3986#section-4.4>`, e.g., ``index.html#foo`` + becomes ``#foo``. Patch by eanorige. Testing -------