epythet.validation.rendered¶
Level 2: read the rendered output (XML, HTML, text) and report what the build hid.
A strict build is silent about most of what a reader sees wrong (research
§2.2): an object listed with no description, a cross-reference that rendered
as plain code, a link to an anchor Sphinx pruned, an image that is not in the
built tree. This level renders three builders through the backend= seam
(render()) and reads each for
what it shows best (research §5.4):
xmlfor structure: empty object descriptions and unresolved cross-references (aliteralwith classxrefthat noreferencewraps, detectable without-n);htmlfor links and assets: dangling#idNanchors and<img src>that resolve to nothing in the built tree;textfor snapshots: a 4 KB page that keeps every text-leak artifact verbatim and none of the theme, diffed againstdocsrc/_snapshots/textwhensnapshot=True.
Only the standard library parses the output (xml.etree and html.parser):
the pages are Sphinx’s own, not untrusted input. Snapshots are opt-in and
off by default; update_snapshots=True re-baselines.
>>> from epythet.validation.rendered import dangling_anchors
>>> dangling_anchors('<a id="x"></a><a href="#x">ok</a><a href="#id7">gone</a>')
['#id7']
Module Attributes
Where |
|
Rule ids this level reports under (all bundled; see |
|
A detector takes |
|
Detector name (as in a rule's |
Functions
|
Pages level 3 should review: changed or new relative to the snapshot. |
|
Diff every rendered text page against its stored snapshot. |
|
Fragment links on a page whose target id does not exist on that page. |
|
Level-2 detector over the |
|
Level-2 detector over the |
|
Objects the page lists or describes with no text at all. |
|
|
|
Level-2 detector over the |
|
Register a level-2 detector; the ledger loader validates |
|
Run every |
|
Level 2: render html, text and xml into |
|
One DR035 finding per changed page, plus info findings for new and removed pages. |
|
DR035's detector is the snapshot diff, driven by |
|
Level-2 detector over the |
|
Cross-references that rendered as plain code: an |
|
Replace the stored snapshots with the current render; returns pages written. |
Classes
|
What level 2 leaves behind for level 3: output dirs and the snapshot diff. |
|
One thing a render detector found on one page. |
|
How the |
- epythet.validation.rendered.EMPTY_DESCRIPTION = 'DR026'¶
Rule ids this level reports under (all bundled; see
epythet/ledger/rules).
- epythet.validation.rendered.RENDER_DETECTORS: dict[str, Callable[[dict[str, Path], Path], list[RenderHit]]] = {'dangling_anchors': <function dangling_anchors_detector>, 'empty_descriptions': <function empty_descriptions>, 'missing_images': <function missing_images_detector>, 'text_snapshots': <function text_snapshots_detector>, 'unresolved_xrefs': <function unresolved_xrefs>}¶
Detector name (as in a rule’s
detector.function) -> function.
- class epythet.validation.rendered.RenderArtifacts(outdirs=<factory>, docsrc=None, snapshot=None)[source]¶
Bases:
objectWhat level 2 leaves behind for level 3: output dirs and the snapshot diff.
- epythet.validation.rendered.RenderDetector¶
A detector takes
{builder: outdir}and the Sphinx source dir.
- class epythet.validation.rendered.RenderHit(page, evidence, object=None)[source]¶
Bases:
objectOne thing a render detector found on one page.
- epythet.validation.rendered.SNAPSHOT_DIRNAME = '_snapshots/text'¶
Where
-b textsnapshots live, relative to the Sphinx source directory.
- class epythet.validation.rendered.SnapshotDiff(changed=<factory>, added=<factory>, removed=<factory>, compared=0)[source]¶
Bases:
objectHow the
-b textrender compares with the stored snapshots.
- epythet.validation.rendered.changed_pages(diff)[source]¶
Pages level 3 should review: changed or new relative to the snapshot.
- epythet.validation.rendered.compare_snapshots(text_dir, snapshot_dir)[source]¶
Diff every rendered text page against its stored snapshot.
- Return type:
- epythet.validation.rendered.dangling_anchors(html)[source]¶
Fragment links on a page whose target id does not exist on that page.
This is the research’s exact detector (§6.3): every
problematicspan Sphinx emits links to a#idNsystem message it then prunes, and a hand-written:ref:to a missing label ends the same way.
- epythet.validation.rendered.dangling_anchors_detector(outdirs, _docsrc)[source]¶
Level-2 detector over the
htmloutput (DR027).
- epythet.validation.rendered.empty_descriptions(outdirs, _docsrc)[source]¶
Level-2 detector over the
xmloutput (DR026).
- epythet.validation.rendered.empty_descriptions_in(root)[source]¶
Objects the page lists or describes with no text at all.
Two shapes: a
descwhosedesc_contentholds nothing but generated paragraphs, index entries and nested objects; and an autosummary row whose summary cell is an empty paragraph (autodoc leaves undocumented members out of the page entirely, so the table row is all a reader sees).
- epythet.validation.rendered.missing_images(html, *, page_dir)[source]¶
<img src>values that resolve to no file next to the page.
- epythet.validation.rendered.missing_images_detector(outdirs, _docsrc)[source]¶
Level-2 detector over the
htmloutput (DR024 at level 2).
- epythet.validation.rendered.render_detector(name)[source]¶
Register a level-2 detector; the ledger loader validates
htmlrules against it.
- epythet.validation.rendered.render_findings(outdirs, ledger, *, docsrc)[source]¶
Run every
html-kind rule of the ledger over the rendered output.
- epythet.validation.rendered.run_render_level(project_dir, ledger, *, backend, outdir, snapshot=False, update=False, snapshot_dir=None)[source]¶
Level 2: render html, text and xml into
outdirand read them.Returns
(findings, notes, artifacts); the artifacts hand level 3 the output directories and the snapshot diff so it never builds again.
- epythet.validation.rendered.snapshot_findings(diff, ledger)[source]¶
One DR035 finding per changed page, plus info findings for new and removed pages.
- epythet.validation.rendered.text_snapshots_detector(_outdirs, _docsrc)[source]¶
DR035’s detector is the snapshot diff, driven by
snapshot=; nothing to scan here.
- epythet.validation.rendered.unresolved_xrefs(outdirs, _docsrc)[source]¶
Level-2 detector over the
xmloutput (DR023 at level 2).
- epythet.validation.rendered.unresolved_xrefs_in(root)[source]¶
Cross-references that rendered as plain code: an
xrefliteral noreferencewraps.Autosummary rows are left out: an unwrapped name there means an undocumented object (reported by
empty_descriptions_in()), not a bad target.