Skip to content

Transfer the 'report' domain from sphinx-reports into pyTooling.Sphinx - #20

Merged
Paebbels merged 9 commits into
devfrom
claude/report-domain
Oct 6, 2026
Merged

Paebbels merged 9 commits into
devfrom
claude/report-domain

Conversation

@pytooling-claude

Copy link
Copy Markdown

New Features

  • pyTooling.Sphinx: the domain report of sphinx-reports (v0.11.2), registered by the extension itself - a project enables only "pyTooling.Sphinx".
    • Directives: report:unittest-summary, report:code-coverage, report:code-coverage-legend, report:doc-coverage, report:doc-coverage-legend, and the prototype report:module-coverage.
    • New modules: pyTooling.Sphinx.CodeCoverage, .DocCoverage, .Unittest, .Workaround, .Adapter.Coverage and .DataModel.CodeCoverage. ReportDomain, ReportExtensionError (derived from SphinxExtensionError), ReportsPackageMissingError, LegendStyle and the call-backs checkReportConfiguration/readReports are in pyTooling.Sphinx.
    • setup() registers the domain, its directives (from one mapping), the configuration values, the LaTeX package pdflscape and the post-transform FixLatexTableWidths.
  • New extra reports: pyEDAA.Reports and docstr_coverage. It is optional: pyTooling.Sphinx and its setup() don't import them. A report directive imports pyEDAA.Reports when it reads a report, and without it reports ReportsPackageMissingError ("Reading a unit test report needs 'pyEDAA.Reports', which isn't installed.") with the note Install it with: pip install pyTooling.Sphinx[reports].
  • pyTooling.Sphinx.Node.Landscape: the container node the wide report tables are put in, registered in NODES with visitors for HTML (pyTooling.Sphinx.HTML.translateLandscape, writes nothing) and LaTeX (new module pyTooling.Sphinx.LaTeX, a landscape environment).

Changes

  • BaseDirective._internalError logs the exception's notes below its message.

Compared to sphinx-reports:

  • The domain is registered by pyTooling.Sphinx instead of the extension sphinx_reports. It is still report, so documents keep writing .. report:code-coverage:: etc.

  • The configuration values are renamed to the pyTooling_ prefix:

    sphinx-reports pyTooling.Sphinx
    report_unittest_testsuites pyTooling_Unittest_Testsuites
    report_codecov_packages pyTooling_CodeCoverage_Packages
    report_codecov_levels pyTooling_CodeCoverage_Levels
    report_doccov_packages pyTooling_DocCoverage_Packages
    report_doccov_levels pyTooling_DocCoverage_Levels
  • report:dependency-table and its adapter and data model are not transferred; dependency-table of pyTooling.Sphinx replaces it.

  • The directives derive from pyTooling.Sphinx.BaseDirective; sphinx-reports' copy of it (sphinx_reports.Sphinx) is not transferred. :style: is read by BaseDirective._ParseEnumOption. An option error now reads Caught SphinxExtensionError when checking options ... instead of Caught ReportExtensionError ....

  • The report styles are a section of pyTooling.css; there is no separate sphinx-reports.<hash>.css. A theme's row stripes are reset for the report tables only - sphinx-reports reset them for every table of the documentation.

  • [REPORT] Reading ... reports is logged as info instead of printed, so sphinx-build -q hides it.

  • report:doc-coverage names itself doc-coverage in its messages instead of docstr-coverage.

  • FixLatexTableWidths is a SphinxPostTransform for LaTeX, instead of reading the deprecated BuildEnvironment.app (removed in Sphinx 11).

  • The data model and the adapter use ExtendedType(slots=True); Coverage declares _coveredBranches and _missingBranches. The code coverage data model no longer imports pyEDAA.Reports.

  • Internal helpers follow the naming convention, e.g. renderlevel → _RenderLevel, _formatTimedelta → _FormatTimedelta, package_DictType → PackageConfiguration.

Bug Fixes

  • report:code-coverage-legend and report:doc-coverage-legend raised NameError: name 'table' is not defined in style horizontal-table - their default style - which aborted the build. The horizontal legend renders now, with one row of levels (the code coverage legend repeated that row).
  • A package configuration whose levels is neither a palette's name nor a dictionary raised a ReportExtensionError with an empty message. It names the field now, and a note the type given.

