Skip to content

Commit 15d8e91

Browse files
committed
fix: address PR #484 review comments (dashboards, implementation_state, source_linker config)
1 parent 0a1a885 commit 15d8e91

5 files changed

Lines changed: 38 additions & 86 deletions

File tree

docs/how-to/dashboards_and_quality_gates.rst

Lines changed: 11 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -38,40 +38,10 @@ repository can:
3838
Typical Setup
3939
-------------
4040

41-
1. Add docs-as-code as a Bazel dependency as described in :ref:`setup`.
42-
2. Define the documentation target via the ``docs(...)`` macro.
43-
3. Provide process or upstream needs via the ``data`` argument when cross-repo
44-
traceability is required.
45-
4. Provide implementation sources via ``scan_code`` so ``source_code_link`` can
46-
be generated.
47-
5. Add test metadata so ``testlink`` and testcase needs can be generated.
48-
49-
Minimal Consumer Example
50-
------------------------
51-
52-
In ``BUILD``:
53-
54-
.. code-block:: starlark
55-
56-
load("@score_docs_as_code//:docs.bzl", "docs")
57-
58-
filegroup(
59-
name = "module_sources",
60-
srcs = glob([
61-
"src/**/*.py",
62-
"src/**/*.cpp",
63-
"src/**/*.h",
64-
"src/**/*.rs",
65-
]),
66-
)
67-
68-
docs(
69-
source_dir = "docs",
70-
data = [
71-
"@score_process//:needs_json",
72-
],
73-
scan_code = [":module_sources"],
74-
)
41+
For details, see :ref:`setup`.
42+
43+
Minimal Configuration Example
44+
-----------------------------
7545

7646
In ``docs/conf.py``:
7747

@@ -80,54 +50,16 @@ In ``docs/conf.py``:
8050
score_metamodel_requirement_types = "feat_req,comp_req,aou_req"
8151
score_metamodel_include_external_needs = False
8252
83-
Use ``score_metamodel_include_external_needs = True`` only in repositories that
84-
intentionally aggregate traceability across dependencies, such as integration
85-
repositories.
86-
87-
Configuration split:
88-
89-
**Policy (conf.py):** What needs to filter and whether to aggregate externals.
90-
91-
**Wiring (BUILD):** Which dependencies to pull and how the build executes.
92-
93-
Example:
94-
95-
.. code-block:: python
96-
97-
# docs/conf.py — policy
98-
score_metamodel_requirement_types = "feat_req,comp_req" # What types to include
99-
score_metamodel_include_external_needs = False # Aggregate or not
100-
101-
.. code-block:: starlark
102-
103-
# BUILD — wiring
104-
docs(
105-
source_dir = "docs",
106-
data = [
107-
"@score_process//:needs_json", # Which external sources to bring in
108-
],
109-
scan_code = [":module_sources"], # Which source files to scan
110-
)
53+
Use ``score_metamodel_include_external_needs = True`` (aggregate_traceability_across_dependencies)
54+
only in repositories that intentionally aggregate requirements across module dependencies, such as
55+
integration repositories. Use ``False`` for module repositories to gate only on local traceability.
11156

11257
Building the Dashboard
11358
----------------------
11459

