Skip to content

🧪 TEST: add a Sphinx-Needs kitchen-sink bundle to the example - #20

Draft
ubmarco wants to merge 1 commit into
mainfrom
needs-directives-showcase
Draft

🧪 TEST: add a Sphinx-Needs kitchen-sink bundle to the example#20
ubmarco wants to merge 1 commit into
mainfrom
needs-directives-showcase

Conversation

@ubmarco

@ubmarco ubmarco commented Jul 30, 2026

Copy link
Copy Markdown
Member

Blocked on useblocks/sphinx-needs#1750.
The PlantUML !include in this bundle needs that fix. The testing group
therefore points at sphinx-needs master for now — CI's pytest/bazel jobs go
green as soon as #1750 lands (tox-uv resolves the git ref fresh, so no
uv.lock refresh is needed), and the pin is then swapped for
sphinx-needs>8.3.0 once that version ships.

What and why

The showcase/ folder has one bundle per file-referencing directive. Sphinx-Needs
did not fit that shape: it contributes three doc-relative file references, and
they do not behave alike.

reference resolved by Sphinx dependency seen by path_check
needimport:: needs.json Sphinx relfn2path yes yes
needreport :template: Sphinx relfn2path no no
needuml / needarch !include the PlantUML process no no

So showcase/needs/ is a deliberate kitchen sink — one page per directive, each
sitting next to the file it reads — because the three only make sense side by
side.

The middle column is the finding worth surfacing. path_check works off
env.dependencies, which is exactly why it is directive-agnostic — and exactly
why it cannot see two of these three. docs/source/configuration.rst now says so
outright, instead of leaving readers to assume the check is total.

Also in here

  • First use of exclude in the example. report-template.rst is Jinja
    input, not a document, but carries the conventional .rst suffix — so a
    directory mount walks it and publishes an orphan page of unrendered Jinja. The
    bundle's .puml / .json files need no exclude; their suffixes are not in
    source_suffix.
  • The shared-ubproject.toml convention, demonstrated. The host sets
    needs_from_toml = "ubproject.toml", so Sphinx-Needs reads [needs] from the
    same file whose [[mounts]] array sphinx-mounts reads. The README has
    advertised this; now the example does it.
  • plantuml_output_format = "svg_img". Sphinx-Needs stamps a scale
    attribute (100 — a no-op) onto every diagram node it generates, and
    sphinxcontrib-plantuml's PNG path warns about any scaling attribute unless
    Pillow is installed, which fails this -nW build over nothing. The SVG path
    does no scaling, so this avoids a dependency rather than adding one.

Tests

Both layers, so this is not gated behind the Bazel job:

  • tests/test_path_directives.py — three new tests next to the existing
    per-directive ones. needimport and needreport stay renderer-independent
    like their neighbours; the needuml !include test has to render for real
    (PlantUML resolves that path itself and records nothing Sphinx can assert on),
    so it skips without java/plantuml.
  • tests/test_example.py — asserts each page rendered, the imported needs became
    real needs, the report template was applied, the excluded template published no
    page, and that the bundle-local .puml reached both rendered SVGs.

Verified locally against the patched sphinx-needs: 168 passed (was 163), docs
build clean under -nW, prek run --all-files passes.

Verified in the other direction too — against unpatched sphinx-needs the new
needuml test and the example build both fail with
plantuml command 'plantuml' cannot be run, which is the #1749 symptom. The
showcase genuinely exercises the fix rather than merely coexisting with it.

Sphinx-Needs contributes three file references resolved relative to the
containing document, and they do not behave alike:

  reference                     resolved by         dependency  path_check
  needimport:: needs.json       relfn2path          yes         yes
  needreport :template:         relfn2path          no          no
  needuml/needarch !include     PlantUML process    no          no

`showcase/needs/` covers all three — one page per directive, each next to the
file it reads. Unlike the other showcase bundles (one directive each) this is a
kitchen sink, because the three cases only make sense side by side.

Only `needimport` records a Sphinx dependency, so it is the only one visible to
`path_check` and to incremental rebuilds; the docs now state that explicitly
rather than leaving readers to assume the check is total.

Also:

- `report-template.rst` goes in the mount's `exclude`. It is Jinja input, not a
  document, but wears an `.rst` suffix — without the exclude the directory mount
  publishes an orphan page of unrendered Jinja. First use of `exclude` in the
  example.
- The host reads its Sphinx-Needs options from the `[needs]` table of the same
  `ubproject.toml` that declares the mounts, so the shared-TOML convention the
  README advertises is now demonstrated rather than only described.
- `plantuml_output_format = "svg_img"`. Sphinx-Needs stamps a `scale` attribute
  (100, a no-op) onto every diagram node, and plantuml's PNG path warns about
  any scaling attribute without Pillow, which fails the `-nW` build. The SVG
  path does no scaling, so no new dependency.
- Non-Bazel coverage in `tests/test_path_directives.py` alongside the existing
  per-directive tests, so this is not gated behind the Bazel job. The needuml
  test must render for real (PlantUML resolves `!include` itself and records
  nothing), so it skips without java/plantuml.

The `!include` requires the sphinx-needs fix for useblocks/sphinx-needs#1749,
which is unreleased — hence the temporary git dependency, to be swapped for
`sphinx-needs>8.3.0` once that ships.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant