You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f38cfca
Browse filesBrowse the repository at this point in the historyBrowse files
build(html): one generator for the HTML tables, reflect data from webref's packages (#22003)
* build(html): one generator for the HTML tables, reflect data from webref's packages
The two HTML generators are one: `generate-html-data.js` now emits both
`lib/html/data.js` and the entity region inside `lib/html/syntax.js`, so a
single command covers everything the parser and minifier look a name up in.
The reflected-attribute tables come from `@webref/idl` and `@webref/elements`
rather than a vendored distillation of them, which deletes
`tooling/html-reflect.json` and its `--fetch` refresh: upstream now moves as a
lockfile bump whose regenerated diff is reviewable, instead of an undated copy
that drifts unnoticed. It already had: the packaged IDL derives four attributes
the vendored file missed, so `frame`, `frameset`, `marquee`, `dir`, `listing`
and `xmp` gain the reflected attributes the spec gives them — `noresize`,
`truespeed`, `scrollamount`, `scrolldelay`, `compact` on `dir`, `hspace` and
`vspace` on `marquee`, `width` on `listing`/`xmp`, and the window event
handlers on `frameset`. Nothing is removed.
The entity table stays vendored: WHATWG publishes it as `entities.json` and no
package carries it faithfully — the ones that exist drop the semicolon, which
loses the 106 legacy names that match unterminated. `--fetch` still refreshes
it, and the emitted region is byte-identical apart from its provenance note.
* build(html): teach cspell the attribute names webref's data adds
`scrollamount`, `scrolldelay`, `truespeed` and `noresize` are the
`marquee` and `frameset` attributes the packaged distillation carries.
* test(html): cover the reflected attributes webref's data adds
Each case pairs the element the table names with one it does not, so a
rewrite keyed on the attribute name alone fails the second half.
Spell the generated entity table with `toJsStringLiteral`: the source is
fetched, and a raw U+2028 would end the string literal it is written into.
* test(html): control every reflected attribute against an element that lacks it
`scrolldelay` and `vspace` were asserted only on the element that reflects
them, so a set widened for one of the two alone would have gone unseen.
- Generated runtime code under `lib/` (driven by `tooling/generate-runtime-code.js`).
574
574
-`lib/css/data.js` — every table the CSS minifier looks a name up in, and the arithmetic its math-function descriptors bind to: derived from `mdn-data` + `color-name` (box shorthands, color-argument and math functions, named colors) plus the generator's `SUPPLEMENT` of spec-prose tables and math primitives, by `tooling/generate-css-data.js` — which also holds the value-definition-syntax parser those grammars are read with, and runs the generation only as the entry point so its tests can require it.
575
-
-`lib/html/data.js` — every table the HTML parser and minifier look a name up in: the reflected-attribute tables distilled from webref's HTML IDL (vendored as `tooling/html-reflect.json`), plus the generator's `SUPPLEMENT` and `PARSER_TABLES` of §13.2 tree-construction vocabulary, by `tooling/generate-html-data.js`.
575
+
-`lib/html/data.js` — every table the HTML parser and minifier look a name up in: the reflected-attribute tables distilled from webref's HTML IDL (the `@webref/idl` and `@webref/elements` packages), plus the generator's `SUPPLEMENT` and `PARSER_TABLES` of §13.2 tree-construction vocabulary, by `tooling/generate-html-data.js` — which also emits the `// #region html entities` block inside `lib/html/syntax.js` from the vendored `tooling/html-entities.json`, WHATWG's own named character references table.
576
576
577
577
Both `syntax.js` files are algorithm only — a new lookup table belongs in the matching generator, not next to the code that reads it.
578
578
579
-
**And in the generator, derive it — do not type it out.** Read the table out of a published dataset (`mdn-data`, `color-name`, the vendored webref IDL) whenever it is derivable at all, _including by analyzing a grammar rather than by listing names_: the value-definition syntax states which properties take an `<integer>`, so that set is computed, never enumerated. A table already in `SUPPLEMENT` counts as a source too — cosine at each eighth turn is sine two eighths along, and each inverse trig table is its forward one read back, so one stated table can carry several.
579
+
**And in the generator, derive it — do not type it out.** Read the table out of a published dataset (`mdn-data`, `color-name`, `@webref/idl`) whenever it is derivable at all, _including by analyzing a grammar rather than by listing names_: the value-definition syntax states which properties take an `<integer>`, so that set is computed, never enumerated. A table already in `SUPPLEMENT` counts as a source too — cosine at each eighth turn is sine two eighths along, and each inverse trig table is its forward one read back, so one stated table can carry several.
580
580
581
581
**Per-construct behaviour is a table as well.** Where the minifier does something different for each name — each math function, and whatever comes next for properties or at-rules — the per-name part belongs in the generator as a descriptor and the shared part in `syntax.js` as an engine keyed by it. `MATH_FUNCTION_FOLD` is the worked example: it says how each function's arguments are read, which arithmetic runs and what unit the answer carries, so `syntax.js` implements neither and names no function of its own. The arithmetic is emitted alongside the descriptors and bound to them by reference rather than by name, so a name nothing defines fails generation rather than folding nothing. Adding a function is then adding a line, and a name whose arithmetic already exists needs nothing else. A test must still drive every descriptor — one input per entry is enough to turn a wrong-but-existing binding into a failure instead of a silent decline. Listing names by hand into a generator's `SUPPLEMENT` is the last resort, and every entry there carries the reason it cannot be derived — spec prose, an equivalence between two spellings, a judgement no dataset states. A hand-typed list goes stale the next time a spec moves and nothing in CI notices; a derived one turns the same spec change into a reviewable diff.
582
582
@@ -586,7 +586,7 @@ Re-run `yarn fix:special` **before the next commit** whenever you touch:
586
586
587
587
-`schemas/**/*.json` — reshapes validators, declarations, and `types.d.ts`.
588
588
-`lib/**/*.js` JSDoc on anything reachable from a public export — regenerates `types.d.ts`.
589
-
-`tooling/generate-runtime-code.js`, `tooling/generate-wasm-code.js`, `tooling/generate-css-data.js`, `tooling/generate-html-data.js`, or any file they consume (including the `mdn-data` / `color-name` versions in `package.json` and the vendored `tooling/html-reflect.json`).
589
+
-`tooling/generate-runtime-code.js`, `tooling/generate-wasm-code.js`, `tooling/generate-css-data.js`, `tooling/generate-html-data.js`, or any file they consume (including the `mdn-data` / `color-name`/ `@webref/*`versions in `package.json` and the vendored `tooling/html-entities.json`).
590
590
591
591
CI's `lint` job verifies these outputs are up to date. The combined `yarn fix` script runs `fix:code` + `fix:special` + `fmt` in one go; prefer it as the final step.
0 commit comments