Repository navigation
test(library): read the public-surface Name tables through mdast instead of a hand parser - #569
Merged
Merged
Conversation
documentedNames pinned the `| Name |` tables of docs/reference/library.md to the names src/index.ts exports with a hand parser: a quote-depth stripper, a fence tracker per quote depth, three regexes for the Name header, the delimiter row, and a code-span first cell, and a line loop that opened a table on header plus delimiter and closed it on a blank line. It now parses the page with mdast-util-from-markdown and the GFM table extensions (micromark-extension-gfm-table, mdast-util-gfm-table), the stack .github/scripts/lib/generated-regions.ts already uses, and reads the tree: the root blocks between `## The API by group` and the next second-level heading, every table under them visited through unist-util-visit-parents, added as a direct devDependency for it; a Name table is one whose header's first cell is the text `Name`; a body row's first cell must be one code span, else the row is refused with its line and source as before. Deleted: QuotedLine, quotedLine, outsideFences, opensNameTable, isNameTableDelimiter, and the three regexes. Differential, old scan against new: the real page gives the same 132 names; the 16 page variants the existing negative controls build give the same answer each (the same names, or the same refusal). Over 4000 generated pages composed from 35 block forms, 1674 differ, on 8 forms, and in each the new answer is how GitHub renders the page: a code span with a space is read as a name (the equality then reports it); an escaped pipe inside a code span is unescaped; a heading, a blockquote line, or a list item directly after a table's rows ends the table, where the old scan refused it as a malformed row; a four-space-indented table is an indented code block; a markdown table inside an HTML block is raw HTML; and a quoted or indented `## ` line is content, not the section's end, so a bad row behind one is now reached and refused. Four of those forms became negative controls, each seen red against the old scan: the indented and HTML-block tables hold shown text, a table whose rows run into a heading still documents its names, and a table after a quoted second-level heading does too.
Contributor
File size check0 over a hard cap (fails), 6 warning(s).
Split the file, wrap the line, shorten or exempt the comment, or list the path in 5 managed file(s) skipped; repo-platform owns them. |
There was a problem hiding this comment.
🟢 Approval recommended
The scoped test-only refactor and matching dependency updates have no identified blocking defects.
No open issues 🎉
What changed in this PR
Replaces the public-surface test's hand-written Markdown parser with an mdast GFM table parser, aligning documented API name checks with GitHub's rendering.
Changes:
- Extracts names from parsed tables within the API section, preserving row validation and duplicate detection.
- Adds regression controls for indented code, HTML blocks, table-ending headings, and quoted headings.
- Adds
unist-util-visit-parentsas a direct development dependency.
| File | Description |
|---|---|
test/library/public-surface.test.ts |
Migrates table extraction to mdast and adds regression controls. |
package.json |
Declares the tree traversal dependency. |
bun.lock |
Records the matching direct dependency. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
How
\|in a code span unescapes; a heading, quote, or list item glued to table rows ends the table; a four-space-indented table is code; a table inside an HTML block is raw HTML; a quoted or indented##is content, not the section end. No real page carries one.unist-util-visit-parents6.0.2 becomes a direct devDependency, the identical line refactor(scripts): walk the markdown tree with unist-util-visit-parents in generated-regions #562 adds.Proof
Technical details
package.jsonandbun.lockhunks are byte-identical to refactor(scripts): walk the markdown tree with unist-util-visit-parents in generated-regions #562's; whichever lands second rebases over an identical change.test/library/public-surface.test.ts,package.json,bun.lock.