tests.sphinx.test_sphinx_parallel moduleΒΆ

Tests for the fixes that make a parallel read index what a serial read indexes.

List the [docs] links of the viewcode pages that reach no anchor.

Return type:

list[str]

tests.sphinx.test_sphinx_parallel.GRAPE = 'vineyard.grape.Grape'ΒΆ

The name of a class under the path of the module that defines it.

tests.sphinx.test_sphinx_parallel.GRAPE_DEFINITION = ('grape', 'vineyard.grape.Grape', 'class', False)ΒΆ

The entry that the page of the module registers for the class.

tests.sphinx.test_sphinx_parallel.GRAPE_ALIAS = ('vineyard', 'vineyard.Grape', 'class', True)ΒΆ

The entry that a page re-exporting the class registers through :canonical:.

tests.sphinx.test_sphinx_parallel.merge_worker(env, docnames, objects)[source]ΒΆ

Merge a worker that read docnames and holds objects, as Sphinx does.

Runs the merge of PythonDomain, then the hook, which is the order BuildEnvironment.merge_info_from follows for each worker of a parallel read.

Return type:

None

tests.sphinx.test_sphinx_parallel.test_parallel_merge_keeps_the_definition_over_an_alias(definition_first)[source]ΒΆ

A definition stays indexed, whichever worker merges first.

PythonDomain.merge_domaindata copies the entries of each worker over the ones in place, so an alias merged after the definition replaces it. A serial read keeps the definition.

tests.sphinx.test_sphinx_parallel.test_a_read_forgets_the_definitions_of_the_last_one()[source]ΒΆ

A definition merged in one build never comes back in the next one.

tests.sphinx.test_sphinx_parallel.TERROIR_MODULES = {'__init__.py': 'from terroir.grape import Grape, Vine\n\n__all__ = ["Grape", "Vine"]\n', 'cellar.py': '"""Wine that takes its time."""\n\nimport time\n\ntime.sleep(1)\n', 'grape.py': 'class Grape:\n    """A grape of the terroir."""\n\n\nclass Vine:\n    """A vine of the terroir."""\n\n\ndef press():\n    """Press the grapes."""\n'}ΒΆ

A package re-exporting both classes of its grape module, but not press.

The page of the package also documents cellar, whose import takes a second, so the worker that reads that page merges after the worker that reads grape.

A parallel read points each [docs] link at an anchor, as a serial read does.

The page of the package documents Grape and Vine with a :canonical: alias to terroir.grape. Merged after the page of grape, those aliases replace its definitions, unless the extension puts them back. The root path then indexes more objects of grape than its own path does, and the link of press, which the package does not re-export, leads under the root path.

tests.sphinx.test_sphinx_parallel.BASKET_MODULE = 'from __future__ import annotations\n\nTYPE_CHECKING = False\nif TYPE_CHECKING:\n    from typing import TypeAlias\n\n    Fruits: TypeAlias = "tuple[str, ...]"\n    """Fruits a basket holds."""\n\n\nclass Basket:\n    """A basket of fruits."""\n\n    def __init__(self, *fruits: str) -> None:\n        """Fill the basket."""\n        self.fruits: tuple[str, ...] = fruits\n'ΒΆ

A module annotating two names that only its source holds.

Fruits sits in a TYPE_CHECKING block, and Basket.fruits in __init__.

tests.sphinx.test_sphinx_parallel.test_a_page_read_first_lists_its_annotated_members(tmp_path, monkeypatch)[source]ΒΆ

A page lists the names its module annotates, whatever autodoc read before.

autodoc copies the annotations of the source into the module and its classes only when it documents an attribute of the module, then lists each annotated name as a member. Without the copy made in advance, a page read before any such attribute, like the first page of a parallel worker, lists neither name.

tests.sphinx.test_sphinx_parallel.CRATE_MODULE = 'from typing import TypedDict\n\n\nclass _Fields(TypedDict, total=False):\n    weight: int\n    """How heavy the crate is."""\n\n\nclass Crate(_Fields, total=False):\n    """A crate of fruits."""\n\n    color: str\n    """The color of the crate."""\n'ΒΆ

A module whose TypedDict takes a field from a private base.

Without from __future__ import annotations, Python 3.14 and later evaluate the annotations of a class lazily, through its __annotate__.

tests.sphinx.test_sphinx_parallel.test_copied_annotations_keep_the_fields_of_a_typeddict_base(tmp_path, monkeypatch)[source]ΒΆ

A TypedDict still lists the fields of its base once its module is annotated.

Assigning a new __annotations__ to the base, rather than filling the one in place, clears its __annotate__ from Python 3.14 on, and Crate then reads its own field alone.