Skip to content

refactor(module-verification-report): split, tests, docs - #730

Draft
antonkri wants to merge 8 commits into
mainfrom
ankr_mod_verf_report
Draft

refactor(module-verification-report): split, tests, docs#730
antonkri wants to merge 8 commits into
mainfrom
ankr_mod_verf_report

Conversation

@antonkri

@antonkri antonkri commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This PR introduces an extension to generate a module verification report, that can be used by every module. For detailed documentation see module_verification_report.rst

See eclipse-score/baselibs#491 (comment) for an example usage

@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

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: 04ec4de5-5838-4d0a-a69c-8440e52992fb
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.712s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

Comment on lines +57 to +59
* - Config option
- ``:config: <path>`` — YAML file resolved relative to Sphinx's
``srcdir`` (i.e. the directory containing ``conf.py``).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a YAML file? Could we configure it via directive attributes instead?

Comment on lines +61 to +63
* - Reads from the source tree
- Every ``.. mod::`` and ``.. comp::`` need, discovered by a
shallow regex scan at ``env-before-read-docs`` time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading the source tree is an anti-pattern. Could use a needs filter instead?

Comment on lines +15 to +20
We deliberately do **not** query ``SphinxNeedsData`` here: doing so would
require reading the report source strictly after every source registering
a ``.. comp::`` / ``.. document::`` need, which forces
``parallel_read_safe = False`` on the extension and produces two
Sphinx-level warnings per build (``the score_module_verification_report
extension is not safe for parallel reading`` / ``doing serial read``).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking through the PR, this is the most obvious red flag that we need to investigate. scanning source code is less than ideal.

antonkri added a commit to eclipse-score/baselibs that referenced this pull request Aug 19, 2026
…cation_report

