-
Notifications
You must be signed in to change notification settings - Fork 29
refactor(module-verification-report): split, tests, docs #730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
antonkri
wants to merge
20
commits into
main
Choose a base branch
from
ankr_mod_verf_report
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f06f53d
feat(module-verification-report): new bundled sphinx extension
antonkri bc1fcf9
refactor(module-verification-report): split extension into focused mo…
antonkri a5ca966
test(module-verification-report): add unit tests for the split modules
antonkri 5a35249
docs(module-verification-report): add extension reference page
antonkri 27154c1
feat(module-verification-report): annotate testcase back-links with r…
antonkri 7f3a99c
refactor(module-verification-report): add module-id/feature-id/compon…
antonkri 3d6db9f
refactor(module-verification-report): replace filesystem scan with :c…
antonkri 4a75281
feat(module-verification-report): validate component links at build-f…
antonkri e49eb74
fix: remove feature-id name guessing — feature section is skipped whe…
antonkri bba1322
refactor: remove unit test coverage (LCOV) and work-product overrides…
antonkri ac2540f
style: apply ruff-format and end-of-file-fixer
antonkri 4ea2b5d
feat(docs_and_test): add Bazel macro chaining tests/coverage with docs
antonkri 83f821c
feat(module-verification-report): per-component coverage dropdown
antonkri d78dae4
refactor(module-verification-report): drop redundant docnames tracking
antonkri ec067b6
Add mod_ver_report generation to module-verification-report directive
antonkri 0ee7de5
fix: collapse single-line logger.info call (ruff-format)
antonkri 374e0bf
docs(module-verification-report): document docs_and_test macro
antonkri 5402638
fix(module-verification-report): omit zero-coverage rows; add -- sepa…
antonkri ca810be
refactor: split docs_and_test macro out into #759
antonkri f957b81
refactor: remove testcase result annotation, now covered by #739
antonkri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| .. | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| .. _module_verification_report: | ||
|
|
||
| Module Verification Report extension | ||
| ==================================== | ||
|
|
||
| ``score_module_verification_report`` provides the | ||
| ``.. module-verification-report::`` directive, which expands into the | ||
| standard per-module verification report: a feature summary, a component | ||
| overview table, and one detailed section per component. Traceability is | ||
| resolved by sphinx-needs at render time — the directive only emits | ||
| ``.. needtable::`` / ``.. needpie::`` widgets with the right filters. | ||
|
|
||
| The extension is part of the :ref:`score_sphinx_bundle<extensions>`. | ||
| No external config file is required for the common case. | ||
|
|
||
| Typical usage (``verification_report/module_verification_report.rst``): | ||
|
|
||
| .. code-block:: rst | ||
|
|
||
| .. module-verification-report:: | ||
| :module-id: mod__mymodule | ||
| :components: comp__mymodule_a, comp__mymodule_b | ||
|
|
||
| .. _mvr_directive: | ||
|
|
||
| Options | ||
| ------- | ||
|
|
||
| .. list-table:: | ||
| :header-rows: 1 | ||
| :widths: 22 12 66 | ||
|
|
||
| * - Option | ||
| - Required | ||
| - Description | ||
|
|
||
| * - ``:module-id:`` | ||
| - yes | ||
| - sphinx-needs id of the ``.. mod::`` need (e.g. ``mod__mymodule``). | ||
| Drives defaults for ``:feature-id:`` and ``:component-prefix:``. | ||
|
|
||
| * - ``:components:`` | ||
| - yes | ||
| - Comma-separated list of ``.. comp::`` need ids. Multi-line values | ||
| are supported. Optional ``[version==N]`` qualifiers are stripped. | ||
|
|
||
| * - ``:feature-id:`` | ||
| - no | ||
| - sphinx-needs id of the ``.. feat::`` need. Default: | ||
| ``feat__<module-short>`` (derived from ``:module-id:``). | ||
|
|
||
| * - ``:component-prefix:`` | ||
| - no | ||
| - Prefix stripped from each component id to derive its slug (used | ||
| for section headings and document-id matching). Default: | ||
| ``comp__<module-short>_``. | ||
|
|
||
| * - ``:safety:`` | ||
| - yes | ||
| - ASIL classification of the module. One of ``QM`` or ``ASIL_B``. | ||
|
|
||
| * - ``:security:`` | ||
| - yes | ||
| - Whether the module is security-relevant. One of ``YES`` or ``NO``. | ||
|
|
||
| * - ``:status:`` | ||
| - yes | ||
| - Review status of the report. One of ``valid`` or ``invalid``. | ||
|
|
||
| * - ``:verification-method:`` | ||
| - yes | ||
| - Free-text description of how the module was verified, e.g. | ||
| ``test_and_inspection``. | ||
|
|
||
| * - ``:version:`` | ||
| - no | ||
| - Version of the emitted ``mod_ver_report`` need. Default: ``1``. | ||
|
|
||
| Metamodel validation | ||
| -------------------- | ||
|
|
||
| ``:safety:``, ``:security:``, ``:status:``, ``:verification-method:`` and | ||
| ``:version:`` are not just directive options — the directive uses them to | ||
| emit a single sphinx-needs ``mod_ver_report`` need (id | ||
| ``mod_vrep__<module-short>__report``, linked ``belongs_to`` the module's | ||
| ``.. mod::`` need). This need type, its id format and the allowed values | ||
| for each option are declared in ``score_metamodel``'s ``metamodel.yaml`` | ||
| (``mod_ver_report`` entry). | ||
|
|
||
| Every generated need is checked against that definition by the | ||
| ``score_metamodel`` Sphinx extension as part of the regular build. If any | ||
| value does not match the expected pattern (e.g. ``:safety: ASIL_D``, which | ||
| is not one of ``QM``/``ASIL_B``), a mandatory option is missing, or the id | ||
| does not follow the required ``<prefix>__<abbreviation>__<element>`` | ||
| scheme, ``score_metamodel`` reports a warning. Since the documentation | ||
| build runs Sphinx with ``-W`` (warnings treated as errors), any such | ||
| mismatch aborts the build instead of silently producing an inconsistent | ||
| report. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
| load("@aspect_rules_py//py:defs.bzl", "py_library") | ||
| load("@docs_as_code_hub_env//:requirements.bzl", "all_requirements") | ||
| load("//:score_pytest.bzl", "score_pytest") | ||
|
|
||
| filegroup( | ||
| name = "sources", | ||
| srcs = glob(["*.py"]), | ||
| ) | ||
|
|
||
| filegroup( | ||
| name = "tests", | ||
| srcs = glob(["tests/*.py"]), | ||
| ) | ||
|
|
||
| filegroup( | ||
| name = "all_sources", | ||
| srcs = [ | ||
| ":sources", | ||
| ":tests", | ||
| ], | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
|
|
||
| py_library( | ||
| name = "score_module_verification_report", | ||
| srcs = [":sources"], | ||
| imports = ["."], | ||
| visibility = ["//visibility:public"], | ||
| deps = all_requirements + [ | ||
| "@score_docs_as_code//src/helper_lib", | ||
| ], | ||
| ) | ||
|
|
||
| score_pytest( | ||
| name = "score_module_verification_report_tests", | ||
| size = "small", | ||
| srcs = glob(["tests/*.py"]), | ||
| deps = [":score_module_verification_report"], | ||
| pytest_config = "//:pyproject.toml", | ||
| ) |
77 changes: 77 additions & 0 deletions
77
src/extensions/score_module_verification_report/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
| """Sphinx extension that generates the per-module verification report body. | ||
|
|
||
| Usage in RST:: | ||
|
|
||
| .. module-verification-report:: | ||
| :module-id: mod__baselibs | ||
| :feature-id: feat__baselibs | ||
| :safety: ASIL_B | ||
| :security: YES | ||
| :status: valid | ||
| :verification-method: test_and_inspection | ||
| :components: comp__baselibs_json, | ||
| comp__baselibs_bit_manipulation, | ||
| comp__baselibs_containers | ||
|
|
||
| ``safety``/``security``/``status``/``verification-method`` are the | ||
| mandatory options of the sphinx-needs ``mod_ver_report`` need type (see | ||
| metamodel.yaml). The directive emits one such need | ||
| (``belongs_to: module-id``) so the report is machine-readable and its | ||
| links are validated by score_metamodel's generic need-link checks — | ||
| not just rendered RST. | ||
|
|
||
| Implementation is split across: | ||
|
|
||
| * :mod:`.templates` — RST templates + default workproduct lists + CSS | ||
| * :mod:`.rendering` — template expansion / report body assembly | ||
| * :mod:`.directive` — the ``ModuleVerificationReportDirective`` class | ||
| * :mod:`.consistency_checks` — ``build-finished`` validation that every | ||
| component is properly linked in the needs graph | ||
|
|
||
| Testcase back-links rendered by this directive are annotated with a | ||
| ``(passed)`` / ``(failed)`` result badge by | ||
| ``score_source_code_linker``'s ``doctree-resolved`` hook, not by this | ||
| extension. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| from .consistency_checks import ( | ||
| check_consistency, | ||
| init_registry, | ||
| merge_registry, | ||
| purge_registry, | ||
| ) | ||
| from .directive import ModuleVerificationReportDirective | ||
|
|
||
|
|
||
| def setup(app: Any) -> dict: | ||
| app.add_directive("module-verification-report", ModuleVerificationReportDirective) | ||
| app.add_config_value( | ||
| "mvr_coverage_lcov", | ||
| "bazel-out/_coverage/_coverage_report.dat", | ||
| "env", | ||
| ) | ||
| app.connect("env-before-read-docs", init_registry) | ||
| app.connect("env-purge-doc", purge_registry) | ||
| app.connect("env-merge-info", merge_registry) | ||
| app.connect("build-finished", check_consistency) | ||
| return { | ||
| "version": "0.9", | ||
| "parallel_read_safe": True, | ||
| "parallel_write_safe": True, | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There already is
mod_ver_reportin the metamodel. This should probably be added into the template here for process compliance.Also, we can extend
mod_ver_reportand then leave the consistency checking to existing mechanisms in the score_metamodel extension.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I've extended code and configuration to generate the mod_verification_report, for now only with mandatory arguments.