Known Issues

Carried over from sphinx-reports unchanged:

  • levels given as a dictionary in a package configuration is accepted but loaded as an empty palette, so rendering that report fails; only a palette's name works.
  • A report file or directory that doesn't exist stops reading the configuration entries after it.
  • report:doc-coverage and report:doc-coverage-legend raise KeyError for a report ID that isn't configured, which aborts the build (the other directives report it on the page).
  • report:module-coverage shows the fixed file ../../sphinx_reports/__init__.py; it is a prototype.
  • The horizontal legend puts the level's CSS class on the cells, while the stylesheet colours rows, so it is uncoloured.
  • The legends accept :class:, but don't put it on the table.

Documentation

  • A page per directive group: report:unittest-summary, report:code-coverage and report:doc-coverage, ported from sphinx-reports, with examples rendered from the test fixtures. Index, README, News, installation and dependency pages describe the extra reports.
  • The documentation renders its own reports with the domain and the renamed configuration values instead of sphinx_reports.
  • suppress_warnings in doc/conf.py silences sphinx_autodoc_typehints.local_function, emitted for the __getstate__/__setstate__ methods ExtendedType adds to every class with slots.
  • pyEDAA.Reports isn't released for pyTooling 10 yet, so the extra and the requirements files install it from its dev branch, like pyTooling itself. The transferred code imports only pyEDAA.Reports.Unittesting.JUnit and pyEDAA.Reports.DocumentationCoverage.Python, which import with pyTooling 10; the JUnit dialect modules, which use InheritDocString(merge=True), aren't imported.
  • docstr_coverage is part of the extra: pyEDAA.Reports.DocumentationCoverage.Python imports it, but pyEDAA.Reports doesn't require it. Coverage is not: nothing imports it, the coverage report is read as JSON.

Unit Tests

  • tests/unit/DataModel.py: packages, modules, the hierarchy and the aggregated counts (instantiation testcases ported from sphinx-reports).
  • tests/unit/Adapter.py: reading a Coverage.py JSON report (fixture tests/data/Report/coverage.json), a missing file and an unsupported format.
  • tests/unit/CodeCoverage.py: the configuration checks and the coverage levels.
  • tests/unit/Unittest.py: ShowTestcases, the runtime format and the status symbols.
  • tests/unit/Reports.py: registration of the domain, directives and configuration values; builds in HTML and LaTeX (fixture tests/data/Report/unittest.xml); a missing report; a process checking that setup() doesn't import pyEDAA.Reports; and a process building reports without pyEDAA.Reports, checking the message and the install note.
  • tests/unit/Extension.py: Landscape is registered with HTML and LaTeX visitors.

Related Issues and Pull-Requests

@pytooling-claude
pytooling-claude Bot requested a review from Paebbels as a code owner October 6, 2026 01:15
@pytooling-claude pytooling-claude Bot added Documentation Improvements or additions to documentation Enhancement New feature or request labels Oct 6, 2026
@codacy-production

codacy-production Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 2 critical · 6 medium · 92 minor

Alerts:
⚠ 100 issues (≤ 0 issues of at least minor severity)

Results:
100 new issues

Category Results
UnusedCode 1 minor
Documentation 33 minor
ErrorProne 2 critical
CodeStyle 54 minor
Complexity 6 medium
4 minor

View in Codacy

🟢 Metrics 333 complexity · 28 duplication

Metric Results
Complexity 333
Duplication 28

View in Codacy

🟢 Coverage 82.37% diff coverage · +7.77% coverage variation

