Files
Kam 350763d84a fix(docs-infra): restore adev build under stricter ts_project deps
The cross-repo dependency update in #69410 bumped rules_angular, whose
ts_project now requires every entry in `deps` to provide the JsInfo
provider. Two adev targets passed deps that don't, so `bazel build
//adev:build` fails analysis and the adev CI check has been red on main
since that PR.

Make generate_nav_items return JsInfo (with the generated routes.json as
its sources) so navigation-entries can keep importing routes.json through
its deps. Also drop the spurious deps entry on llms_lib: llms.mts reads
llms-list.md at runtime via readFile rather than importing it, and the
file is already provided to the binary via data.

Fixes #69429
2026-06-19 11:37:17 +02:00

73 lines
2.3 KiB
Python

load("@aspect_rules_js//js:providers.bzl", "js_info")
def _generate_nav_items(ctx):
"""Implementation of the navigation items data generator rule"""
# Set the arguments for the actions inputs and output location.
args = ctx.actions.args()
# Use a param file because we may have a large number of inputs.
args.set_param_file_format("multiline")
args.use_param_file("%s", use_always = True)
# Pass the set of source files.
args.add_joined(ctx.files.srcs, join_with = ",")
# Add BUILD file path to the arguments.
args.add(ctx.label.package)
# Add the nav item generation strategy to thte arguments.
args.add(ctx.attr.strategy)
# File declaration of the generated JSON file.
json_output = ctx.actions.declare_file("routes.json")
# Add the path to the output file to the arguments.
args.add(json_output.path)
ctx.actions.run(
inputs = depset(ctx.files.srcs),
executable = ctx.executable._generate_nav_items,
outputs = [json_output],
arguments = [args],
env = {
"BAZEL_BINDIR": ".",
},
)
# The return value describes what the rule is producing. We expose the generated JSON via
# both DefaultInfo and JsInfo so it can be consumed as a `ts_project` dependency (the new
# rules_angular `ts_project` requires deps to provide JsInfo).
outputs = depset([json_output])
return [
DefaultInfo(files = outputs),
js_info(
target = ctx.label,
sources = outputs,
transitive_sources = outputs,
),
]
generate_nav_items = rule(
# Point to the starlark function that will execute for this rule.
implementation = _generate_nav_items,
doc = """Rule that generates navigation items data.""",
# The attributes that can be set to this rule.
attrs = {
"srcs": attr.label_list(
doc = """Markdown files that represent the page contents.""",
allow_empty = False,
allow_files = True,
),
"strategy": attr.string(
doc = """Represents the navigation items generation strategy.""",
),
"_generate_nav_items": attr.label(
default = Label("//adev/shared-docs/pipeline:navigation"),
executable = True,
cfg = "exec",
),
},
)