Skip to content

Commit f6ba79c

Browse files
committed
Ignore tmp build fixtures; verify <main> pages
Add /.tmp-* to .gitignore and remove throwaway .tmp-fakebuild fixtures. Update scripts/verify-llms-output.js: rename articlePages to contentPages, update console output, and change the page detection to validate pages that use <article> or fall back to <main>, with updated comments to mirror the injector's html-to-markdown fallback.
1 parent 7fb29c2 commit f6ba79c

5 files changed

Lines changed: 19 additions & 21 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
# Production
77
/build
88

9+
# Throwaway local build/test fixtures
10+
/.tmp-*
11+
912
# Dev sanity-check output from scripts/verify-llms-output.js
1013
/.llms-verify
1114
/.llms-inspect

.tmp-fakebuild/foo/index.html

Lines changed: 0 additions & 5 deletions
This file was deleted.

.tmp-fakebuild/index.html

Lines changed: 0 additions & 5 deletions
This file was deleted.

.tmp-fakebuild/llms.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

scripts/verify-llms-output.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,15 @@ async function verifyBuildOutput(buildDir, failures) {
222222
// directive injection against the production HTML.
223223
const stats = {
224224
pages: 0,
225-
articlePages: 0,
225+
contentPages: 0,
226226
mdMissing: [],
227227
altMissing: [],
228228
directiveMissing: [],
229229
}
230230
await visitHtml(buildDir, buildDir, stats)
231231

232232
console.log(
233-
`Scanned ${stats.pages} HTML page(s); ${stats.articlePages} content page(s) with <article>`
233+
`Scanned ${stats.pages} HTML page(s); ${stats.contentPages} content page(s) with <article> or <main>`
234234
)
235235

236236
if (stats.pages === 0) {
@@ -258,8 +258,11 @@ async function verifyBuildOutput(buildDir, failures) {
258258
* Recursively walk `dir` for `index.html` files, recording AFDocs-relevant
259259
* violations into `stats`. The body directive is asserted on every page (the
260260
* injector adds it to every `<body>`); the `.md` sibling and alternate link
261-
* are asserted on content pages (those with an `<article>`), mirroring the
262-
* injector's own "regenerate from `<article>`, then link the `.md`" contract.
261+
* are asserted on content pages, mirroring the injector's own
262+
* "regenerate from `<article>` (falling back to `<main>`), then link the `.md`"
263+
* contract — see `htmlToMarkdown()` in the injector, which selects `<article>`
264+
* first and falls back to `<main>`. The gate must use the SAME selector or
265+
* pages that render under `<main>` without an `<article>` ship unchecked.
263266
*/
264267
async function visitHtml(dir, buildDir, stats) {
265268
const entries = await fs.readdir(dir, { withFileTypes: true })
@@ -284,14 +287,17 @@ async function visitHtml(dir, buildDir, stats) {
284287
stats.directiveMissing.push(relDir || '<root>')
285288
}
286289

287-
// Only content pages (those Docusaurus renders inside <article>) are
288-
// expected to produce a `.md` sibling + alternate link. The homepage and
289-
// bare landing pages have no <article>, so they're exempt — matching
290-
// regenerateMdFromHtml()/injectAlternateLinks() in the injector.
290+
// Only content pages are expected to produce a `.md` sibling + alternate
291+
// link. The injector's regenerateMdFromHtml() converts the first
292+
// `<article>`, OR the first `<main>` when no `<article>` exists, and
293+
// returns null only when neither is present. Mirror that exact fallback
294+
// here so pages whose body lives under `<main>` (no `<article>`) are still
295+
// checked. The homepage and bare landing pages have neither, so they're
296+
// exempt — matching regenerateMdFromHtml()/injectAlternateLinks().
291297
if (!relDir || relDir === '.') continue
292-
if (!/<article\b/i.test(html)) continue
298+
if (!/<article\b/i.test(html) && !/<main\b/i.test(html)) continue
293299

294-
stats.articlePages++
300+
stats.contentPages++
295301

296302
const mdAbs = path.join(buildDir, `${relDir}.md`)
297303
let mdExists = true

0 commit comments

Comments
 (0)