Skip to content

WIP: sphinx-needs filtering, Markdown & TRLC export rules (demo playground)#615

Open
antonkri wants to merge 4 commits into
mainfrom
ankr_rules_score_playground
Open

WIP: sphinx-needs filtering, Markdown & TRLC export rules (demo playground)#615
antonkri wants to merge 4 commits into
mainfrom
ankr_rules_score_playground

Conversation

@antonkri

Copy link
Copy Markdown
Contributor

⚠️ WIP — Demonstration purposes only. This PR is a playground/proof-of-concept and is not intended to be merged as-is.

What

Adds experimental Bazel rules and helper scripts around sphinx-needs to:

  • Filter needs.json output
  • Export sphinx-needs data to Markdown
  • Export sphinx-needs data to TRLC

Why

To demonstrate how requirements/needs data can be transformed into other formats (Markdown, TRLC) as part of the docs-as-code pipeline, for discussion and evaluation.

How to use

See the newly added README for details on the rules and scripts and example invocations.

Status

This is work in progress for demo only — APIs, naming, and structure are subject to change.

…round)

Add Bazel macros and Python tools to post-process needs.json:
- filter_needs_json / component_requirements / feature_requirements /
  assumptions_of_use: extract a subset of sphinx-needs elements
- sphinx_needs_to_md: render needs as a Markdown document
- sphinx_needs_to_trlc: convert S-CORE requirements to TRLC

WIP / demonstration only.
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run --lockfile_mode=error //src:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.6.0) and connecting to it...
INFO: Invocation ID: 2d90f806-c5e8-4d5c-96cc-ca292e4bfbaf
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
    currently loading: src
WARNING: Target pattern parsing failed.
ERROR: Skipping '//src:license-check': no such target '//src:license-check': target 'license-check' not declared in package 'src' defined by /home/runner/work/docs-as-code/docs-as-code/src/BUILD
ERROR: no such target '//src:license-check': target 'license-check' not declared in package 'src' defined by /home/runner/work/docs-as-code/docs-as-code/src/BUILD
INFO: Elapsed time: 5.667s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

Comment thread scripts_bazel/filter_needs_json.py Fixed
)

args.output.parent.mkdir(parents=True, exist_ok=True)
with open(args.output, "w") as f:

args = parser.parse_args()

with open(args.input) as f:
document = render_document(data, title=args.title)

args.output.parent.mkdir(parents=True, exist_ok=True)
with open(args.output, "w") as f:
if not package or not (package[0].isalpha() or package[0] == "_"):
package = "Needs"

with open(args.input) as f:
Comment thread scripts_bazel/sphinx_needs_to_md.py Fixed
Comment thread scripts_bazel/sphinx_needs_to_md.py Fixed
Comment thread scripts_bazel/sphinx_needs_to_trlc.py Fixed
Comment thread scripts_bazel/sphinx_needs_to_trlc.py Fixed
Comment thread scripts_bazel/sphinx_needs_to_trlc.py Fixed
@github-actions

Copy link
Copy Markdown

The created documentation from the pull request is available at: docu-html

Adds a 'req_chklst' sphinx-needs type that pins the reviewed state of build outputs via a SHA256 hash, plus a 'requirements_checklist' Bazel rule and 'validate_checklist.py' tool that recompute the hash over the validated target outputs and fail the build when it drifts.

Copy link
Copy Markdown
Contributor Author

Added a separate commit: Requirement Checklist need type + validation rule (still WIP / demo only).

What this adds

  • New req_chklst sphinx-needs type (in metamodel.yaml) that pins the reviewed state of build outputs via a mandatory sha256 attribute, plus a targets attribute and a checklist link to the checklist document.
  • New requirements_checklist Bazel rule (docs.bzl) + validate_checklist.py tool: building the target recomputes the SHA256 over the validated dependency outputs (e.g. component_requirements) and fails the build if it differs from the hash recorded in the checklist need.

Workflow

  1. bazel build //:<checklist_target> → fails on first run and prints the actual hash.
  2. Review the checklist, paste the hash into the need's sha256.
  3. Build passes until the validated requirements change again, then it fails and requests a re-review.

A demonstration of the consuming side (need element + requirements_checklist target) lives in the baselibs repo and is not part of this PR.


args = parser.parse_args()

with open(args.needs_json) as f:
Comment thread scripts_bazel/validate_checklist.py Fixed
Comment thread scripts_bazel/validate_checklist.py Fixed
Comment thread scripts_bazel/validate_checklist.py Fixed
Comment thread scripts_bazel/validate_checklist.py Fixed
Comment thread scripts_bazel/validate_checklist.py Fixed
Comment thread scripts_bazel/validate_checklist.py Fixed
Comment thread scripts_bazel/validate_checklist.py Fixed
Comment thread scripts_bazel/validate_checklist.py Fixed
Comment thread scripts_bazel/validate_checklist.py Fixed
@antonkri antonkri force-pushed the ankr_rules_score_playground branch from e7c195e to b02108f Compare June 25, 2026 08:15
- Add feature_architecture / component_architecture macros (no static/dynamic split)
- Add architecture_checklist macro and arch_chklst need type
- Report computed SHA256 on empty sha256 attribute in validate_checklist
- Make req_chklst/arch_chklst sha256 optional so empty values build
- Document new macros and need type
@antonkri antonkri force-pushed the ankr_rules_score_playground branch from b02108f to 7c10704 Compare June 25, 2026 08:49
Comment thread scripts_bazel/validate_checklist.py Fixed
Comment thread scripts_bazel/validate_checklist.py Fixed
Comment thread scripts_bazel/validate_checklist.py Fixed
Comment thread scripts_bazel/validate_checklist.py Fixed
Comment thread scripts_bazel/validate_checklist.py Fixed
…ture checklists

requirements_checklist and architecture_checklist now follow the
sphinx-needs link graph recursively from the elements in deps and hash
the whole closure, so a checklist goes out of date when an upstream
dependency (e.g. a linked stakeholder requirement) changes, not only
when a root element changes.

- validate_checklist.py: add transitive mode via repeatable --link-field;
  follow links recursively, normalize version-constrained link targets
  (id[version==1] -> id), hash canonical serialization of the closure.
- docs.bzl: add link_fields arg to both macros (defaults cover the
  requirement / architecture link chains); pass --link-field through.
  link_fields = [] restores the previous flat hashing.
- metamodel.yaml + README_needs_rules.md: document the recursive behavior.
@antonkri antonkri force-pushed the ankr_rules_score_playground branch from 32e06cd to adf58f4 Compare June 26, 2026 14:15

args = parser.parse_args()

with open(args.input) as f:
# whole closure (roots + all reachable dependencies).
root_needs: dict[str, dict[str, Any]] = {}
for path in args.inputs:
with open(path) as f:
# are invisible to the checklist.
all_needs: dict[str, dict[str, Any]] = {}
for extra_path in args.extra_needs_json:
with open(extra_path) as f:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants