From de43317396f79b5c75507406a0edaff920a27f0a Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Mon, 30 May 2022 12:50:55 +0100 Subject: [PATCH 01/18] Add `aside.topic` for Docutils 0.18+ --- sphinx/themes/basic/static/basic.css_t | 6 ++++-- sphinx/themes/bizstyle/static/bizstyle.css_t | 2 +- sphinx/themes/classic/static/classic.css_t | 2 +- sphinx/themes/epub/static/epub.css_t | 2 +- sphinx/themes/nature/static/nature.css_t | 2 +- sphinx/themes/nonav/static/nonav.css | 2 +- sphinx/themes/pyramid/static/epub.css | 2 +- sphinx/themes/pyramid/static/pyramid.css_t | 2 +- sphinx/themes/sphinxdoc/static/sphinxdoc.css_t | 2 +- sphinx/themes/traditional/static/traditional.css_t | 2 +- 10 files changed, 13 insertions(+), 11 deletions(-) diff --git a/sphinx/themes/basic/static/basic.css_t b/sphinx/themes/basic/static/basic.css_t index a05c8ba0e..9e5047afe 100644 --- a/sphinx/themes/basic/static/basic.css_t +++ b/sphinx/themes/basic/static/basic.css_t @@ -335,13 +335,13 @@ p.sidebar-title { font-weight: bold; } -div.admonition, div.topic, blockquote { +div.admonition, div.topic, aside.topic, blockquote { clear: left; } /* -- topics ---------------------------------------------------------------- */ -div.topic { +div.topic, aside.topic { border: 1px solid #ccc; padding: 7px; margin: 10px 0 10px 0; @@ -380,6 +380,7 @@ div.body p.centered { div.sidebar > :last-child, aside.sidebar > :last-child, div.topic > :last-child, +aside.topic > :last-child, div.admonition > :last-child { margin-bottom: 0; } @@ -387,6 +388,7 @@ div.admonition > :last-child { div.sidebar::after, aside.sidebar::after, div.topic::after, +aside.topic::after, div.admonition::after, blockquote::after { display: block; diff --git a/sphinx/themes/bizstyle/static/bizstyle.css_t b/sphinx/themes/bizstyle/static/bizstyle.css_t index 465734646..b5c84e0bb 100644 --- a/sphinx/themes/bizstyle/static/bizstyle.css_t +++ b/sphinx/themes/bizstyle/static/bizstyle.css_t @@ -306,7 +306,7 @@ div.quotebar { border: 1px solid #ccc; } -div.topic { +div.topic, aside.topic { background-color: #f8f8f8; } diff --git a/sphinx/themes/classic/static/classic.css_t b/sphinx/themes/classic/static/classic.css_t index 739def5cd..58b55c8bf 100644 --- a/sphinx/themes/classic/static/classic.css_t +++ b/sphinx/themes/classic/static/classic.css_t @@ -290,7 +290,7 @@ div.seealso { border: 1px solid #ff6; } -div.topic { +div.topic, aside.topic { background-color: #eee; } diff --git a/sphinx/themes/epub/static/epub.css_t b/sphinx/themes/epub/static/epub.css_t index 981baaab0..f7a12c0f0 100644 --- a/sphinx/themes/epub/static/epub.css_t +++ b/sphinx/themes/epub/static/epub.css_t @@ -245,7 +245,7 @@ p.sidebar-title { /* -- topics ---------------------------------------------------------------- */ -div.topic { +div.topic, aside.topic { border: 1px solid #ccc; padding: 7px 7px 0 7px; margin: 10px 0 10px 0; diff --git a/sphinx/themes/nature/static/nature.css_t b/sphinx/themes/nature/static/nature.css_t index 28a4f64c9..f3c0d0224 100644 --- a/sphinx/themes/nature/static/nature.css_t +++ b/sphinx/themes/nature/static/nature.css_t @@ -194,7 +194,7 @@ div.seealso { border: 1px solid #ff6; } -div.topic { +div.topic, aside.topic { background-color: #eee; } diff --git a/sphinx/themes/nonav/static/nonav.css b/sphinx/themes/nonav/static/nonav.css index 98d2163a4..3bb152166 100644 --- a/sphinx/themes/nonav/static/nonav.css +++ b/sphinx/themes/nonav/static/nonav.css @@ -234,7 +234,7 @@ p.sidebar-title { /* -- topics ---------------------------------------------------------------- */ -div.topic { +div.topic, aside.topic { border: 1px solid #ccc; padding: 7px 7px 0 7px; margin: 10px 0 10px 0; diff --git a/sphinx/themes/pyramid/static/epub.css b/sphinx/themes/pyramid/static/epub.css index 165f41d5d..8606c8c8d 100644 --- a/sphinx/themes/pyramid/static/epub.css +++ b/sphinx/themes/pyramid/static/epub.css @@ -254,7 +254,7 @@ div.seealso { border: 1px solid #ff6; } -div.topic { +div.topic, aside.topic { background-color: #eee; } diff --git a/sphinx/themes/pyramid/static/pyramid.css_t b/sphinx/themes/pyramid/static/pyramid.css_t index c8c05af3b..b7fed2943 100644 --- a/sphinx/themes/pyramid/static/pyramid.css_t +++ b/sphinx/themes/pyramid/static/pyramid.css_t @@ -245,7 +245,7 @@ div.seealso { padding: 10px 20px 10px 60px; } -div.topic { +div.topic, aside.topic { background: #eeeeee; border: 2px solid #C6C9CB; padding: 10px 20px; diff --git a/sphinx/themes/sphinxdoc/static/sphinxdoc.css_t b/sphinx/themes/sphinxdoc/static/sphinxdoc.css_t index 1ff1d0291..b6de4ae6f 100644 --- a/sphinx/themes/sphinxdoc/static/sphinxdoc.css_t +++ b/sphinx/themes/sphinxdoc/static/sphinxdoc.css_t @@ -266,7 +266,7 @@ div.quotebar { border: 1px solid #ccc; } -div.topic { +div.topic, aside.topic { background-color: #f8f8f8; } diff --git a/sphinx/themes/traditional/static/traditional.css_t b/sphinx/themes/traditional/static/traditional.css_t index f98b33719..b5b05dc21 100644 --- a/sphinx/themes/traditional/static/traditional.css_t +++ b/sphinx/themes/traditional/static/traditional.css_t @@ -506,7 +506,7 @@ p.rubric { /* "Topics" */ -div.topic { +div.topic, aside.topic { background-color: #eee; border: 1px solid #ccc; padding: 0 7px 0 7px; From 6755290592176c1a4152f6aa291ffe94bb0f2b23 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Mon, 30 May 2022 12:57:35 +0100 Subject: [PATCH 02/18] Add `aside.sidebar` where it is missing --- sphinx/themes/agogo/static/agogo.css_t | 37 ++++++++++++++-------- sphinx/themes/epub/static/epub.css_t | 2 +- sphinx/themes/nonav/static/nonav.css | 2 +- sphinx/themes/pyramid/static/pyramid.css_t | 2 +- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/sphinx/themes/agogo/static/agogo.css_t b/sphinx/themes/agogo/static/agogo.css_t index 08a4db0cc..14c5e52ce 100644 --- a/sphinx/themes/agogo/static/agogo.css_t +++ b/sphinx/themes/agogo/static/agogo.css_t @@ -271,7 +271,8 @@ div.document ol { /* Sidebar */ -div.sidebar { +div.sidebar, +aside.sidebar { width: {{ theme_sidebarwidth|todim }}; {%- if theme_rightsidebar|tobool %} float: right; @@ -281,26 +282,29 @@ div.sidebar { font-size: .9em; } -div.sidebar a, div.header a { +div.sidebar a, aside.sidebar a, div.header a { text-decoration: none; } -div.sidebar a:hover, div.header a:hover { +div.sidebar a:hover, aside.sidebar a:hover, div.header a:hover { text-decoration: underline; } -div.sidebar h3 { +div.sidebar h3, +aside.sidebar h3 { color: #2e3436; text-transform: uppercase; font-size: 130%; letter-spacing: .1em; } -div.sidebar ul { +div.sidebar ul, +aside.sidebar ul { list-style-type: none; } -div.sidebar li.toctree-l1 a { +div.sidebar li.toctree-l1 a, +aside.sidebar li.toctree-l1 a { display: block; padding: 1px; border: 1px solid #dddddd; @@ -310,37 +314,44 @@ div.sidebar li.toctree-l1 a { color: #2e3436; } -div.sidebar li.toctree-l2 a { +div.sidebar li.toctree-l2 a, +aside.sidebar li.toctree-l2 a { background-color: transparent; border: none; margin-left: 1em; border-bottom: 1px solid #dddddd; } -div.sidebar li.toctree-l3 a { +div.sidebar li.toctree-l3 a, +aside.sidebar li.toctree-l3 a { background-color: transparent; border: none; margin-left: 2em; border-bottom: 1px solid #dddddd; } -div.sidebar li.toctree-l2:last-child a { +div.sidebar li.toctree-l2:last-child a, +aside.sidebar li.toctree-l2:last-child a { border-bottom: none; } -div.sidebar li.toctree-l1.current a { +div.sidebar li.toctree-l1.current a, +aside.sidebar li.toctree-l1.current a { border-right: 5px solid {{ theme_headerlinkcolor }}; } -div.sidebar li.toctree-l1.current li.toctree-l2 a { +div.sidebar li.toctree-l1.current li.toctree-l2 a, +aside.sidebar li.toctree-l1.current li.toctree-l2 a { border-right: none; } -div.sidebar input[type="text"] { +div.sidebar input[type="text"], +aside.sidebar input[type="text"] { width: 170px; } -div.sidebar input[type="submit"] { +div.sidebar input[type="submit"], +aside.sidebar input[type="submit"] { width: 30px; } diff --git a/sphinx/themes/epub/static/epub.css_t b/sphinx/themes/epub/static/epub.css_t index f7a12c0f0..bd64a1bc8 100644 --- a/sphinx/themes/epub/static/epub.css_t +++ b/sphinx/themes/epub/static/epub.css_t @@ -230,7 +230,7 @@ p.rubric { /* -- sidebars -------------------------------------------------------------- */ -div.sidebar { +div.sidebar, aside.sidebar { margin: 0 0 0.5em 1em; border: 1px solid #ddb; padding: 7px 7px 0 7px; diff --git a/sphinx/themes/nonav/static/nonav.css b/sphinx/themes/nonav/static/nonav.css index 3bb152166..90c3300cf 100644 --- a/sphinx/themes/nonav/static/nonav.css +++ b/sphinx/themes/nonav/static/nonav.css @@ -219,7 +219,7 @@ p.rubric { /* -- sidebars -------------------------------------------------------------- */ -div.sidebar { +div.sidebar, aside.sidebar { margin: 0 0 0.5em 1em; border: 1px solid #ddb; padding: 7px 7px 0 7px; diff --git a/sphinx/themes/pyramid/static/pyramid.css_t b/sphinx/themes/pyramid/static/pyramid.css_t index b7fed2943..f093ba164 100644 --- a/sphinx/themes/pyramid/static/pyramid.css_t +++ b/sphinx/themes/pyramid/static/pyramid.css_t @@ -155,7 +155,7 @@ div.sphinxsidebar .searchformwrapper { /* -- sidebars -------------------------------------------------------------- */ -div.sidebar { +div.sidebar, aside.sidebar { margin: 0 0 0.5em 1em; border: 2px solid #c6d880; background-color: #e6efc2; From bc6571a67b9a95af23f2689d375c4517782891ae Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 31 May 2022 17:06:51 +0100 Subject: [PATCH 03/18] Add a meta node to fix iteration --- sphinx/ext/ifconfig.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sphinx/ext/ifconfig.py b/sphinx/ext/ifconfig.py index bffaa49ff..202bee533 100644 --- a/sphinx/ext/ifconfig.py +++ b/sphinx/ext/ifconfig.py @@ -20,6 +20,7 @@ from docutils import nodes from docutils.nodes import Node import sphinx +from sphinx import addnodes from sphinx.application import Sphinx from sphinx.util.docutils import SphinxDirective from sphinx.util.nodes import nested_parse_with_titles @@ -64,7 +65,7 @@ def process_ifconfig_nodes(app: Sphinx, doctree: nodes.document, docname: str) - node.replace_self(newnode) else: if not res: - node.replace_self([]) + node.replace_self(addnodes.meta()) else: node.replace_self(node.children) From d066d23067480f7ce1f02ed9c802906289413b0d Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 31 May 2022 17:12:17 +0100 Subject: [PATCH 04/18] Add a test --- tests/roots/test-ext-ifconfig/conf.py | 1 + tests/roots/test-ext-ifconfig/index.rst | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/tests/roots/test-ext-ifconfig/conf.py b/tests/roots/test-ext-ifconfig/conf.py index 565f6bcb3..e82ec79f2 100644 --- a/tests/roots/test-ext-ifconfig/conf.py +++ b/tests/roots/test-ext-ifconfig/conf.py @@ -7,3 +7,4 @@ confval1 = True def setup(app): app.add_config_value('confval1', False, None) app.add_config_value('confval2', False, None) + app.add_config_value('false_config', False, None) diff --git a/tests/roots/test-ext-ifconfig/index.rst b/tests/roots/test-ext-ifconfig/index.rst index ab08aabef..594d88542 100644 --- a/tests/roots/test-ext-ifconfig/index.rst +++ b/tests/roots/test-ext-ifconfig/index.rst @@ -9,3 +9,13 @@ ifconfig egg +Issue 10496 regression test +=========================== + +.. ifconfig:: false_config + + `Link 1 `__ + +.. ifconfig:: false_config + + `Link 2 `__ From 9fad9d98c2883e6781972060c28c17281274370c Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 31 May 2022 17:15:19 +0100 Subject: [PATCH 05/18] Fix fake link in test --- tests/roots/test-ext-ifconfig/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/roots/test-ext-ifconfig/index.rst b/tests/roots/test-ext-ifconfig/index.rst index 594d88542..f7fabcc78 100644 --- a/tests/roots/test-ext-ifconfig/index.rst +++ b/tests/roots/test-ext-ifconfig/index.rst @@ -18,4 +18,4 @@ Issue 10496 regression test .. ifconfig:: false_config - `Link 2 `__ + `Link 2 `__ From bca9e48348706bb67ef40ec920ec554238ca0d87 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 31 May 2022 18:24:17 +0100 Subject: [PATCH 06/18] Ensure positions always sort --- sphinx/builders/gettext.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py index 0d7d0ac11..0f38ea7f5 100644 --- a/sphinx/builders/gettext.py +++ b/sphinx/builders/gettext.py @@ -57,7 +57,7 @@ class Catalog: def __iter__(self) -> Generator[Message, None, None]: for message in self.messages: - positions = sorted(set((source, line) for source, line, uuid + positions = sorted(set((source, line or -1) for source, line, uuid in self.metadata[message])) uuids = [uuid for source, line, uuid in self.metadata[message]] yield Message(message, positions, uuids) From 34a82968597ea581b3f251aa9147a8e6e438fda3 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 31 May 2022 18:37:28 +0100 Subject: [PATCH 07/18] Add a warning --- sphinx/builders/gettext.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py index 0f38ea7f5..4aa3cf5d4 100644 --- a/sphinx/builders/gettext.py +++ b/sphinx/builders/gettext.py @@ -53,11 +53,15 @@ class Catalog: if msg not in self.metadata: # faster lookup in hash self.messages.append(msg) self.metadata[msg] = [] - self.metadata[msg].append((origin.source, origin.line, origin.uid)) # type: ignore + line = origin.line + if line is None: + logger.warning(f"Node {origin!r} has no line number, using '-1'.") + line = -1 + self.metadata[msg].append((origin.source, line, origin.uid)) # type: ignore def __iter__(self) -> Generator[Message, None, None]: for message in self.messages: - positions = sorted(set((source, line or -1) for source, line, uuid + positions = sorted(set((source, line) for source, line, uuid in self.metadata[message])) uuids = [uuid for source, line, uuid in self.metadata[message]] yield Message(message, positions, uuids) From 04b84e82a019b12d79519082d79e6636238b31a7 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Wed, 1 Jun 2022 00:31:12 +0100 Subject: [PATCH 08/18] Fix `findall` usage in KeyboardTransform --- sphinx/builders/html/transforms.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sphinx/builders/html/transforms.py b/sphinx/builders/html/transforms.py index ea596cb4b..7f96c4e60 100644 --- a/sphinx/builders/html/transforms.py +++ b/sphinx/builders/html/transforms.py @@ -40,7 +40,10 @@ class KeyboardTransform(SphinxPostTransform): def run(self, **kwargs: Any) -> None: matcher = NodeMatcher(nodes.literal, classes=["kbd"]) - for node in self.document.findall(matcher): # type: nodes.literal + # this list must be pre-created as during iteration new nodes + # are added which match the condition in the NodeMatcher. + nodes_to_expand = list(self.document.findall(matcher)) + for node in nodes_to_expand: # type: nodes.literal parts = self.pattern.split(node[-1].astext()) if len(parts) == 1 or self.is_multiwords_key(parts): continue @@ -61,6 +64,7 @@ class KeyboardTransform(SphinxPostTransform): node += nodes.Text(sep) except IndexError: pass + _a = 1 def is_multiwords_key(self, parts: List[str]) -> bool: if len(parts) >= 3 and parts[1].strip() == '': From 23a4b614157b3e69d4f43075dc6cacd05fecf3b9 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Wed, 1 Jun 2022 00:35:28 +0100 Subject: [PATCH 09/18] Add a test --- .../test-transforms-post_transforms-keyboard/conf.py | 0 .../test-transforms-post_transforms-keyboard/index.rst | 4 ++++ tests/test_transforms_post_transforms.py | 8 ++++++++ 3 files changed, 12 insertions(+) create mode 100644 tests/roots/test-transforms-post_transforms-keyboard/conf.py create mode 100644 tests/roots/test-transforms-post_transforms-keyboard/index.rst diff --git a/tests/roots/test-transforms-post_transforms-keyboard/conf.py b/tests/roots/test-transforms-post_transforms-keyboard/conf.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/roots/test-transforms-post_transforms-keyboard/index.rst b/tests/roots/test-transforms-post_transforms-keyboard/index.rst new file mode 100644 index 000000000..76c5c584e --- /dev/null +++ b/tests/roots/test-transforms-post_transforms-keyboard/index.rst @@ -0,0 +1,4 @@ +Regression test for issue 10495 +=============================== + +:kbd:`test - test` diff --git a/tests/test_transforms_post_transforms.py b/tests/test_transforms_post_transforms.py index 272d83e3a..73cd66758 100644 --- a/tests/test_transforms_post_transforms.py +++ b/tests/test_transforms_post_transforms.py @@ -48,3 +48,11 @@ def test_missing_reference_conditional_pending_xref(app, status, warning): content = (app.outdir / 'index.html').read_text(encoding='utf8') assert 'Age' in content + + +@pytest.mark.sphinx('html', testroot='transforms-post_transforms-keyboard', + freshenv=True) +def test_keyboard_issue_10495(app): + """Regression test for issue 10495, we want no crash.""" + app.build() + assert "blah" in (app.outdir / 'index.html').read_text(encoding='utf8') From 244ab1c015ff869fbe0757d5cb872c5bf9a2d656 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Wed, 1 Jun 2022 00:38:55 +0100 Subject: [PATCH 10/18] Add annotation --- sphinx/builders/html/transforms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/builders/html/transforms.py b/sphinx/builders/html/transforms.py index 7f96c4e60..a2944c017 100644 --- a/sphinx/builders/html/transforms.py +++ b/sphinx/builders/html/transforms.py @@ -42,7 +42,7 @@ class KeyboardTransform(SphinxPostTransform): matcher = NodeMatcher(nodes.literal, classes=["kbd"]) # this list must be pre-created as during iteration new nodes # are added which match the condition in the NodeMatcher. - nodes_to_expand = list(self.document.findall(matcher)) + nodes_to_expand: List[nodes.literal] = list(self.document.findall(matcher)) for node in nodes_to_expand: # type: nodes.literal parts = self.pattern.split(node[-1].astext()) if len(parts) == 1 or self.is_multiwords_key(parts): From 6aa2d05111168ea93a82719b3fa99fd203924bb2 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Wed, 1 Jun 2022 00:39:35 +0100 Subject: [PATCH 11/18] Remove temp variable --- sphinx/builders/html/transforms.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sphinx/builders/html/transforms.py b/sphinx/builders/html/transforms.py index a2944c017..940b0c0d8 100644 --- a/sphinx/builders/html/transforms.py +++ b/sphinx/builders/html/transforms.py @@ -64,7 +64,6 @@ class KeyboardTransform(SphinxPostTransform): node += nodes.Text(sep) except IndexError: pass - _a = 1 def is_multiwords_key(self, parts: List[str]) -> bool: if len(parts) >= 3 and parts[1].strip() == '': From 91f90a5fb5c7c4e412d966582266f20bbadd46d2 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Wed, 1 Jun 2022 00:50:41 +0100 Subject: [PATCH 12/18] Fix test --- tests/roots/test-transforms-post_transforms-keyboard/index.rst | 2 +- tests/test_transforms_post_transforms.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/roots/test-transforms-post_transforms-keyboard/index.rst b/tests/roots/test-transforms-post_transforms-keyboard/index.rst index 76c5c584e..21775782f 100644 --- a/tests/roots/test-transforms-post_transforms-keyboard/index.rst +++ b/tests/roots/test-transforms-post_transforms-keyboard/index.rst @@ -1,4 +1,4 @@ Regression test for issue 10495 =============================== -:kbd:`test - test` +:kbd:`spanish - inquisition` diff --git a/tests/test_transforms_post_transforms.py b/tests/test_transforms_post_transforms.py index 73cd66758..ebd505776 100644 --- a/tests/test_transforms_post_transforms.py +++ b/tests/test_transforms_post_transforms.py @@ -55,4 +55,5 @@ def test_missing_reference_conditional_pending_xref(app, status, warning): def test_keyboard_issue_10495(app): """Regression test for issue 10495, we want no crash.""" app.build() - assert "blah" in (app.outdir / 'index.html').read_text(encoding='utf8') + assert "spanish" in (app.outdir / 'index.html').read_text(encoding='utf8') + assert "inquisition" in (app.outdir / 'index.html').read_text(encoding='utf8') From efdbe06eea67cba57532160a1eb80aaac2241d50 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Wed, 1 Jun 2022 18:10:55 +0100 Subject: [PATCH 13/18] Review comments --- sphinx/builders/html/transforms.py | 3 +-- tests/test_transforms_post_transforms.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sphinx/builders/html/transforms.py b/sphinx/builders/html/transforms.py index 940b0c0d8..1ba6ba857 100644 --- a/sphinx/builders/html/transforms.py +++ b/sphinx/builders/html/transforms.py @@ -42,8 +42,7 @@ class KeyboardTransform(SphinxPostTransform): matcher = NodeMatcher(nodes.literal, classes=["kbd"]) # this list must be pre-created as during iteration new nodes # are added which match the condition in the NodeMatcher. - nodes_to_expand: List[nodes.literal] = list(self.document.findall(matcher)) - for node in nodes_to_expand: # type: nodes.literal + for node in list(self.document.findall(matcher)): # type: nodes.literal parts = self.pattern.split(node[-1].astext()) if len(parts) == 1 or self.is_multiwords_key(parts): continue diff --git a/tests/test_transforms_post_transforms.py b/tests/test_transforms_post_transforms.py index ebd505776..215e6d14f 100644 --- a/tests/test_transforms_post_transforms.py +++ b/tests/test_transforms_post_transforms.py @@ -52,7 +52,7 @@ def test_missing_reference_conditional_pending_xref(app, status, warning): @pytest.mark.sphinx('html', testroot='transforms-post_transforms-keyboard', freshenv=True) -def test_keyboard_issue_10495(app): +def test_keyboard_hyphen_spaces(app): """Regression test for issue 10495, we want no crash.""" app.build() assert "spanish" in (app.outdir / 'index.html').read_text(encoding='utf8') From a1ecf99b9fb75bfb74d891716958666d497bd153 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Wed, 1 Jun 2022 18:45:48 +0100 Subject: [PATCH 14/18] Remove warning --- sphinx/builders/gettext.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py index 4aa3cf5d4..92edcc9f2 100644 --- a/sphinx/builders/gettext.py +++ b/sphinx/builders/gettext.py @@ -55,7 +55,6 @@ class Catalog: self.metadata[msg] = [] line = origin.line if line is None: - logger.warning(f"Node {origin!r} has no line number, using '-1'.") line = -1 self.metadata[msg].append((origin.source, line, origin.uid)) # type: ignore From d6d2a403450e022f5b91323a367fdc5539f7c525 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 2 Jun 2022 02:56:59 +0900 Subject: [PATCH 15/18] Update CHANGES for PR #10503 --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index d962f8f89..dd8e82f1e 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,9 @@ Features added Bugs fixed ---------- +* #10498: gettext: TypeError is raised when sorting warning messages if a node + has no line number + Testing -------- From 28f9ce78b0074c70a3b849c7f9eb7a4dabf6bece Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 3 Jun 2022 01:05:41 +0900 Subject: [PATCH 16/18] Update CHANGES for PR #10493 --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index dd8e82f1e..8c0e3af6a 100644 --- a/CHANGES +++ b/CHANGES @@ -18,6 +18,8 @@ Bugs fixed * #10498: gettext: TypeError is raised when sorting warning messages if a node has no line number +* #10493: html theme: :rst:dir:`topic` directive is rendered incorrectly with + docutils-0.18 Testing -------- From 2a50b2e5a3b76d708dfb61d46bd78847353189a7 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 3 Jun 2022 01:22:16 +0900 Subject: [PATCH 17/18] Update CHANGES for PR #10504 --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index 8c0e3af6a..0e8a504b1 100644 --- a/CHANGES +++ b/CHANGES @@ -20,6 +20,7 @@ Bugs fixed has no line number * #10493: html theme: :rst:dir:`topic` directive is rendered incorrectly with docutils-0.18 +* #10495: IndexError is raised for a :rst:role:`kbd` role having a separator Testing -------- From c4458e3adbcffced2248fb3d05a283e1754d3b7c Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 3 Jun 2022 02:01:01 +0900 Subject: [PATCH 18/18] ifconfig: Do not use a meta node for noop --- sphinx/ext/ifconfig.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sphinx/ext/ifconfig.py b/sphinx/ext/ifconfig.py index 202bee533..f0d115077 100644 --- a/sphinx/ext/ifconfig.py +++ b/sphinx/ext/ifconfig.py @@ -20,7 +20,6 @@ from docutils import nodes from docutils.nodes import Node import sphinx -from sphinx import addnodes from sphinx.application import Sphinx from sphinx.util.docutils import SphinxDirective from sphinx.util.nodes import nested_parse_with_titles @@ -52,7 +51,7 @@ def process_ifconfig_nodes(app: Sphinx, doctree: nodes.document, docname: str) - ns = {confval.name: confval.value for confval in app.config} ns.update(app.config.__dict__.copy()) ns['builder'] = app.builder.name - for node in doctree.findall(ifconfig): + for node in list(doctree.findall(ifconfig)): try: res = eval(node['expr'], ns) except Exception as err: @@ -65,7 +64,7 @@ def process_ifconfig_nodes(app: Sphinx, doctree: nodes.document, docname: str) - node.replace_self(newnode) else: if not res: - node.replace_self(addnodes.meta()) + node.replace_self([]) else: node.replace_self(node.children)