115-
Run:
116-
117-
.. code-block:: bash
118-
119-
bazel run //:docs
120-
121-
This produces the HTML output.
122-
123-
Run:
124-
125-
.. code-block:: bash
126-
127-
bazel build //:needs_json
60+
After building/running any docs command (i.e. ``bazel build //:needs_json`` or ``bazel run //:docs_verify`` are the fastest):
12861

129-
In this setup, the documentation build writes ``metrics.json`` via
130-
``score_metamodel``, and the ``needs_json`` artifact contains:
62+
The documentation build writes ``metrics.json`` via ``score_metamodel``, and the ``needs_json`` artifact contains:
13163

13264
- ``bazel-bin/needs_json/_build/needs/needs.json``
13365
- ``bazel-bin/needs_json/_build/needs/metrics.json``
@@ -172,7 +104,8 @@ After building ``//:needs_json``, run the gate on the exported metrics:
172104

173105
.. code-block:: bash
174106
175-
bazel run @score_docs_as_code//scripts_bazel:traceability_gate -- \
107+
bazel run //:docs && \
108+
bazel run //:traceability_gate -- \
176109
--metrics-json bazel-bin/needs_json/_build/needs/metrics.json \
177110
--min-req-code 70 \
178111
--min-req-test 70 \

docs/internals/requirements/implementation_state.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repositories.
2626
Overview
2727
--------
2828

29-
.. needpie:: Requirements Status
29+
.. needpie:: Tool Requirements Status
3030
:labels: not implemented, implemented but incomplete traceability, fully linked
3131
:colors: red,yellow, green
3232
:filter-func: src.extensions.score_metamodel.checks.traceability_dashboard.pie_requirements_status(tool_req)
@@ -57,8 +57,8 @@ Implementation labels used on this page:
5757

5858
Why multiple pies are shown:
5959

60-
- ``Requirements with Codelinks`` shows implementation-to-source traceability.
61-
- ``Requirements with linked tests`` shows implementation-to-verification traceability.
60+
- ``Requirements with Codelinks`` shows requirement-to-implementation traceability.
61+
- ``Requirements with linked tests`` shows requirement-to-verification traceability.
6262
- ``Requirements fully linked`` is the strict roll-up (both links present).
6363

6464
These are intentionally separate because they answer different diagnostics:

docs/internals/requirements/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Requirements
1818
This repository provides the docs-as-code tooling used by other SCORE
1919
repositories. The pages in this section therefore focus on two questions:
2020

21-
1. Which process and tool requirements are covered by the docs-as-code tooling?
21+
1. Which process requirements are covered by the docs-as-code tooling?
2222
2. How is the tooling itself verified and qualified for downstream use?
2323

2424
Actual product and module traceability is expected to live in consuming

docs/reference/commands.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
| Target | What it does |
1010
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------- |
11-
| `bazel run //:docs` | Builds documentation (also writes `metrics.json`) |
11+
| `bazel run //:docs` | Builds documentation (also writes `metrics.json` via the score_metamodel extension) |
1212
| `bazel run //:docs_check` | Verifies documentation correctness |
1313
| `bazel run //:docs_combo` | Builds combined documentation with all external dependencies included |
14-
| `bazel run @score_docs_as_code//scripts_bazel:traceability_gate -- --metrics-json bazel-bin/needs_json/_build/needs/metrics.json --min-req-code 100 --min-req-test 100 --min-req-fully-linked 100 --min-tests-linked 100 --fail-on-broken-test-refs` | Reads the pre-computed metrics.json from the docs build and fails if coverage thresholds are not met |
14+
| `bazel run //:traceability_gate -- --metrics-json bazel-bin/needs_json/_build/needs/metrics.json --min-req-code 70 --min-req-test 70 --min-req-fully-linked 60 --min-tests-linked 70` | Reads the pre-computed metrics.json and fails if coverage thresholds are not met |
1515
| `bazel run //:live_preview` | Creates a live_preview of the documentation viewable in a local server |
1616
| `bazel run //:live_preview_combo_experimental` | Creates a live_preview of the full documentation with all dependencies viewable in a local server |
1717
| `bazel run //:ide_support` | Sets up a Python venv for esbonio (Remember to restart VS Code!) |

src/extensions/score_source_code_linker/__init__.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ def setup_once(app: Sphinx):
310310
assert find_git_root()
311311

312312
# Register & Run (if needed) parsing & saving of JSON caches
313+
# Note: This extension now runs on both internal and external needs_json invocations.
314+
# Both modes aggregate links from local sources and external dependencies, enabling
315+
# unified traceability reporting in integration repositories. Impact on external needs
316+
# invocations is minimal since they typically don't have local test logs or source code.
313317
setup_source_code_linker(app, ws_root)
314318
register_test_code_linker(app)
315319
register_combined_linker(app)
@@ -322,13 +326,28 @@ def setup_once(app: Sphinx):
322326
def setup(app: Sphinx) -> dict[str, str | bool]:
323327
# Esbonio will execute setup() on every iteration.
324328
# setup_once will only be called once.
325-
app.add_config_value("KNOWN_GOOD_JSON", default="", rebuild="env", types=str)
326-
app.add_config_value("score_sourcelinks_json", default="", rebuild="env", types=str)
329+
330+
# Config values for source code linking and testcase metadata integration
331+
app.add_config_value(
332+
"KNOWN_GOOD_JSON",
333+
default="",
334+
rebuild="env",
335+
types=str,
336+
description="Path to pre-generated source code links JSON (optional fallback)"
337+
)
338+
app.add_config_value(
339+
"score_sourcelinks_json",
340+
default="",
341+
rebuild="env",
342+
types=str,
343+
description="Path to pre-generated source code links JSON from Bazel via SCORE_SOURCELINKS env var"
344+
)
327345
app.add_config_value(
328346
"score_source_code_linker_plain_links",
329347
default=False,
330348
rebuild="env",
331349
types=bool,
350+
description="If True, render links as plain text without GitHub URLs (useful for Bazel sandbox builds)"
332351
)
333352
setup_once(app)
334353

0 commit comments

Comments
 (0)