Skip to content

Commit

Permalink
Merge pull request #112 from rscohn2/master
Browse files Browse the repository at this point in the history
  • Loading branch information
humitos authored Oct 1, 2020
2 parents 0a842c0 + be0e512 commit 842ff84
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 0 deletions.
7 changes: 7 additions & 0 deletions notfound/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
11 changes: 11 additions & 0 deletions tests/examples/parallel-build/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
Sample ``conf.py``.
"""

master_doc = 'index'

extensions = [
'notfound.extension',
]


4 changes: 4 additions & 0 deletions tests/examples/parallel-build/five.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
=======
Five
=======

4 changes: 4 additions & 0 deletions tests/examples/parallel-build/four.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
=======
Four
=======

17 changes: 17 additions & 0 deletions tests/examples/parallel-build/index.rst
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions tests/examples/parallel-build/one.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
=====
One
=====

4 changes: 4 additions & 0 deletions tests/examples/parallel-build/three.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
=======
Three
=======

4 changes: 4 additions & 0 deletions tests/examples/parallel-build/two.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
=====
Two
=====

7 changes: 7 additions & 0 deletions tests/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest
import sphinx
import shutil
import subprocess
import warnings

srcdir = os.path.join(
Expand All @@ -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()
Expand Down

0 comments on commit 842ff84

Please sign in to comment.