[PR3] Add local Needs exports for documentation bundles - #772
[PR3] Add local Needs exports for documentation bundles#772AlexanderLanin wants to merge 1 commit into
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //src:license-checkStatus: Click to expand output |
|
Documentation preview for this pull request is available at: |
MaximilianSoerenPollak
left a comment
There was a problem hiding this comment.
It seems alright to me.
I think it's hard to judge some edgecases and see if this covers all of the useages we might need.
Easiest to slowly test it in the modules that need it and see what is missing / not quiet right.
Great starting point though. 💯
There was a problem hiding this comment.
Pull request overview
Adds reusable local and upward Needs exports for source-bearing documentation bundles.
Changes:
- Adds
upward_bundleshierarchy support and generated Needs targets. - Extends external Needs resolution for bundle exports.
- Adds documentation and integration/unit coverage.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
docs.bzl |
Generates local and upward Needs exports. |
bzl/bundle_rules.bzl |
Propagates hierarchy metadata. |
default_conf.py.tpl |
Supports bundle entry documents. |
docs/reference/bazel_macros.rst |
Documents the new API and flow. |
src/extensions/score_metamodel/external_needs.py |
Resolves upward exports from runfiles. |
src/extensions/score_metamodel/tests/test_external_needs.py |
Tests bundle export resolution. |
src/tests/docs_bzl/test_upward_bundles.py |
Tests bundle export behavior. |
src/tests/docs_bzl/README.md |
Registers the new scenario. |
src/tests/docs_bzl/scenarios/upward_bundles/BUILD |
Defines the hierarchy fixture. |
src/tests/docs_bzl/scenarios/upward_bundles/platform/index.rst |
Provides ancestor Needs. |
src/tests/docs_bzl/scenarios/upward_bundles/component/index.rst |
Provides dependent Needs. |
src/tests/docs_bzl/scenarios/data_files_runfiles/BUILD |
Documents data-only behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # Label() directly would resolve them relative to the repository containing | ||
| # this .bzl file, which is wrong when the macro is loaded by another module. | ||
| bundle_string = str(native.package_relative_label(bundle)) | ||
| return Label(bundle_string + ".__internal__.needs_local") |
There was a problem hiding this comment.
I am intentionally not applying the suggested change. upward_bundles is defined as an explicit direct-dependency list; resolving needs_upward here would import the ancestor chain implicitly and violate the no-transitive-dependencies contract. Source-less hierarchy groups are now rejected explicitly with an analysis-time error (1d33c85), and consumers must list the source-bearing ancestors they need directly. Leaving this thread open because the proposed behavior conflicts with that contract.
2aa2764 to
93ebfb9
Compare
93ebfb9 to
2dbb70b
Compare
8a8ab62 to
6205415
Compare
0fe3bed to
eee8166
Compare
98c79f9 to
5cbdcb9
Compare
5cbdcb9 to
6ccbea7
Compare
Why this matters
Reusable source-bearing documentation bundles currently contribute content but do not expose a standalone Needs artifact. That prevents a bundle’s own Needs from being validated or consumed independently.
This change establishes the local-export layer for the bundle split. It intentionally supports self-contained bundles only: references to Needs owned outside the bundle remain unresolved and fail strict builds. Cross-bundle resolution and propagation are reserved for PR4.
What changed
<name>.__internal__.needs_localfor every source-bearing bundle.conf.py, or its generated configuration when none is provided.docs():needs_jsonexport.This is the logical PR3 layer on top of the PR0–PR2 history. The upstream PR necessarily targets
mainbecause the prerequisite branches are in the contributor fork.