Skip to content

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

Open
antonkri wants to merge 3 commits into
mainfrom
ankr_rules_score_playground
Open

WIP: sphinx-needs filtering, Markdown & TRLC export rules (demo playground)#615
antonkri wants to merge 3 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: 27d7c50f-fc14-4cca-9da2-73745a95d462
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.549s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target


args = parser.parse_args()

with open(args.input) as f:
)

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:
)
logger.info(
"Documented '%s' -> '%s' (%d needs)",
args.input,
logger.info(
"Documented '%s' -> '%s' (%d needs)",
args.input,
args.output,
converted = len(_collect_requirement_needs(data))
logger.info(
"Converted '%s' -> '%s' (%d requirements, package '%s')",
args.input,
logger.info(
"Converted '%s' -> '%s' (%d requirements, package '%s')",
args.input,
args.output,
args.input,
args.output,
converted,
package,
@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:
)
return 1

logger.info("Checklist '%s' is up to date (sha256=%s).", args.checklist_id, actual)
"last reviewed. Re-review the checklist and update its 'sha256' "
"attribute to '%s'.",
args.checklist_id,
expected,
"The validated target output has changed since the checklist was "
"last reviewed. Re-review the checklist and update its 'sha256' "
"attribute to '%s'.",
args.checklist_id,
Comment thread scripts_bazel/validate_checklist.py Fixed
Comment thread scripts_bazel/validate_checklist.py Fixed
Comment thread scripts_bazel/validate_checklist.py Fixed
"checklist's 'sha256' attribute to:\n"
"\n"
" %s\n",
args.checklist_id,
logger.error(
"Checklist need '%s' not found in '%s'.",
args.checklist_id,
args.needs_json,
if need is None:
logger.error(
"Checklist need '%s' not found in '%s'.",
args.checklist_id,
@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
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