Demonstrates the .. module-verification-report:: directive shipped by
the ankr_mod_verf_report branch of score_docs_as_code
(eclipse-score/docs-as-code#730):

- Replace the hand-maintained ~2700-line
  docs/reporting/module_verification_report.rst with a two-line
  invocation of the new directive, driven by
  docs/reporting/module_report.yaml (module_id, feature_id, standard
  workproducts).
- Bump score_docs_as_code git_override to a66bf953 (tip of
  ankr_mod_verf_report — refactor + tests + docs + testcase_annotations).
- Drop the tracked bitmanipulation coverage HTML dump under
  coverage_reports/bitmanipulation and the derived
  docs/reporting/coverage_summary.json snapshot together with the
  tools/extract_coverage.py script that produced it.
- Strip the legacy _load_coverage_substitutions() and testcase-badge
  setup() helpers from docs/conf.py — the former's input file is
  gone, the latter now lives in the shared extension as
  testcase_annotations.
antonkri added a commit to eclipse-score/baselibs that referenced this pull request Aug 19, 2026
…cation_report

Demonstrates the ``.. module-verification-report::`` directive shipped by
the ``ankr_mod_verf_report`` branch of ``score_docs_as_code``
(eclipse-score/docs-as-code#730):

- Add a new page ``docs/reporting/module_verification_report.rst`` that
  only carries the ``.. document::`` need and the two-line invocation
  of the new directive, driven by ``docs/reporting/module_report.yaml``
  (module_id, feature_id, five standard workproducts).
- Hook the new page into ``docs/index.rst`` under a fresh "Reporting"
  section in the top-level toctree.
- Pin ``score_docs_as_code`` via ``git_override`` to a66bf953 — tip of
  ankr_mod_verf_report (refactor + tests + docs + testcase_annotations).
- Extend the existing gtest suites for ``bit_manipulation``,
  ``bitmask_operators`` and the ``flatbuffers/details`` unit tests
  with additional cases that fill in the coverage the module report is
  meant to visualise.
- Keep ``docs/conf.py`` minimal — no coverage-substitution helper, no
  testcase-badge ``setup`` (that logic now lives in the shared
  extension as ``testcase_annotations``).
antonkri added a commit to eclipse-score/baselibs that referenced this pull request Aug 19, 2026
…cation_report

Demonstrates the ``.. module-verification-report::`` directive shipped by
the ``ankr_mod_verf_report`` branch of ``score_docs_as_code``
(eclipse-score/docs-as-code#730):

- Add a new page ``docs/reporting/module_verification_report.rst`` that
  only carries the ``.. document::`` need and the two-line invocation
  of the new directive, driven by ``docs/reporting/module_report.yaml``
  (module_id, feature_id, five standard workproducts).
- Hook the new page into ``docs/index.rst`` under a fresh "Reporting"
  section in the top-level toctree.
- Pin ``score_docs_as_code`` via ``git_override`` to a66bf953 — tip of
  ankr_mod_verf_report (refactor + tests + docs + testcase_annotations).
- Extend the existing gtest suites for ``bit_manipulation``,
  ``bitmask_operators`` and the ``flatbuffers/details`` unit tests
  with additional cases that fill in the coverage the module report is
  meant to visualise.
- Keep ``docs/conf.py`` minimal — no coverage-substitution helper, no
  testcase-badge ``setup`` (that logic now lives in the shared
  extension as ``testcase_annotations``).
Adds score_module_verification_report to the score_sphinx_bundle.
Provides the .. module-verification-report:: directive that renders
a per-module verification report body from a YAML config:

- Component overview via sphinx-needs
- Per-component Verification & Safety Analysis Documents table with
  Status column, delegated to sphinx-needs via .. needtable::
- Feature section (requirements / architecture / inspection stats)

Extracted from baselibs' local docs/_ext/module_report.py so any
consumer of docs-as-code can now use the directive without a local
copy.
…dules

Move the 909-line monolithic __init__.py into five thin modules so each
layer can be reviewed and tested independently:

* scanner.py   - filesystem regex scan for .. mod:: / .. comp::
* coverage.py  - coverage_summary.json loading + intro selection
* templates.py - RST templates, WP-table CSS, default workproducts
* rendering.py - pure template-expansion helpers
* directive.py - the Sphinx directive class

__init__.py is now a thin entry point (only setup() and re-exports).
BUILD is aligned with score_mounts (sources / tests filegroups) and
still exposes the same py_library target name, so the sphinx bundle
consumer needs no change.

The public surface is unchanged: the directive name, the config schema,
env.module_verification_report_needs and the setup() return value all
stay identical. Verified end-to-end against baselibs via
local_path_override: the rendered report is byte-for-byte equivalent
(same 42 wp-doc-table occurrences).
36 pytest cases exercising every branch of the pure layers:

* test_scanner.py   (15 tests): scan_rst_needs, module_includes,
  discover_components, scan_source_tree. Covers directive filtering,
  version-pinned includes, non-utf-8 files, deep walks, prefix
  mismatches, missing env attribute.
* test_coverage.py  (8 tests): load_coverage_summary (missing / invalid
  / null JSON, note_dependency), coverage_intro (measured vs.
  specification-only decision, trailing blank line).
* test_rendering.py (13 tests): slug utilities, override vs. filter
  work-product rows, render_component / render_feature substitutions
  and end-to-end render_report assembly (with feature and component
  overrides).

BUILD adds score_pytest(name = 'score_module_verification_report_tests').
Follows the existing score_mounts test pattern.
New src/extensions/docs/module_verification_report.rst documents:

* the .. module-verification-report:: directive (arguments, options,
  fatal errors, warnings);
* the YAML config schema, with defaults derived from module_id;
* the sphinx-needs data model the extension reads or filters by
  (.. mod:: / .. comp:: / .. feat:: / .. wp:: / .. document:: /
  comp_req / comp_arc_* / feat_req / feat_arc_*);
* what the read-hook actually scans and why (regex over srcdir, not
  SphinxNeedsData, to keep parallel_read_safe = True);
* the report structure (CSS, feature section, component overview, per
  component sections);
* work-product row rendering (override vs. sphinx-needs filter path,
  including the underscore-free slug normalisation);
* the optional coverage_summary.json integration and its currently
  disabled section;
* the 5-module architecture and public surface;
* known limitations (feature-only repos, line-scan boundary conditions,
  nested DataTables cost);
* how to run the unit tests.

The extensions landing page (index.rst) gains a grid card and a
toctree entry pointing to the new page.
…esult

Moves the doctree-resolved handler that previously lived in each
consumer's docs/conf.py (baselibs, etc.) into the shared extension as
a new module 'testcase_annotations'. It walks doctree references whose
visible text starts with 'testcase__', looks up the corresponding
sphinx-needs entry via SphinxNeedsData.get_needs_view() and appends a
coloured '(passed)' / '(failed)' / '(skipped)' / '(disabled)' badge in
the same palette as the report pie charts.

To keep the hook scoped to pages that actually render the directive
(and to avoid affecting unrelated docs), the directive registers its
docname in env.module_verification_report_docnames. The lifecycle is
kept parallel-read-safe via three matching handlers:

  - env-before-read-docs -> init_docnames  (create the set)
  - env-purge-doc         -> purge_docname  (drop stale entries)
  - env-merge-info        -> merge_docnames (union worker sets)

Also:
- 16 unit tests covering every branch (colours, fallback, no-op paths,
  lifecycle handlers) — no dependency on sphinx-needs being installed.
- Extension reference page updated: architecture table gains the new
  module, public surface list mentions the new env attribute, testing
  section mentions the new test file.
- Version bumped 0.6 -> 0.7.
@antonkri
antonkri force-pushed the ankr_mod_verf_report branch from a66bf95 to 9a95bd0 Compare August 19, 2026 14:46
antonkri added a commit to eclipse-score/baselibs that referenced this pull request Aug 19, 2026
…cation_report

Demonstrates the ``.. module-verification-report::`` directive shipped by
the ``ankr_mod_verf_report`` branch of ``score_docs_as_code``
(eclipse-score/docs-as-code#730):

- Add a new page ``docs/reporting/module_verification_report.rst`` that
  only carries the ``.. document::`` need and the two-line invocation
  of the new directive, driven by ``docs/reporting/module_report.yaml``
  (module_id, feature_id, five standard workproducts).
- Hook the new page into ``docs/index.rst`` under a fresh "Reporting"
  section in the top-level toctree.
- Pin ``score_docs_as_code`` via ``git_override`` to a66bf953 — tip of
  ankr_mod_verf_report (refactor + tests + docs + testcase_annotations).
- Extend the existing gtest suites for ``bit_manipulation``,
  ``bitmask_operators`` and the ``flatbuffers/details`` unit tests
  with additional cases that fill in the coverage the module report is
  meant to visualise.
- Keep ``docs/conf.py`` minimal — no coverage-substitution helper, no
  testcase-badge ``setup`` (that logic now lives in the shared
  extension as ``testcase_annotations``).
…ent-prefix options

Replace the mandatory :config: YAML file with direct RST directive
options so the common case requires no external file at all:

  .. module-verification-report::
     :module-id: mod__mymodule

feature-id defaults to feat__<module-short> and component-prefix
defaults to comp__<module-short>_ when omitted. :config: is retained
as an optional escape hatch for non-default workproducts and
per-component doc-id overrides; fields in the file are ignored when
the corresponding directive option is set.

Also: 12 unit tests in test_directive.py covering the option-vs-config
precedence rules and all derivation paths; extension reference docs
updated (typical usage, at-a-glance table, directive reference,
config schema section retitled to 'advanced'); version unchanged.
antonkri added a commit to eclipse-score/baselibs that referenced this pull request Aug 20, 2026
…cation_report

Demonstrates the ``.. module-verification-report::`` directive shipped by
the ``ankr_mod_verf_report`` branch of ``score_docs_as_code``
(eclipse-score/docs-as-code#730):

- Add a new page ``docs/reporting/module_verification_report.rst`` that
  only carries the ``.. document::`` need and the two-line invocation
  of the new directive, driven by ``docs/reporting/module_report.yaml``
  (module_id, feature_id, five standard workproducts).
- Hook the new page into ``docs/index.rst`` under a fresh "Reporting"
  section in the top-level toctree.
- Pin ``score_docs_as_code`` via ``git_override`` to a66bf953 — tip of
  ankr_mod_verf_report (refactor + tests + docs + testcase_annotations).
- Extend the existing gtest suites for ``bit_manipulation``,
  ``bitmask_operators`` and the ``flatbuffers/details`` unit tests
  with additional cases that fill in the coverage the module report is
  meant to visualise.
- Keep ``docs/conf.py`` minimal — no coverage-substitution helper, no
  testcase-badge ``setup`` (that logic now lives in the shared
  extension as ``testcase_annotations``).
antonkri added a commit to eclipse-score/baselibs that referenced this pull request Aug 20, 2026
…cation_report

Demonstrates the ``.. module-verification-report::`` directive shipped by
the ``ankr_mod_verf_report`` branch of ``score_docs_as_code``
(eclipse-score/docs-as-code#730):

- Add a new page ``docs/reporting/module_verification_report.rst`` that
  only carries the ``.. document::`` need and the two-line invocation
  of the new directive, driven by ``docs/reporting/module_report.yaml``
  (module_id, feature_id, five standard workproducts).
- Hook the new page into ``docs/index.rst`` under a fresh "Reporting"
  section in the top-level toctree.
- Pin ``score_docs_as_code`` via ``git_override`` to a66bf953 — tip of
  ankr_mod_verf_report (refactor + tests + docs + testcase_annotations).
- Extend the existing gtest suites for ``bit_manipulation``,
  ``bitmask_operators`` and the ``flatbuffers/details`` unit tests
  with additional cases that fill in the coverage the module report is
  meant to visualise.
- Keep ``docs/conf.py`` minimal — no coverage-substitution helper, no
  testcase-badge ``setup`` (that logic now lives in the shared
  extension as ``testcase_annotations``).
antonkri added a commit to eclipse-score/baselibs that referenced this pull request Aug 20, 2026
…cation_report

Demonstrates the ``.. module-verification-report::`` directive shipped by
the ``ankr_mod_verf_report`` branch of ``score_docs_as_code``
(eclipse-score/docs-as-code#730):

- Add a new page ``docs/reporting/module_verification_report.rst`` that
  only carries the ``.. document::`` need and the two-line invocation
  of the new directive, driven by ``docs/reporting/module_report.yaml``
  (module_id, feature_id, five standard workproducts).
- Hook the new page into ``docs/index.rst`` under a fresh "Reporting"
  section in the top-level toctree.
- Pin ``score_docs_as_code`` via ``git_override`` to a66bf953 — tip of
  ankr_mod_verf_report (refactor + tests + docs + testcase_annotations).
- Extend the existing gtest suites for ``bit_manipulation``,
  ``bitmask_operators`` and the ``flatbuffers/details`` unit tests
  with additional cases that fill in the coverage the module report is
  meant to visualise.
- Keep ``docs/conf.py`` minimal — no coverage-substitution helper, no
  testcase-badge ``setup`` (that logic now lives in the shared
  extension as ``testcase_annotations``).
…omponents: option

Instead of scanning .rst files at env-before-read-docs time to resolve
the mod's :includes: list, component ids are now declared directly on
the directive:

  .. module-verification-report::
     :module-id: mod__baselibs
     :feature-id: feat__baselibs
     :components: comp__baselibs_json,
                  comp__baselibs_bit_manipulation, ...

Changes:
- scanner.py removed entirely (no filesystem walk, no regex parsing,
  no env.module_verification_report_needs attribute).
- env-before-read-docs hook for scan_source_tree removed from setup().
- _parse_components() helper in directive.py: splits on commas, strips
  optional [version==N] qualifiers, derives slug by stripping
  component_prefix, derives title from slug (underscore -> space,
  title-case).
- Error if :components: is empty / omitted.
- Version bumped 0.7 -> 0.8.
- test_scanner.py removed; test_directive.py extended with 9 tests for
  _parse_components (id parsing, version stripping, title derivation,
  whitespace handling, multi-line values, prefix mismatch).
- Reference docs updated: typical usage, at-a-glance table, directive
  reference (:components: option), 'No filesystem scan' rationale
  section replaces 'Filesystem scan' section, architecture table updated
  to five modules, limitations updated, testing section updated.
@antonkri
antonkri force-pushed the ankr_mod_verf_report branch from bab116b to 1cb9250 Compare August 20, 2026 08:51
antonkri added a commit to eclipse-score/baselibs that referenced this pull request Aug 20, 2026
…cation_report

Demonstrates the ``.. module-verification-report::`` directive shipped by
the ``ankr_mod_verf_report`` branch of ``score_docs_as_code``
(eclipse-score/docs-as-code#730):

- Add a new page ``docs/reporting/module_verification_report.rst`` that
  only carries the ``.. document::`` need and the two-line invocation
  of the new directive, driven by ``docs/reporting/module_report.yaml``
  (module_id, feature_id, five standard workproducts).
- Hook the new page into ``docs/index.rst`` under a fresh "Reporting"
  section in the top-level toctree.
- Pin ``score_docs_as_code`` via ``git_override`` to a66bf953 — tip of
  ankr_mod_verf_report (refactor + tests + docs + testcase_annotations).
- Extend the existing gtest suites for ``bit_manipulation``,
  ``bitmask_operators`` and the ``flatbuffers/details`` unit tests
  with additional cases that fill in the coverage the module report is
  meant to visualise.
- Keep ``docs/conf.py`` minimal — no coverage-substitution helper, no
  testcase-badge ``setup`` (that logic now lives in the shared
  extension as ``testcase_annotations``).
@antonkri
antonkri force-pushed the ankr_mod_verf_report branch 2 times, most recently from d3f2719 to 0af2a93 Compare August 20, 2026 10:45
@github-actions

Copy link
Copy Markdown
Contributor

Documentation preview for this pull request is available at:
pr-730: https://eclipse-score.github.io/docs-as-code/pr-730/

@antonkri
antonkri force-pushed the ankr_mod_verf_report branch 4 times, most recently from 590b548 to 5c956f5 Compare August 20, 2026 11:34
…inished

Add consistency_checks.py with a build-finished hook that warns when:
- a component listed in :components: is not in the module need's :includes:
- the feature ID is not in the component need's :belongs_to:

The check is entirely passive (Sphinx warnings, no build failure) and
requires no configuration in consumer repos. The registry is populated
by the directive during the read phase and is parallel-read safe via
init_registry / purge_registry / merge_registry lifecycle hooks.

17 new unit tests (75 total). Version bumped to 0.9.
@antonkri
antonkri force-pushed the ankr_mod_verf_report branch from 5c956f5 to 6fdb693 Compare August 20, 2026 12:12
antonkri added a commit to eclipse-score/baselibs that referenced this pull request Aug 20, 2026
…cation_report

Demonstrates the ``.. module-verification-report::`` directive shipped by
the ``ankr_mod_verf_report`` branch of ``score_docs_as_code``
(eclipse-score/docs-as-code#730):

- Add a new page ``docs/reporting/module_verification_report.rst`` that
  only carries the ``.. document::`` need and the two-line invocation
  of the new directive, driven by ``docs/reporting/module_report.yaml``
  (module_id, feature_id, five standard workproducts).
- Hook the new page into ``docs/index.rst`` under a fresh "Reporting"
  section in the top-level toctree.
- Pin ``score_docs_as_code`` via ``git_override`` to a66bf953 — tip of
  ankr_mod_verf_report (refactor + tests + docs + testcase_annotations).
- Extend the existing gtest suites for ``bit_manipulation``,
  ``bitmask_operators`` and the ``flatbuffers/details`` unit tests
  with additional cases that fill in the coverage the module report is
  meant to visualise.
- Keep ``docs/conf.py`` minimal — no coverage-substitution helper, no
  testcase-badge ``setup`` (that logic now lives in the shared
  extension as ``testcase_annotations``).
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.

3 participants