Skip to content

The how-to-read class scan reads whole classes and skips comments - #677

Merged
johnnyt merged 1 commit into
mainfrom
sb-9wvq-how-to-read-class-scan
Sep 30, 2026
Merged

johnnyt merged 1 commit into
mainfrom
sb-9wvq-how-to-read-class-scan

Conversation

@johnnyt

@johnnyt johnnyt commented Sep 30, 2026

Copy link
Copy Markdown
Member

What

The info test "names every mark the hook draws" holds the classes assets/js/statifier_blocks_map.js draws to the how-to-read paragraph. It had two gaps:

  • It matched an interpolation only right after the sb-map__ prefix. A class built as a stem plus an interpolated modifier (sb-map__edge--${edge.kind}) passed on its stem alone.
  • It read classes out of the hook's comments, so a comment naming a class could fail the gate.

The scan is now one test helper, hook_classes/1:

  • it cuts // and /* */ comments (a // after a : is kept, so the SVG namespace URL survives);
  • it reads each class whole, with every ${...} in it read as ${} wherever it stands;
  • an interpolation whose every string is empty or opens with a space (the block's ${container ? " sb-map__block--container" : ""}) appends other classes rather than extending the name, so it ends the name and the classes inside it are read on their own.

The hook's stem classes (end--${}, mark--${}, slot--${}) are listed in a new @modifiers table with the graph key their value comes from. A new test, "names every value the hook puts after a stem", holds every value the library documents give under each key to the existing variants table. A second new test, "reads no class out of a comment", pins the comment skip on a small source. The caption table's key is now written in the normalized form, ${}-caption.

Test-only: no lib/ or hook change, no changelog fragment (changelog.d/README.md excludes tests).

Sabotage

Each reverted from a copy, byte-equal, and recompiled before the next:

Mutation Test that went red
hook: sb-map__edge--${edge.kind} added to the plain edge's template names every mark the hook draws
hook: an unnamed plain class added to the fork's template names every mark the hook draws
hook: sb-map__${edge.kind}-tag added to the plain edge's template names every mark the hook draws
mark/1 in lib/statifier_blocks/map.ex answers "hourglass" for an await names every value the hook puts after a stem (and the existing variants test)
hook_classes/1 with its comment cuts removed reads no class out of a comment
hook_classes/1 reading every interpolation as part of the name names every mark the hook draws

The first mutation run against the test as it stands on main left it green, which is the defect this fixes. Two existing sabotage notes that injected into a hook comment now read "template", the shape they were re-run in.

Gate

Full mix quality green on the committed tree: 3,953 of 3,953 tests, 95.3% coverage, dialyzer clean, ADR cites green.

Review

In-turn review: re-read the diff against the bead. The acceptance asks the scan to catch an interpolation anywhere in a class name, each stem covered by the variants table, and to skip comments, each pinned by a sabotage; the table above maps each part to a red test. Every sb-map__ occurrence in the hook was read by hand against the helper's reading: the plain classes it returns are the ones the old scan returned, and the built set is the caption plus the three stems. A slot style that no library document draws (the drafts shelf's tray) is not exercised by the new values test; renaming it left the suite green, so the sabotage row uses the await's mark instead.

Refs: sb-9wvq

The info test that holds the Map hook's drawn classes to the
how-to-read paragraph matched an interpolation only right after the
sb-map__ prefix, so a class built as a stem plus an interpolated
modifier (sb-map__edge--${kind}) passed on its stem alone. It also read
classes out of the hook's comments, so a comment could fail the gate.

The scan now lives in one helper, hook_classes/1. It cuts line and
block comments, reads each class whole with every ${...} in it read as
${} wherever it stands, and ends a name at an interpolation that only
appends other classes (its strings empty or opening with a space). The
hook's stem classes (end--, mark--, slot--) are listed with the graph
key their value comes from, and a new test holds every value the
library documents give under each key to the variants table. A second
new test pins the comment skip on a small source.

Sabotaged: a stem-interpolated class, an unnamed class and an unlisted
interpolated class added to hook templates, a renamed await mark, the
comment cut removed, and every interpolation read as part of the name;
each turned a test red. Test-only; no lib change.

Gate: full mix quality green on this staged tree (3,953 of 3,953
tests, 95.3% coverage, dialyzer clean, ADR cites green).

Refs: sb-9wvq
@johnnyt
johnnyt force-pushed the sb-9wvq-how-to-read-class-scan branch from 8bd661b to e280d67 Compare September 30, 2026 11:10
@johnnyt
johnnyt merged commit fefd330 into main Sep 30, 2026
2 checks passed
@johnnyt
johnnyt deleted the sb-9wvq-how-to-read-class-scan branch September 30, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant