From fe3dea2e7b32f34ac623f43b6d8c669313432404 Mon Sep 17 00:00:00 2001 From: Tobias Kaestner Date: Fri, 9 Oct 2026 16:15:24 +0200 Subject: [PATCH] refactor: sphinx: move the plain modules to _scripts sphinx/_extensions held two kinds of module: Sphinx extensions, each with a setup(), and plain modules that the extensions share. adequacy, doxygen_parser, needs_fields, rst_builders and twister_reader have no setup() and are never in the extension list. Move them to sphinx/_scripts, as the safety docset did with its own doc/_extensions and doc/_scripts. zdocs_conf.py and the API document put both folders on sys.path; module names do not change. The unit tests split the same way. sphinx/_scripts/_tests holds the tests that import only _scripts modules (doxygen_parser, rst_builders, twister_reader). A test that imports an extension stays in sphinx/_extensions/_tests, also test_adequacy, which tests the testcoverage directive too. The fixtures of both are now in sphinx/_fixtures, and each test file computes that path itself: two conftest modules make "from conftest import" ambiguous. pytest.ini at the root loads the sphinx.testing plugin and selects both folders, so "python3 -m pytest -q" runs all 403 tests. pytest accepts pytest_plugins only in a top-level conftest, which neither one is in a run of both. Each folder still runs alone. The API reference gets a page for the moved modules. README, ADR 0003, the test how-to and the architecture page give the new layout. Unit 403 (88 + 315), acceptance 321/321, zdocs docs 0 warnings. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Tobias Kaestner --- .pre-commit-config.yaml | 2 +- .ruff.toml | 1 + README.rst | 8 ++- doc/api/conf.py | 1 + doc/api/python/extensions.rst | 52 +----------------- doc/api/python/index.rst | 1 + doc/api/python/support-modules.rst | 55 +++++++++++++++++++ .../architecture/building-blocks.rst | 11 +++- .../decisions/0003-engine-unit-suite.rst | 7 ++- doc/manual/howto/run-the-test-suites.rst | 10 ++-- pytest.ini | 13 +++++ sphinx/_extensions/_tests/conftest.py | 14 +++-- .../_tests/roots/test-symbolneeds/conf.py | 2 +- .../roots/test-testmodule-mapping/conf.py | 2 +- .../test-testmodule-partial-mapping/conf.py | 2 +- .../roots/test-testmodule-qualifier/conf.py | 2 +- .../_tests/roots/test-testmodule/conf.py | 2 +- .../roots/test-testreport-depends/conf.py | 2 +- .../roots/test-testreport-mapping/conf.py | 2 +- .../roots/test-testreport-param/conf.py | 2 +- .../_tests/roots/test-testreport-path/conf.py | 2 +- .../_tests/roots/test-testreport/conf.py | 2 +- .../_tests/test_kconfig_depends.py | 3 +- .../_tests/test_suite_qualifier.py | 3 +- .../_extensions/_tests/test_symbol_needs.py | 3 +- sphinx/_extensions/_tests/test_test_module.py | 3 +- .../_tests/test_testreport_depends.py | 3 +- .../_tests/test_testreport_param.py | 3 +- .../_tests/test_testreport_path.py | 3 +- .../doxygen-kconfig/Doxyfile | 0 .../doxygen-kconfig/group__kd__suite.xml | 0 .../doxygen-kconfig/index.xml | 0 .../doxygen-kconfig/kd.c | 0 .../group__m1____workqueue__api.xml | 0 .../doxygen-qualifier/group__m1__module.xml | 0 .../group__m2____workqueue__api.xml | 0 .../doxygen-qualifier/group__m2__module.xml | 0 .../doxygen-qualifier/index.xml | 0 .../doxygen-symbols/Doxyfile | 0 .../doxygen-symbols/group__queue__apis.xml | 0 .../doxygen-symbols/index.xml | 0 .../doxygen-symbols/queue.h | 0 .../doxygen-symbols/queue_8h.xml | 0 .../doxygen-symbols/req.dox | 0 .../doxygen-symbols/req_8dox.xml | 0 .../doxygen/group__kernel__queue__module.xml | 0 .../doxygen/group__queue__api.xml | 0 .../doxygen/group__queue__procedures.xml | 0 .../fixtures => _fixtures}/doxygen/index.xml | 0 .../fixtures => _fixtures}/needs/needs.json | 0 .../demo/kernel.demo.big/zephyr/.config | 0 .../kernel/demo/kernel.demo/zephyr/.config | 0 .../twister-depends/needs.json | 0 .../demo/kernel.demo.soak/zephyr/.config | 0 .../kernel/demo/kernel.demo/zephyr/.config | 0 .../twister-depends/twister.json | 0 .../twister-depends/twister_report.xml | 0 .../twister-param/needs.json | 0 .../twister-param/twister.json | 0 .../twister-param/twister_report.xml | 0 .../twister-path/needs.json | 0 .../twister-path/twister.json | 0 .../twister-path/twister_report.xml | 0 .../kernel/queue/kernel.queue/handler.log | 0 .../twister/twister.json | 0 .../twister/twister_report.xml | 0 sphinx/_scripts/_tests/conftest.py | 32 +++++++++++ .../_tests/test_doxygen_parser.py | 4 +- .../_tests/test_rst_builders.py | 5 +- .../_tests/test_twister_reader.py | 5 +- sphinx/{_extensions => _scripts}/adequacy.py | 0 .../doxygen_parser.py | 0 .../{_extensions => _scripts}/needs_fields.py | 0 .../{_extensions => _scripts}/rst_builders.py | 0 .../twister_reader.py | 0 sphinx/requirements-doc.txt | 2 +- sphinx/zdocs_conf.py | 11 ++-- 77 files changed, 182 insertions(+), 93 deletions(-) create mode 100644 doc/api/python/support-modules.rst create mode 100644 pytest.ini rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-kconfig/Doxyfile (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-kconfig/group__kd__suite.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-kconfig/index.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-kconfig/kd.c (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-qualifier/group__m1____workqueue__api.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-qualifier/group__m1__module.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-qualifier/group__m2____workqueue__api.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-qualifier/group__m2__module.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-qualifier/index.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-symbols/Doxyfile (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-symbols/group__queue__apis.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-symbols/index.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-symbols/queue.h (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-symbols/queue_8h.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-symbols/req.dox (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen-symbols/req_8dox.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen/group__kernel__queue__module.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen/group__queue__api.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen/group__queue__procedures.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/doxygen/index.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/needs/needs.json (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister-depends/mps2_an385/zephyr_gnu/tests/kernel/demo/kernel.demo.big/zephyr/.config (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister-depends/mps2_an385/zephyr_gnu/tests/kernel/demo/kernel.demo/zephyr/.config (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister-depends/needs.json (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister-depends/qemu_x86/zephyr_gnu/tests/kernel/demo/kernel.demo.soak/zephyr/.config (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister-depends/qemu_x86/zephyr_gnu/tests/kernel/demo/kernel.demo/zephyr/.config (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister-depends/twister.json (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister-depends/twister_report.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister-param/needs.json (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister-param/twister.json (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister-param/twister_report.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister-path/needs.json (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister-path/twister.json (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister-path/twister_report.xml (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister/qemu_cortex_m3_ti_lm3s6965/zephyr_gnu/tests/kernel/queue/kernel.queue/handler.log (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister/twister.json (100%) rename sphinx/{_extensions/_tests/fixtures => _fixtures}/twister/twister_report.xml (100%) create mode 100644 sphinx/_scripts/_tests/conftest.py rename sphinx/{_extensions => _scripts}/_tests/test_doxygen_parser.py (99%) rename sphinx/{_extensions => _scripts}/_tests/test_rst_builders.py (99%) rename sphinx/{_extensions => _scripts}/_tests/test_twister_reader.py (98%) rename sphinx/{_extensions => _scripts}/adequacy.py (100%) rename sphinx/{_extensions => _scripts}/doxygen_parser.py (100%) rename sphinx/{_extensions => _scripts}/needs_fields.py (100%) rename sphinx/{_extensions => _scripts}/rst_builders.py (100%) rename sphinx/{_extensions => _scripts}/twister_reader.py (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d754937..f96e820 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -56,7 +56,7 @@ repos: # Read-only structural checks. Nothing here rewrites a file. # # trailing-whitespace and end-of-file-fixer are intentionally absent: the - # twister and Doxygen fixtures under sphinx/_extensions/_tests/fixtures/ are + # twister and Doxygen fixtures under sphinx/_fixtures/ are # hand-crafted and compared byte for byte, and reStructuredText gives trailing # whitespace meaning in line blocks. Both hooks would edit those files. - repo: https://github.com/pre-commit/pre-commit-hooks diff --git a/.ruff.toml b/.ruff.toml index 7741d89..65e8693 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -15,6 +15,7 @@ target-version = "py310" exclude = [ "doc/_build", "sphinx/_extensions/_tests/roots/*/_build", + "sphinx/_scripts/_tests/roots/*/_build", ] [lint] diff --git a/README.rst b/README.rst index 41e3add..4cd3e8f 100644 --- a/README.rst +++ b/README.rst @@ -83,10 +83,12 @@ non-Python ``dot`` (Graphviz) dependency the architecture diagrams need. Tests ----- -Two suites, in two repositories. The engine's own unit suite covers the -pure-Python extensions and runs in about a second:: +Two suites, in two repositories. The engine's own unit suites cover the +Sphinx extensions (``sphinx/_extensions/_tests``) and the plain modules they +share (``sphinx/_scripts/_tests``). Both run in a few seconds; ``pytest.ini`` +selects them:: - $ python3 -m pytest sphinx/_extensions/_tests -q + $ python3 -m pytest -q The acceptance suite lives in a separate project that consumes zdocs the way a real one does, builds real documentation with real tools, and asserts on diff --git a/doc/api/conf.py b/doc/api/conf.py index 7a985e8..fb23cd7 100644 --- a/doc/api/conf.py +++ b/doc/api/conf.py @@ -15,6 +15,7 @@ ENGINE_ROOT = Path(os.environ["ZDOCS_CONF_DIR"]).resolve().parent sys.path.insert(0, str(ENGINE_ROOT / "sphinx" / "_extensions")) +sys.path.insert(0, str(ENGINE_ROOT / "sphinx" / "_scripts")) sys.path.insert(0, str(ENGINE_ROOT / "scripts")) configure( diff --git a/doc/api/python/extensions.rst b/doc/api/python/extensions.rst index c1f6c92..2d7a690 100644 --- a/doc/api/python/extensions.rst +++ b/doc/api/python/extensions.rst @@ -2,7 +2,8 @@ Sphinx extensions ================== Reference documentation for the modules under ``sphinx/_extensions/``: directives, roles and -builders loaded by :py:func:`zdocs_conf.configure`. See the companion +builders loaded by :py:func:`zdocs_conf.configure`. The plain modules they share are on +:doc:`support-modules`. See the companion manual's :external+zdocs-manual:doc:`Directives and roles ` page for how a document author uses each one. @@ -81,14 +82,6 @@ Re-reads a document when its sphinx-needs TOML file or the needs it imports chan .. automodule:: needs_config_state :members: -``needs_fields`` ------------------- - -Which optional need fields a consumer declared. - -.. automodule:: needs_fields - :members: - ``xref_builder`` ------------------ @@ -96,44 +89,3 @@ The stage-1 ``xref`` builder for the two-stage documentation build. .. automodule:: xref_builder :members: - -``doxygen_parser`` --------------------- - -Doxygen XML parsing, with no Sphinx dependency of its own. - -.. automodule:: doxygen_parser - :members: - -``rst_builders`` ------------------- - -RST string builders, with no Sphinx dependency of their own. - -.. automodule:: rst_builders - :members: - -``twister_reader`` --------------------- - -Twister output parsing, with no Sphinx dependency of its own. - -.. automodule:: twister_reader - :members: - :exclude-members: parse_twister_results - -``adequacy`` --------------- - -Coverage adequacy, with no Sphinx dependency of its own. - -.. automodule:: adequacy - :members: - -.. - parse_twister_results is excluded: its docstring's own example text, - "leading 'test_' prefix stripped", ends in a bare trailing underscore - directly after a word — reST's own "quoted hyperlink reference" syntax - (``word_``) — with no matching target, so autodoc turns it into - "Unknown target name: 'test'". A source defect, not a directive-option - fix; see the final report. diff --git a/doc/api/python/index.rst b/doc/api/python/index.rst index 543af5c..302d662 100644 --- a/doc/api/python/index.rst +++ b/doc/api/python/index.rst @@ -9,5 +9,6 @@ system. The API's for all of this can be found in the sub-sections below. :maxdepth: 1 extensions + support-modules scripts conf diff --git a/doc/api/python/support-modules.rst b/doc/api/python/support-modules.rst new file mode 100644 index 0000000..5481537 --- /dev/null +++ b/doc/api/python/support-modules.rst @@ -0,0 +1,55 @@ +Support modules +================ + +The plain Python modules that the Sphinx extensions share: parsers, RST +builders and the coverage logic. None of them is a Sphinx extension; none has +a ``setup()``. Source: ``sphinx/_scripts/``. + +``needs_fields`` +------------------ + +Which optional need fields a consumer declared. + +.. automodule:: needs_fields + :members: + +``doxygen_parser`` +-------------------- + +Doxygen XML parsing, with no Sphinx dependency of its own. + +.. automodule:: doxygen_parser + :members: + +``rst_builders`` +------------------ + +RST string builders, with no Sphinx dependency of their own. + +.. automodule:: rst_builders + :members: + +``twister_reader`` +-------------------- + +Twister output parsing, with no Sphinx dependency of its own. + +.. automodule:: twister_reader + :members: + :exclude-members: parse_twister_results + +``adequacy`` +-------------- + +Coverage adequacy, with no Sphinx dependency of its own. + +.. automodule:: adequacy + :members: + +.. + parse_twister_results is excluded: its docstring's own example text, + "leading 'test_' prefix stripped", ends in a bare trailing underscore + directly after a word — reST's own "quoted hyperlink reference" syntax + (``word_``) — with no matching target, so autodoc turns it into + "Unknown target name: 'test'". A source defect, not a directive-option + fix; see the final report. diff --git a/doc/manual/explanation/architecture/building-blocks.rst b/doc/manual/explanation/architecture/building-blocks.rst index 4f50d31..b4247cf 100644 --- a/doc/manual/explanation/architecture/building-blocks.rst +++ b/doc/manual/explanation/architecture/building-blocks.rst @@ -39,7 +39,8 @@ follows the tool each area serves — see subgraph cluster_sphinx { label="sphinx/ — payload"; conf [label="zdocs_conf.py\nshared configure()"]; - exts [label="_extensions/\nxref_builder, doc_control,\nqms_ref, latexinclude,\ntest_module + parsers"]; + exts [label="_extensions/\nxref_builder, doc_control,\nqms_ref, latexinclude,\ntest_module, test_coverage"]; + libs [label="_scripts/\nparsers, RST builders,\ncoverage adequacy"]; tmpl [label="_templates/, _static/"]; } @@ -57,6 +58,7 @@ follows the tool each area serves — see sphinx_cm -> conf [label="ZDOCS_CONF_DIR"]; conf -> docrefs [label="imports"]; conf -> exts; + exts -> libs [label="imports"]; conf -> tmpl; doxygen_cm -> theme [label="HTML_EXTRA_*"]; doxygen_cm -> nav; @@ -93,8 +95,11 @@ whole configuration, including the engine's extension list, and appends the consumer's own extensions rather than being replaced by them. The extensions divide into presentation (``doc_control``, ``qms_ref``, ``latexinclude``), build machinery (``xref_builder``, which provides the stage-one index builder) -and the test-specification block (``test_module`` with its Doxygen XML parser, -twister reader and rST builders). +and the test-specification block (``test_module``, ``test_coverage``, +``symbol_needs``). ``_extensions/`` holds only Sphinx extensions, each with a +``setup()``. The plain modules they share are in ``_scripts/``: the Doxygen +XML parser, the twister reader, the rST builders and the coverage adequacy +logic. ``doxygen/`` — the Doxygen payload ---------------------------------- diff --git a/doc/manual/explanation/decisions/0003-engine-unit-suite.rst b/doc/manual/explanation/decisions/0003-engine-unit-suite.rst index 113b2f1..11e8508 100644 --- a/doc/manual/explanation/decisions/0003-engine-unit-suite.rst +++ b/doc/manual/explanation/decisions/0003-engine-unit-suite.rst @@ -25,11 +25,16 @@ Decision The engine carries a **second, fast unit suite in its own repository**, at ``sphinx/_extensions/_tests/``, covering the pure-Python extension modules. +*Update 2026-10-09:* the plain modules that the extensions share moved to +``sphinx/_scripts/``, with their tests in ``sphinx/_scripts/_tests/``. The +fixtures of both moved to ``sphinx/_fixtures/``. ``pytest.ini`` at the +repository root selects both folders. + There are therefore two suites in two repositories: .. code-block:: console - $ cd tools/zdocs && python3 -m pytest sphinx/_extensions/_tests -q # fast + $ cd tools/zdocs && python3 -m pytest -q # fast $ cd zdocs-tests && python3 -m pytest tests/ -q # acceptance Neither layer can contaminate the other's count, and the engine becomes diff --git a/doc/manual/howto/run-the-test-suites.rst b/doc/manual/howto/run-the-test-suites.rst index dfba1af..c4f756d 100644 --- a/doc/manual/howto/run-the-test-suites.rst +++ b/doc/manual/howto/run-the-test-suites.rst @@ -13,11 +13,13 @@ In the zdocs repository, no build tree and no west workspace required: .. code-block:: console - $ python3 -m pytest sphinx/_extensions/_tests -q + $ python3 -m pytest -q -Pure-Python tests over the Sphinx extensions (``doxygen_parser``, -``rst_builders``, ``twister_reader``, ``test_module``, and their need-type -mapping) run in-process against fixture XML/JSON — no Sphinx build, no +``pytest.ini`` selects two folders. ``sphinx/_scripts/_tests`` tests the plain +modules (``doxygen_parser``, ``rst_builders``, ``twister_reader``). +``sphinx/_extensions/_tests`` tests the Sphinx extensions (``test_module`` and +its need-type mapping, ``test_coverage``, ``doc_control``, ...). To run one, +give its folder. The tests run in-process against fixture XML/JSON — no Sphinx build, no Doxygen, no CMake. It runs in about a second, which is what makes it the right tool for iterating on extension logic; it proves nothing about CMake wiring or about what actually lands in rendered HTML. diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..c7d8538 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,13 @@ +# Copyright (c) 2026 inovex GmbH +# +# SPDX-License-Identifier: Apache-2.0 + +# The engine's unit suites: sphinx/_scripts/_tests and sphinx/_extensions/_tests. +# The sphinx.testing plugin is loaded here and not in a conftest.py: pytest +# accepts `pytest_plugins` only in a top-level conftest, and with two suites +# neither conftest is top-level in a run of both. +[pytest] +addopts = -p sphinx.testing.fixtures +testpaths = + sphinx/_scripts/_tests + sphinx/_extensions/_tests diff --git a/sphinx/_extensions/_tests/conftest.py b/sphinx/_extensions/_tests/conftest.py index 001fc48..6037734 100644 --- a/sphinx/_extensions/_tests/conftest.py +++ b/sphinx/_extensions/_tests/conftest.py @@ -7,12 +7,14 @@ import pytest -# Make _extensions/ importable without install -sys.path.insert(0, str(Path(__file__).resolve().parents[1])) - -FIXTURES = Path(__file__).parent / "fixtures" - -pytest_plugins = "sphinx.testing.fixtures" +# Make _extensions/ importable without install, and _scripts/: the extensions +# import the modules there. +_SPHINX = Path(__file__).resolve().parents[2] +sys.path.insert(0, str(_SPHINX / "_scripts")) +sys.path.insert(0, str(_SPHINX / "_extensions")) + +# The sphinx.testing fixtures (app, make_app, warning) come from pytest.ini at +# the repository root, so both suites can run in one pytest call. # rootdir is intentionally left as the sphinx.testing default (None). # Tests pass srcdir as an absolute path so Sphinx uses the source tree directly # without copying, keeping __file__-relative paths in conf.py correct. diff --git a/sphinx/_extensions/_tests/roots/test-symbolneeds/conf.py b/sphinx/_extensions/_tests/roots/test-symbolneeds/conf.py index c5170bc..2511d3c 100644 --- a/sphinx/_extensions/_tests/roots/test-symbolneeds/conf.py +++ b/sphinx/_extensions/_tests/roots/test-symbolneeds/conf.py @@ -7,7 +7,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[3])) # _extensions/ -_FIXTURES = Path(__file__).resolve().parents[2] / "fixtures" +_FIXTURES = Path(__file__).resolve().parents[4] / "_fixtures" extensions = ["sphinx_needs", "symbol_needs"] master_doc = "index" diff --git a/sphinx/_extensions/_tests/roots/test-testmodule-mapping/conf.py b/sphinx/_extensions/_tests/roots/test-testmodule-mapping/conf.py index bab888a..f144792 100644 --- a/sphinx/_extensions/_tests/roots/test-testmodule-mapping/conf.py +++ b/sphinx/_extensions/_tests/roots/test-testmodule-mapping/conf.py @@ -7,7 +7,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[3])) # _extensions/ -_FIXTURES = Path(__file__).resolve().parents[2] / "fixtures" +_FIXTURES = Path(__file__).resolve().parents[4] / "_fixtures" # Point the testcase.yaml lookup at a directory that has none, so # build_scenario_table() returns [] and these roots stay focused on the diff --git a/sphinx/_extensions/_tests/roots/test-testmodule-partial-mapping/conf.py b/sphinx/_extensions/_tests/roots/test-testmodule-partial-mapping/conf.py index b3b28dc..4e84f1d 100644 --- a/sphinx/_extensions/_tests/roots/test-testmodule-partial-mapping/conf.py +++ b/sphinx/_extensions/_tests/roots/test-testmodule-partial-mapping/conf.py @@ -7,7 +7,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[3])) # _extensions/ -_FIXTURES = Path(__file__).resolve().parents[2] / "fixtures" +_FIXTURES = Path(__file__).resolve().parents[4] / "_fixtures" # Point the testcase.yaml lookup at a directory that has none, so # build_scenario_table() returns [] and these roots stay focused on the diff --git a/sphinx/_extensions/_tests/roots/test-testmodule-qualifier/conf.py b/sphinx/_extensions/_tests/roots/test-testmodule-qualifier/conf.py index 24dd5a4..41ac1fe 100644 --- a/sphinx/_extensions/_tests/roots/test-testmodule-qualifier/conf.py +++ b/sphinx/_extensions/_tests/roots/test-testmodule-qualifier/conf.py @@ -7,7 +7,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[3])) # _extensions/ -_FIXTURES = Path(__file__).resolve().parents[2] / "fixtures" +_FIXTURES = Path(__file__).resolve().parents[4] / "_fixtures" # Point the testcase.yaml lookup at a directory that has none, so # build_scenario_table() returns [] and these roots stay focused on the diff --git a/sphinx/_extensions/_tests/roots/test-testmodule/conf.py b/sphinx/_extensions/_tests/roots/test-testmodule/conf.py index 83e9c05..43448aa 100644 --- a/sphinx/_extensions/_tests/roots/test-testmodule/conf.py +++ b/sphinx/_extensions/_tests/roots/test-testmodule/conf.py @@ -7,7 +7,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[3])) # _extensions/ -_FIXTURES = Path(__file__).resolve().parents[2] / "fixtures" +_FIXTURES = Path(__file__).resolve().parents[4] / "_fixtures" # Point the testcase.yaml lookup at a directory that has none, so # build_scenario_table() returns [] and these roots stay focused on the diff --git a/sphinx/_extensions/_tests/roots/test-testreport-depends/conf.py b/sphinx/_extensions/_tests/roots/test-testreport-depends/conf.py index f7c45df..83f65c4 100644 --- a/sphinx/_extensions/_tests/roots/test-testreport-depends/conf.py +++ b/sphinx/_extensions/_tests/roots/test-testreport-depends/conf.py @@ -7,7 +7,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[3])) # _extensions/ -_FIXTURES = Path(__file__).resolve().parents[2] / "fixtures" +_FIXTURES = Path(__file__).resolve().parents[4] / "_fixtures" extensions = ["sphinx_needs", "test_module"] master_doc = "index" diff --git a/sphinx/_extensions/_tests/roots/test-testreport-mapping/conf.py b/sphinx/_extensions/_tests/roots/test-testreport-mapping/conf.py index b437f91..d91393e 100644 --- a/sphinx/_extensions/_tests/roots/test-testreport-mapping/conf.py +++ b/sphinx/_extensions/_tests/roots/test-testreport-mapping/conf.py @@ -7,7 +7,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[3])) # _extensions/ -_FIXTURES = Path(__file__).resolve().parents[2] / "fixtures" +_FIXTURES = Path(__file__).resolve().parents[4] / "_fixtures" extensions = ["sphinx_needs", "test_module"] master_doc = "index" diff --git a/sphinx/_extensions/_tests/roots/test-testreport-param/conf.py b/sphinx/_extensions/_tests/roots/test-testreport-param/conf.py index 992358c..b1c5f62 100644 --- a/sphinx/_extensions/_tests/roots/test-testreport-param/conf.py +++ b/sphinx/_extensions/_tests/roots/test-testreport-param/conf.py @@ -7,7 +7,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[3])) # _extensions/ -_FIXTURES = Path(__file__).resolve().parents[2] / "fixtures" +_FIXTURES = Path(__file__).resolve().parents[4] / "_fixtures" extensions = ["sphinx_needs", "test_module"] master_doc = "index" diff --git a/sphinx/_extensions/_tests/roots/test-testreport-path/conf.py b/sphinx/_extensions/_tests/roots/test-testreport-path/conf.py index 9d05c35..7350353 100644 --- a/sphinx/_extensions/_tests/roots/test-testreport-path/conf.py +++ b/sphinx/_extensions/_tests/roots/test-testreport-path/conf.py @@ -7,7 +7,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[3])) # _extensions/ -_FIXTURES = Path(__file__).resolve().parents[2] / "fixtures" +_FIXTURES = Path(__file__).resolve().parents[4] / "_fixtures" extensions = ["sphinx_needs", "test_module"] master_doc = "index" diff --git a/sphinx/_extensions/_tests/roots/test-testreport/conf.py b/sphinx/_extensions/_tests/roots/test-testreport/conf.py index 558e7db..b243798 100644 --- a/sphinx/_extensions/_tests/roots/test-testreport/conf.py +++ b/sphinx/_extensions/_tests/roots/test-testreport/conf.py @@ -7,7 +7,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[3])) # _extensions/ -_FIXTURES = Path(__file__).resolve().parents[2] / "fixtures" +_FIXTURES = Path(__file__).resolve().parents[4] / "_fixtures" extensions = ["sphinx_needs", "test_module"] master_doc = "index" diff --git a/sphinx/_extensions/_tests/test_kconfig_depends.py b/sphinx/_extensions/_tests/test_kconfig_depends.py index d7a5146..e261159 100644 --- a/sphinx/_extensions/_tests/test_kconfig_depends.py +++ b/sphinx/_extensions/_tests/test_kconfig_depends.py @@ -21,7 +21,8 @@ import pytest import rst_builders as rb import test_module as tm -from conftest import FIXTURES + +FIXTURES = Path(__file__).resolve().parents[2] / "_fixtures" _ROOTS = Path(__file__).parent / "roots" XML = FIXTURES / "doxygen-kconfig" diff --git a/sphinx/_extensions/_tests/test_suite_qualifier.py b/sphinx/_extensions/_tests/test_suite_qualifier.py index ad54864..bc0c0de 100644 --- a/sphinx/_extensions/_tests/test_suite_qualifier.py +++ b/sphinx/_extensions/_tests/test_suite_qualifier.py @@ -22,9 +22,10 @@ import pytest import test_module as tm -from conftest import FIXTURES from twister_reader import load_spec_lookup +FIXTURES = Path(__file__).resolve().parents[2] / "_fixtures" + _ROOTS = Path(__file__).parent / "roots" XML = FIXTURES / "doxygen-qualifier" M1 = "group__m1____workqueue__api" diff --git a/sphinx/_extensions/_tests/test_symbol_needs.py b/sphinx/_extensions/_tests/test_symbol_needs.py index c52b74d..4dc42e9 100644 --- a/sphinx/_extensions/_tests/test_symbol_needs.py +++ b/sphinx/_extensions/_tests/test_symbol_needs.py @@ -20,12 +20,13 @@ import pytest import rst_builders as rb import symbol_needs as sn -from conftest import FIXTURES sys.path.insert(0, str(Path(__file__).resolve().parents[3] / "scripts")) import docrefs # noqa: E402 +FIXTURES = Path(__file__).resolve().parents[2] / "_fixtures" + _ROOTS = Path(__file__).parent / "roots" XML = FIXTURES / "doxygen-symbols" diff --git a/sphinx/_extensions/_tests/test_test_module.py b/sphinx/_extensions/_tests/test_test_module.py index be2b532..3f73c52 100644 --- a/sphinx/_extensions/_tests/test_test_module.py +++ b/sphinx/_extensions/_tests/test_test_module.py @@ -12,11 +12,12 @@ import pytest import test_module as tm -from conftest import FIXTURES from docutils import nodes from docutils.utils import Reporter from twister_reader import SpecLookup +FIXTURES = Path(__file__).resolve().parents[2] / "_fixtures" + _ROOTS = Path(__file__).parent / "roots" DOXYGEN = FIXTURES / "doxygen" diff --git a/sphinx/_extensions/_tests/test_testreport_depends.py b/sphinx/_extensions/_tests/test_testreport_depends.py index 588ea85..b9dc6aa 100644 --- a/sphinx/_extensions/_tests/test_testreport_depends.py +++ b/sphinx/_extensions/_tests/test_testreport_depends.py @@ -18,7 +18,8 @@ import rst_builders as rb import test_module as tm import twister_reader as tw -from conftest import FIXTURES + +FIXTURES = Path(__file__).resolve().parents[2] / "_fixtures" _ROOTS = Path(__file__).parent / "roots" DATA = FIXTURES / "twister-depends" diff --git a/sphinx/_extensions/_tests/test_testreport_param.py b/sphinx/_extensions/_tests/test_testreport_param.py index c37f1e1..3bc67c3 100644 --- a/sphinx/_extensions/_tests/test_testreport_param.py +++ b/sphinx/_extensions/_tests/test_testreport_param.py @@ -18,9 +18,10 @@ import pytest import rst_builders as rb import twister_reader as tw -from conftest import FIXTURES from twister_reader import SpecLookup +FIXTURES = Path(__file__).resolve().parents[2] / "_fixtures" + _ROOTS = Path(__file__).parent / "roots" DATA = FIXTURES / "twister-param" XML = DATA / "twister_report.xml" diff --git a/sphinx/_extensions/_tests/test_testreport_path.py b/sphinx/_extensions/_tests/test_testreport_path.py index 5897e32..2449ee3 100644 --- a/sphinx/_extensions/_tests/test_testreport_path.py +++ b/sphinx/_extensions/_tests/test_testreport_path.py @@ -17,9 +17,10 @@ import pytest import test_module as tm import twister_reader as tw -from conftest import FIXTURES from docutils import nodes +FIXTURES = Path(__file__).resolve().parents[2] / "_fixtures" + _ROOTS = Path(__file__).parent / "roots" DATA = FIXTURES / "twister-path" XML = DATA / "twister_report.xml" diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-kconfig/Doxyfile b/sphinx/_fixtures/doxygen-kconfig/Doxyfile similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-kconfig/Doxyfile rename to sphinx/_fixtures/doxygen-kconfig/Doxyfile diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-kconfig/group__kd__suite.xml b/sphinx/_fixtures/doxygen-kconfig/group__kd__suite.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-kconfig/group__kd__suite.xml rename to sphinx/_fixtures/doxygen-kconfig/group__kd__suite.xml diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-kconfig/index.xml b/sphinx/_fixtures/doxygen-kconfig/index.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-kconfig/index.xml rename to sphinx/_fixtures/doxygen-kconfig/index.xml diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-kconfig/kd.c b/sphinx/_fixtures/doxygen-kconfig/kd.c similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-kconfig/kd.c rename to sphinx/_fixtures/doxygen-kconfig/kd.c diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-qualifier/group__m1____workqueue__api.xml b/sphinx/_fixtures/doxygen-qualifier/group__m1____workqueue__api.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-qualifier/group__m1____workqueue__api.xml rename to sphinx/_fixtures/doxygen-qualifier/group__m1____workqueue__api.xml diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-qualifier/group__m1__module.xml b/sphinx/_fixtures/doxygen-qualifier/group__m1__module.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-qualifier/group__m1__module.xml rename to sphinx/_fixtures/doxygen-qualifier/group__m1__module.xml diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-qualifier/group__m2____workqueue__api.xml b/sphinx/_fixtures/doxygen-qualifier/group__m2____workqueue__api.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-qualifier/group__m2____workqueue__api.xml rename to sphinx/_fixtures/doxygen-qualifier/group__m2____workqueue__api.xml diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-qualifier/group__m2__module.xml b/sphinx/_fixtures/doxygen-qualifier/group__m2__module.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-qualifier/group__m2__module.xml rename to sphinx/_fixtures/doxygen-qualifier/group__m2__module.xml diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-qualifier/index.xml b/sphinx/_fixtures/doxygen-qualifier/index.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-qualifier/index.xml rename to sphinx/_fixtures/doxygen-qualifier/index.xml diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-symbols/Doxyfile b/sphinx/_fixtures/doxygen-symbols/Doxyfile similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-symbols/Doxyfile rename to sphinx/_fixtures/doxygen-symbols/Doxyfile diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-symbols/group__queue__apis.xml b/sphinx/_fixtures/doxygen-symbols/group__queue__apis.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-symbols/group__queue__apis.xml rename to sphinx/_fixtures/doxygen-symbols/group__queue__apis.xml diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-symbols/index.xml b/sphinx/_fixtures/doxygen-symbols/index.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-symbols/index.xml rename to sphinx/_fixtures/doxygen-symbols/index.xml diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-symbols/queue.h b/sphinx/_fixtures/doxygen-symbols/queue.h similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-symbols/queue.h rename to sphinx/_fixtures/doxygen-symbols/queue.h diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-symbols/queue_8h.xml b/sphinx/_fixtures/doxygen-symbols/queue_8h.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-symbols/queue_8h.xml rename to sphinx/_fixtures/doxygen-symbols/queue_8h.xml diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-symbols/req.dox b/sphinx/_fixtures/doxygen-symbols/req.dox similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-symbols/req.dox rename to sphinx/_fixtures/doxygen-symbols/req.dox diff --git a/sphinx/_extensions/_tests/fixtures/doxygen-symbols/req_8dox.xml b/sphinx/_fixtures/doxygen-symbols/req_8dox.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen-symbols/req_8dox.xml rename to sphinx/_fixtures/doxygen-symbols/req_8dox.xml diff --git a/sphinx/_extensions/_tests/fixtures/doxygen/group__kernel__queue__module.xml b/sphinx/_fixtures/doxygen/group__kernel__queue__module.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen/group__kernel__queue__module.xml rename to sphinx/_fixtures/doxygen/group__kernel__queue__module.xml diff --git a/sphinx/_extensions/_tests/fixtures/doxygen/group__queue__api.xml b/sphinx/_fixtures/doxygen/group__queue__api.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen/group__queue__api.xml rename to sphinx/_fixtures/doxygen/group__queue__api.xml diff --git a/sphinx/_extensions/_tests/fixtures/doxygen/group__queue__procedures.xml b/sphinx/_fixtures/doxygen/group__queue__procedures.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen/group__queue__procedures.xml rename to sphinx/_fixtures/doxygen/group__queue__procedures.xml diff --git a/sphinx/_extensions/_tests/fixtures/doxygen/index.xml b/sphinx/_fixtures/doxygen/index.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/doxygen/index.xml rename to sphinx/_fixtures/doxygen/index.xml diff --git a/sphinx/_extensions/_tests/fixtures/needs/needs.json b/sphinx/_fixtures/needs/needs.json similarity index 100% rename from sphinx/_extensions/_tests/fixtures/needs/needs.json rename to sphinx/_fixtures/needs/needs.json diff --git a/sphinx/_extensions/_tests/fixtures/twister-depends/mps2_an385/zephyr_gnu/tests/kernel/demo/kernel.demo.big/zephyr/.config b/sphinx/_fixtures/twister-depends/mps2_an385/zephyr_gnu/tests/kernel/demo/kernel.demo.big/zephyr/.config similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister-depends/mps2_an385/zephyr_gnu/tests/kernel/demo/kernel.demo.big/zephyr/.config rename to sphinx/_fixtures/twister-depends/mps2_an385/zephyr_gnu/tests/kernel/demo/kernel.demo.big/zephyr/.config diff --git a/sphinx/_extensions/_tests/fixtures/twister-depends/mps2_an385/zephyr_gnu/tests/kernel/demo/kernel.demo/zephyr/.config b/sphinx/_fixtures/twister-depends/mps2_an385/zephyr_gnu/tests/kernel/demo/kernel.demo/zephyr/.config similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister-depends/mps2_an385/zephyr_gnu/tests/kernel/demo/kernel.demo/zephyr/.config rename to sphinx/_fixtures/twister-depends/mps2_an385/zephyr_gnu/tests/kernel/demo/kernel.demo/zephyr/.config diff --git a/sphinx/_extensions/_tests/fixtures/twister-depends/needs.json b/sphinx/_fixtures/twister-depends/needs.json similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister-depends/needs.json rename to sphinx/_fixtures/twister-depends/needs.json diff --git a/sphinx/_extensions/_tests/fixtures/twister-depends/qemu_x86/zephyr_gnu/tests/kernel/demo/kernel.demo.soak/zephyr/.config b/sphinx/_fixtures/twister-depends/qemu_x86/zephyr_gnu/tests/kernel/demo/kernel.demo.soak/zephyr/.config similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister-depends/qemu_x86/zephyr_gnu/tests/kernel/demo/kernel.demo.soak/zephyr/.config rename to sphinx/_fixtures/twister-depends/qemu_x86/zephyr_gnu/tests/kernel/demo/kernel.demo.soak/zephyr/.config diff --git a/sphinx/_extensions/_tests/fixtures/twister-depends/qemu_x86/zephyr_gnu/tests/kernel/demo/kernel.demo/zephyr/.config b/sphinx/_fixtures/twister-depends/qemu_x86/zephyr_gnu/tests/kernel/demo/kernel.demo/zephyr/.config similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister-depends/qemu_x86/zephyr_gnu/tests/kernel/demo/kernel.demo/zephyr/.config rename to sphinx/_fixtures/twister-depends/qemu_x86/zephyr_gnu/tests/kernel/demo/kernel.demo/zephyr/.config diff --git a/sphinx/_extensions/_tests/fixtures/twister-depends/twister.json b/sphinx/_fixtures/twister-depends/twister.json similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister-depends/twister.json rename to sphinx/_fixtures/twister-depends/twister.json diff --git a/sphinx/_extensions/_tests/fixtures/twister-depends/twister_report.xml b/sphinx/_fixtures/twister-depends/twister_report.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister-depends/twister_report.xml rename to sphinx/_fixtures/twister-depends/twister_report.xml diff --git a/sphinx/_extensions/_tests/fixtures/twister-param/needs.json b/sphinx/_fixtures/twister-param/needs.json similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister-param/needs.json rename to sphinx/_fixtures/twister-param/needs.json diff --git a/sphinx/_extensions/_tests/fixtures/twister-param/twister.json b/sphinx/_fixtures/twister-param/twister.json similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister-param/twister.json rename to sphinx/_fixtures/twister-param/twister.json diff --git a/sphinx/_extensions/_tests/fixtures/twister-param/twister_report.xml b/sphinx/_fixtures/twister-param/twister_report.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister-param/twister_report.xml rename to sphinx/_fixtures/twister-param/twister_report.xml diff --git a/sphinx/_extensions/_tests/fixtures/twister-path/needs.json b/sphinx/_fixtures/twister-path/needs.json similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister-path/needs.json rename to sphinx/_fixtures/twister-path/needs.json diff --git a/sphinx/_extensions/_tests/fixtures/twister-path/twister.json b/sphinx/_fixtures/twister-path/twister.json similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister-path/twister.json rename to sphinx/_fixtures/twister-path/twister.json diff --git a/sphinx/_extensions/_tests/fixtures/twister-path/twister_report.xml b/sphinx/_fixtures/twister-path/twister_report.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister-path/twister_report.xml rename to sphinx/_fixtures/twister-path/twister_report.xml diff --git a/sphinx/_extensions/_tests/fixtures/twister/qemu_cortex_m3_ti_lm3s6965/zephyr_gnu/tests/kernel/queue/kernel.queue/handler.log b/sphinx/_fixtures/twister/qemu_cortex_m3_ti_lm3s6965/zephyr_gnu/tests/kernel/queue/kernel.queue/handler.log similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister/qemu_cortex_m3_ti_lm3s6965/zephyr_gnu/tests/kernel/queue/kernel.queue/handler.log rename to sphinx/_fixtures/twister/qemu_cortex_m3_ti_lm3s6965/zephyr_gnu/tests/kernel/queue/kernel.queue/handler.log diff --git a/sphinx/_extensions/_tests/fixtures/twister/twister.json b/sphinx/_fixtures/twister/twister.json similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister/twister.json rename to sphinx/_fixtures/twister/twister.json diff --git a/sphinx/_extensions/_tests/fixtures/twister/twister_report.xml b/sphinx/_fixtures/twister/twister_report.xml similarity index 100% rename from sphinx/_extensions/_tests/fixtures/twister/twister_report.xml rename to sphinx/_fixtures/twister/twister_report.xml diff --git a/sphinx/_scripts/_tests/conftest.py b/sphinx/_scripts/_tests/conftest.py new file mode 100644 index 0000000..690df43 --- /dev/null +++ b/sphinx/_scripts/_tests/conftest.py @@ -0,0 +1,32 @@ +# Copyright (c) 2026 inovex GmbH +# +# SPDX-License-Identifier: Apache-2.0 + +"""Unit tests of the plain modules in ``_scripts/``. + +A test that imports a Sphinx extension from ``_extensions/`` belongs in +``_extensions/_tests``. The fixtures of both suites are in ``sphinx/_fixtures``. +""" + +import sys +from pathlib import Path + +import pytest + +# Make _scripts/ importable without install +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) + +ROOTS = Path(__file__).parent / "roots" + + +@pytest.fixture(autouse=True) +def _fresh_sphinx_build_dirs(): + """Wipe every test root's ``_build/`` before each test. + + Load-bearing, not hygiene: see the same fixture in + ``_extensions/_tests/conftest.py`` for why. + """ + import shutil + + for build_dir in ROOTS.glob("*/_build"): + shutil.rmtree(build_dir, ignore_errors=True) diff --git a/sphinx/_extensions/_tests/test_doxygen_parser.py b/sphinx/_scripts/_tests/test_doxygen_parser.py similarity index 99% rename from sphinx/_extensions/_tests/test_doxygen_parser.py rename to sphinx/_scripts/_tests/test_doxygen_parser.py index 4084007..228ed50 100644 --- a/sphinx/_extensions/_tests/test_doxygen_parser.py +++ b/sphinx/_scripts/_tests/test_doxygen_parser.py @@ -3,10 +3,12 @@ # SPDX-License-Identifier: Apache-2.0 import xml.etree.ElementTree as ET +from pathlib import Path import doxygen_parser as dp import pytest -from conftest import FIXTURES + +FIXTURES = Path(__file__).resolve().parents[2] / "_fixtures" # --------------------------------------------------------------------------- # elem_text diff --git a/sphinx/_extensions/_tests/test_rst_builders.py b/sphinx/_scripts/_tests/test_rst_builders.py similarity index 99% rename from sphinx/_extensions/_tests/test_rst_builders.py rename to sphinx/_scripts/_tests/test_rst_builders.py index f112253..6e92898 100644 --- a/sphinx/_extensions/_tests/test_rst_builders.py +++ b/sphinx/_scripts/_tests/test_rst_builders.py @@ -2,9 +2,12 @@ # # SPDX-License-Identifier: Apache-2.0 +from pathlib import Path + import rst_builders as rb import yaml -from conftest import FIXTURES + +FIXTURES = Path(__file__).resolve().parents[2] / "_fixtures" def _base_info(**kwargs): diff --git a/sphinx/_extensions/_tests/test_twister_reader.py b/sphinx/_scripts/_tests/test_twister_reader.py similarity index 98% rename from sphinx/_extensions/_tests/test_twister_reader.py rename to sphinx/_scripts/_tests/test_twister_reader.py index 5dcb264..7d95b6d 100644 --- a/sphinx/_extensions/_tests/test_twister_reader.py +++ b/sphinx/_scripts/_tests/test_twister_reader.py @@ -3,8 +3,11 @@ # SPDX-License-Identifier: Apache-2.0 +from pathlib import Path + import twister_reader as tw -from conftest import FIXTURES + +FIXTURES = Path(__file__).resolve().parents[2] / "_fixtures" XML_PATH = FIXTURES / "twister" / "twister_report.xml" TWISTER_JSON = FIXTURES / "twister" / "twister.json" diff --git a/sphinx/_extensions/adequacy.py b/sphinx/_scripts/adequacy.py similarity index 100% rename from sphinx/_extensions/adequacy.py rename to sphinx/_scripts/adequacy.py diff --git a/sphinx/_extensions/doxygen_parser.py b/sphinx/_scripts/doxygen_parser.py similarity index 100% rename from sphinx/_extensions/doxygen_parser.py rename to sphinx/_scripts/doxygen_parser.py diff --git a/sphinx/_extensions/needs_fields.py b/sphinx/_scripts/needs_fields.py similarity index 100% rename from sphinx/_extensions/needs_fields.py rename to sphinx/_scripts/needs_fields.py diff --git a/sphinx/_extensions/rst_builders.py b/sphinx/_scripts/rst_builders.py similarity index 100% rename from sphinx/_extensions/rst_builders.py rename to sphinx/_scripts/rst_builders.py diff --git a/sphinx/_extensions/twister_reader.py b/sphinx/_scripts/twister_reader.py similarity index 100% rename from sphinx/_extensions/twister_reader.py rename to sphinx/_scripts/twister_reader.py diff --git a/sphinx/requirements-doc.txt b/sphinx/requirements-doc.txt index 1121579..20d0f56 100644 --- a/sphinx/requirements-doc.txt +++ b/sphinx/requirements-doc.txt @@ -30,7 +30,7 @@ sphinx-needs==8.3.0 sphinxcontrib-doxylink==1.13.0 # -- Used by the registry tooling, not by Sphinx directly ---------------------- -# scripts/docrefs.py, scripts/doccheck.py and sphinx/_extensions/rst_builders.py +# scripts/docrefs.py, scripts/doccheck.py and sphinx/_scripts/rst_builders.py # all `import yaml` to read documents.yaml. The engine is unusable without it. PyYAML==6.0.3 diff --git a/sphinx/zdocs_conf.py b/sphinx/zdocs_conf.py index ca760ff..cdfde6b 100644 --- a/sphinx/zdocs_conf.py +++ b/sphinx/zdocs_conf.py @@ -36,10 +36,13 @@ ZDOCS_DOC_DIR = Path(__file__).resolve().parent ZDOCS_BASE = ZDOCS_DOC_DIR.parent -# zdocs' own extensions and scripts, plus Zephyr's doc extensions (external_content -# assembles the Sphinx source tree). cmake/sphinx.cmake puts ZEPHYR_BASE into -# the environment of every Sphinx run, from the Zephyr that find_package(Zephyr) -# found. find_package itself sets only the CMake variable. +# zdocs' own extensions (_extensions: Sphinx extensions, each with a setup()), +# the modules they share (_scripts: plain Python, no setup()) and scripts, plus +# Zephyr's doc extensions (external_content assembles the Sphinx source tree). +# cmake/sphinx.cmake puts ZEPHYR_BASE into the environment of every Sphinx run, +# from the Zephyr that find_package(Zephyr) found. find_package itself sets +# only the CMake variable. +sys.path.insert(0, str(ZDOCS_DOC_DIR / "_scripts")) sys.path.insert(0, str(ZDOCS_DOC_DIR / "_extensions")) sys.path.insert(0, str(ZDOCS_BASE / "scripts")) _zephyr_base = os.environ.get("ZEPHYR_BASE")