Metric Results
Coverage variation ✅ +7.77% coverage variation (-1.00%)
Diff coverage ✅ 82.37% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (97f6504) 1488 1025 68.88%
Head commit (091453d) 2604 (+1116) 1996 (+971) 76.65% (+7.77%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#20) 1123 925 82.37%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.98486% with 236 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.59%. Comparing base (b19ac51) to head (9d2f3fb).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
pyTooling/Sphinx/CodeCoverage.py 69.30% 87 Missing and 14 partials ⚠️
pyTooling/Sphinx/DocCoverage.py 68.24% 62 Missing and 12 partials ⚠️
pyTooling/Sphinx/Unittest.py 79.76% 43 Missing and 9 partials ⚠️
pyTooling/Sphinx/__init__.py 94.11% 3 Missing and 1 partial ⚠️
pyTooling/Sphinx/Workaround.py 83.33% 1 Missing and 2 partials ⚠️
pyTooling/Sphinx/Adapter/Coverage.py 96.29% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #20      +/-   ##
==========================================
+ Coverage   63.61%   72.59%   +8.98%     
==========================================
  Files          10       17       +7     
  Lines        1311     2427    +1116     
  Branches      220      342     +122     
==========================================
+ Hits          834     1762     +928     
- Misses        466      610     +144     
- Partials       11       55      +44     
Flag Coverage Δ
unittests 72.59% <78.98%> (+8.98%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

claude-code and others added 9 commits October 6, 2026 13:10
The node comes from sphinx-reports, whose report tables it holds. It joins
'NODES' with visitors for HTML (no output) and for LaTeX, in the new module
'pyTooling.Sphinx.LaTeX'.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
…ing.Sphinx.Report'

The domain keeps its name and its directives - unittest-summary,
code-coverage, code-coverage-legend, module-coverage, doc-coverage and
doc-coverage-legend - and is enabled as the extension
'pyTooling.Sphinx.Report', which sets up 'pyTooling.Sphinx' first. It reads
the reports with pyEDAA.Reports, which the new extra 'reports' installs, so
the core extension stays free of that dependency.

The configuration values are renamed to the 'pyTooling_' prefix:
pyTooling_CodeCoverage_Packages/_Levels, pyTooling_DocCoverage_Packages/_Levels
and pyTooling_Unittest_Testsuites.

The directives use pyTooling.Sphinx's BaseDirective, and the report styles
become a section of pyTooling.css. sphinx-reports' dependency table is not
transferred; pyTooling.Sphinx has its own.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
The data model testcases are ported from sphinx-reports. New testcases cover
the code coverage adapter, the configuration checks, the unit test summary's
helpers, and builds in HTML and LaTeX; one checks that setting up
'pyTooling.Sphinx' alone doesn't import pyEDAA.Reports.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
A page per directive group - report:unittest-summary, report:code-coverage
and report:doc-coverage -, ported from sphinx-reports' documentation, with
examples rendered from the test fixtures. The index, the README, the News,
the installation and dependency pages and the module doc-string say how to
install the extra 'reports' and enable 'pyTooling.Sphinx.Report'.

The own documentation uses 'pyTooling.Sphinx.Report' and the renamed
configuration values instead of sphinx_reports, which leaves
doc/requirements.txt in favour of the extra's requirements.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
The unit test summary and the documentation coverage table import
pyEDAA.Reports when they read a report, and its types only for type checking.
Without the extra 'reports', the directive reports a
ReportsPackageMissingError naming the packages it needs, with a note how to
install them; setting up the extension and checking its configuration don't
need them. BaseDirective._internalError logs an exception's notes.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
The domain 'report' is registered by the extension 'pyTooling.Sphinx' itself;
the separate extension 'pyTooling.Sphinx.Report' is gone.

* Report/{CodeCoverage,DocCoverage,Unittest,Workaround}.py, Report/Adapter
  and Report/DataModel move one level up.
* ReportDomain, ReportExtensionError, ReportsPackageMissingError,
  LegendStyle and INDENTATION move into pyTooling/Sphinx/__init__.py; the
  call-backs become checkReportConfiguration and readReports.
* setup() imports the report modules lazily like the other directives and
  registers the domain, its directives from one mapping, the configuration
  values, 'pdflscape' and FixLatexTableWidths.

The extra 'reports' stays optional: nothing setup() imports needs
pyEDAA.Reports. Documentation, README, News and tests follow the new layout.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
… methods

ExtendedType gives every class with slots '__getstate__' and '__setstate__',
whose type hints sphinx_autodoc_typehints can't read, so it warned twice per
such class.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
…omain code

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
…y side

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation Enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants