Skip to content

Commit f42f078

Browse files
authored
[rules score] bugfix document not included in toctree (#519)
2 parents ea96b4f + 5ed2ff6 commit f42f078

3 files changed

Lines changed: 68 additions & 0 deletions

File tree

‎bazel/rules/rules_score/private/dependable_element.bzl‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,12 @@ def _dependable_element_index_impl(ctx):
12291229
# Sphinx sidebar navigation.
12301230
component_entries = ["components/" + name for name in component_refs]
12311231

1232+
# Units listed directly in components have no parent component page, so
1233+
# link their pages from the Components section.
1234+
for comp_target in ctx.attr.components:
1235+
if UnitInfo in comp_target and ComponentInfo not in comp_target:
1236+
component_entries.append("units/" + comp_target.label.name)
1237+
12321238
# Generate submodule links for the index page
12331239
deps_links = _process_deps(ctx)
12341240

‎bazel/rules/rules_score/test/BUILD‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ load(
4747
"cross_label_collision_fails_test",
4848
"same_label_collision_fails_test",
4949
)
50+
load(
51+
":dependable_element_toplevel_unit_test.bzl",
52+
"toplevel_unit_linked_test",
53+
)
5054
load(
5155
":html_generation_test.bzl",
5256
"auto_config_generation_test",
@@ -919,6 +923,26 @@ dependable_element(
919923
deps = [],
920924
)
921925

926+
# Unit listed directly in components (no parent component).
927+
dependable_element(
928+
name = "toplevel_unit_example_lib",
929+
testonly = True,
930+
architectural_design = [":arch_design_leaf_unit_example"],
931+
components = [":leaf_unit"],
932+
dependability_analysis = [":dependability_analysis_target"],
933+
integrity_level = "B",
934+
maturity = "development",
935+
requirements = [":feat_req"],
936+
tests = [],
937+
deps = [],
938+
)
939+
940+
toplevel_unit_linked_test(
941+
name = "toplevel_unit_linked_test",
942+
target_under_test = ":toplevel_unit_example_lib_index",
943+
unit_name = "leaf_unit",
944+
)
945+
922946
sh_test(
923947
name = "leaf_unit_example_link_rendered_test",
924948
srcs = ["check_idmap_link.sh"],
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
"""Analysis test: units listed directly in dependable_element.components are linked in a toctree."""
14+
15+
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
16+
17+
def _toplevel_unit_linked_test_impl(ctx):
18+
env = analysistest.begin(ctx)
19+
20+
actions = [
21+
a
22+
for a in analysistest.target_actions(env)
23+
if a.mnemonic == "TemplateExpand" and a.outputs.to_list()[0].basename == "components.rst"
24+
]
25+
asserts.equals(env, 1, len(actions))
26+
if len(actions) == 1:
27+
entries = {s: v for s, v in actions[0].substitutions.items()}["{entries}"]
28+
asserts.true(
29+
env,
30+
"units/" + ctx.attr.unit_name in entries,
31+
"top-level unit page missing from components toctree: " + entries,
32+
)
33+
return analysistest.end(env)
34+
35+
toplevel_unit_linked_test = analysistest.make(
36+
_toplevel_unit_linked_test_impl,
37+
attrs = {"unit_name": attr.string(mandatory = True)},
38+
)

0 commit comments

Comments
 (0)