diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8ab4ae8f..6625375e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,7 +41,6 @@ jobs: - name: Run pytest run: > pytest --durations=10 --cov=sphinx_book_theme --cov-report=xml --cov-report=term-missing - - name: Upload to Codecov if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.7 && github.repository == 'executablebooks/sphinx-book-theme' uses: codecov/codecov-action@v1 diff --git a/sphinx_book_theme/__init__.py b/sphinx_book_theme/__init__.py index 85c0eb5e..c4ccdc32 100644 --- a/sphinx_book_theme/__init__.py +++ b/sphinx_book_theme/__init__.py @@ -386,3 +386,8 @@ def setup(app: Sphinx): app.connect("html-page-context", add_to_context) app.add_directive("margin", Margin) + + return { + "parallel_read_safe": True, + "parallel_write_safe": True, + } diff --git a/tests/sites/parallel-build/Makefile b/tests/sites/parallel-build/Makefile new file mode 100644 index 00000000..764cdb06 --- /dev/null +++ b/tests/sites/parallel-build/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= -j auto +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/tests/sites/parallel-build/conf.py b/tests/sites/parallel-build/conf.py new file mode 100644 index 00000000..ae8fabb4 --- /dev/null +++ b/tests/sites/parallel-build/conf.py @@ -0,0 +1,5 @@ +""" +Sample ``conf.py``. +""" + +html_theme = "sphinx_book_theme" diff --git a/tests/sites/parallel-build/five.rst b/tests/sites/parallel-build/five.rst new file mode 100644 index 00000000..afa18b90 --- /dev/null +++ b/tests/sites/parallel-build/five.rst @@ -0,0 +1,3 @@ +======= + Five +======= diff --git a/tests/sites/parallel-build/four.rst b/tests/sites/parallel-build/four.rst new file mode 100644 index 00000000..d7d1fb2b --- /dev/null +++ b/tests/sites/parallel-build/four.rst @@ -0,0 +1,3 @@ +======= + Four +======= diff --git a/tests/sites/parallel-build/index.rst b/tests/sites/parallel-build/index.rst new file mode 100644 index 00000000..5c7cafc7 --- /dev/null +++ b/tests/sites/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/sites/parallel-build/one.rst b/tests/sites/parallel-build/one.rst new file mode 100644 index 00000000..9933978c --- /dev/null +++ b/tests/sites/parallel-build/one.rst @@ -0,0 +1,3 @@ +===== + One +===== diff --git a/tests/sites/parallel-build/three.rst b/tests/sites/parallel-build/three.rst new file mode 100644 index 00000000..c3a96057 --- /dev/null +++ b/tests/sites/parallel-build/three.rst @@ -0,0 +1,3 @@ +======= + Three +======= diff --git a/tests/sites/parallel-build/two.rst b/tests/sites/parallel-build/two.rst new file mode 100644 index 00000000..87d368ca --- /dev/null +++ b/tests/sites/parallel-build/two.rst @@ -0,0 +1,3 @@ +===== + Two +===== diff --git a/tests/test_build.py b/tests/test_build.py index 22af0368..aada4c89 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -1,6 +1,7 @@ import os from pathlib import Path from shutil import copytree +from subprocess import check_call from bs4 import BeautifulSoup import pytest @@ -53,6 +54,15 @@ def _func(src_folder, **kwargs): yield _func +def test_parallel_build(): + # We cannot use the sphinx_build_factory because SpinxTestApp does + # not have a way to pass parallel=2 to the Sphinx constructor + # https://github.com/sphinx-doc/sphinx/blob/d8c006f1c0e612d0dc595ae463b8e4c3ebee5ca4/sphinx/testing/util.py#L101 + check_call( + "sphinx-build -j 2 -W -b html tests/sites/parallel-build build", shell=True + ) + + def test_build_book(sphinx_build_factory, file_regression): """Test building the base book template and config.""" sphinx_build = sphinx_build_factory("base") # type: SphinxBuild