diff --git a/notfound/extension.py b/notfound/extension.py index e7161ee..5c1228c 100644 --- a/notfound/extension.py +++ b/notfound/extension.py @@ -194,6 +194,13 @@ def process_doc(self, app, doctree): if sphinx.version_info >= (3, 0, 0): metadata.update({'nosearch': True}) + def merge_other(self, app, env, docnames, other): + """Merge in specified data regarding docnames from a different `BuildEnvironment` + object which coming from a subprocess in parallel builds.""" + # TODO: find an example about why this is strictly required for parallel read + # https://github.com/readthedocs/sphinx-notfound-page/pull/112/files#r498219556 + env.metadata.update(other.metadata) + def handle_deprecated_configs(app, *args, **kwargs): """ diff --git a/tests/examples/parallel-build/conf.py b/tests/examples/parallel-build/conf.py new file mode 100644 index 0000000..3485726 --- /dev/null +++ b/tests/examples/parallel-build/conf.py @@ -0,0 +1,11 @@ +""" +Sample ``conf.py``. +""" + +master_doc = 'index' + +extensions = [ + 'notfound.extension', +] + + diff --git a/tests/examples/parallel-build/five.rst b/tests/examples/parallel-build/five.rst new file mode 100644 index 0000000..b03139a --- /dev/null +++ b/tests/examples/parallel-build/five.rst @@ -0,0 +1,4 @@ +======= + Five +======= + diff --git a/tests/examples/parallel-build/four.rst b/tests/examples/parallel-build/four.rst new file mode 100644 index 0000000..e6ed1be --- /dev/null +++ b/tests/examples/parallel-build/four.rst @@ -0,0 +1,4 @@ +======= + Four +======= + diff --git a/tests/examples/parallel-build/index.rst b/tests/examples/parallel-build/index.rst new file mode 100644 index 0000000..5c7cafc --- /dev/null +++ b/tests/examples/parallel-build/index.rst @@ -0,0 +1,17 @@ +Samples for substitution directives +=================================== + +.. + + This is a test of parallel document builds. You need at least 5 + documents. See: + https://github.com/adamtheturtle/sphinx-substitution-extensions/pull/173 + +.. toctree:: + :hidden: + + one + two + three + four + five diff --git a/tests/examples/parallel-build/one.rst b/tests/examples/parallel-build/one.rst new file mode 100644 index 0000000..a5525d2 --- /dev/null +++ b/tests/examples/parallel-build/one.rst @@ -0,0 +1,4 @@ +===== + One +===== + diff --git a/tests/examples/parallel-build/three.rst b/tests/examples/parallel-build/three.rst new file mode 100644 index 0000000..1e4126d --- /dev/null +++ b/tests/examples/parallel-build/three.rst @@ -0,0 +1,4 @@ +======= + Three +======= + diff --git a/tests/examples/parallel-build/two.rst b/tests/examples/parallel-build/two.rst new file mode 100644 index 0000000..ff1cabd --- /dev/null +++ b/tests/examples/parallel-build/two.rst @@ -0,0 +1,4 @@ +===== + Two +===== + diff --git a/tests/test_urls.py b/tests/test_urls.py index 9f8e028..3e0d0f3 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -4,6 +4,7 @@ import pytest import sphinx import shutil +import subprocess import warnings srcdir = os.path.join( @@ -27,6 +28,12 @@ def remove_sphinx_build_output(): shutil.rmtree(build_path) +@pytest.mark.sphinx(srcdir=srcdir) +def test_parallel_build(): + # TODO: migrate to `app.build(..., parallel=2)` after merging + # https://github.com/sphinx-doc/sphinx/pull/8257 + subprocess.check_call('sphinx-build -j 2 -W -b html tests/examples/parallel-build build', shell=True) + @pytest.mark.sphinx(srcdir=srcdir) def test_404_page_created(app, status, warning): app.build()