From 44684e165426470e8e8befa45e32d1b0b2f6302e Mon Sep 17 00:00:00 2001 From: Jeremy Maitin-Shepard Date: Tue, 14 Feb 2023 21:26:10 -0800 Subject: [PATCH] Restore correct parallel search index building (#11192) Revert b32841e153431ec02de31e9ec32e79ab3ac7d1c2 to fix parallel search index building The image-related changes were already reverted in 2a7c40d07f4b0e0fd2a4bc942e74634c2df24dee, but the search index changes also need to be reverted. It would be nice to support parallel search index building, but the necessary support for merging the search indices produced by each process needs to be added first. --- sphinx/builders/html/__init__.py | 7 +++---- tests/test_search.py | 7 +++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py index 4b067eadb7c..81fac5870e1 100644 --- a/sphinx/builders/html/__init__.py +++ b/sphinx/builders/html/__init__.py @@ -655,10 +655,6 @@ def get_doc_context(self, docname: str, body: str, metatags: str) -> dict[str, A } def write_doc(self, docname: str, doctree: nodes.document) -> None: - title_node = self.env.longtitles.get(docname) - title = self.render_partial(title_node)['title'] if title_node else '' - self.index_page(docname, doctree, title) - destination = StringOutput(encoding='utf-8') doctree.settings = self.docsettings @@ -678,6 +674,9 @@ def write_doc(self, docname: str, doctree: nodes.document) -> None: def write_doc_serialized(self, docname: str, doctree: nodes.document) -> None: self.imgpath = relative_uri(self.get_target_uri(docname), self.imagedir) self.post_process_images(doctree) + title_node = self.env.longtitles.get(docname) + title = self.render_partial(title_node)['title'] if title_node else '' + self.index_page(docname, doctree, title) def finish(self) -> None: self.finish_tasks.add_task(self.gen_indices) diff --git a/tests/test_search.py b/tests/test_search.py index 0fafa297553..d0172df6bbc 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -286,3 +286,10 @@ def test_nosearch(app): assert 'latex' not in index['terms'] assert 'zfs' in index['terms'] assert index['terms']['zfs'] == [] # zfs on nosearch.rst is not registered to index + + +@pytest.mark.sphinx(testroot='search', parallel=3, freshenv=True) +def test_parallel(app): + app.build() + index = load_searchindex(app.outdir / 'searchindex.js') + assert index['docnames'] == ['index', 'nosearch', 'tocitem']