fix(catalog): restore the required Related topics section on generated pages

My generator rebuild replaced the '## Related topics' section (still required by
docs/AGENTS.md) with the provenance footer, dropping it from all 168 generated
Catalog pages. Emit it again as the final section so pages end with it, and stop
carriedSectionsFrom() breaking at the footer marker so a human section appended
below the generated tail survives a regeneration. Adds a per-page regeneration
assertion so a future drop fails CI. Flagged by Magi (P1) and Rames.
This commit is contained in:
ukimsanov
2026-08-05 05:38:58 -07:00
parent b62c3fd656
commit 6ff6601dd0
170 changed files with 1067 additions and 9 deletions
@@ -1,13 +1,11 @@
import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { readdirSync, readFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
const here = dirname(fileURLToPath(import.meta.url));
const generatorSource = readFileSync(
resolve(here, "../../../../scripts/generate-catalog-pages.ts"),
"utf-8",
);
const repoRoot = resolve(here, "../../../..");
const generatorSource = readFileSync(join(repoRoot, "scripts/generate-catalog-pages.ts"), "utf-8");
describe("catalog generator texture instructions", () => {
it("pins the unambiguous texture style-block copy instruction", () => {
@@ -16,3 +14,28 @@ describe("catalog generator texture instructions", () => {
expect(generatorSource).toContain("real \\`<style>\\` element near the bottom");
});
});
// docs/AGENTS.md requires every Catalog page to end with `## Related topics`.
// The generator emits it (see RELATED_TOPICS); this asserts the committed output
// still honours the rule, so a regeneration that drops it fails CI here.
describe("catalog pages keep the required reader continuation", () => {
const catalogDir = join(repoRoot, "docs/catalog");
const pages = (["blocks", "components"] as const).flatMap((sub) =>
readdirSync(join(catalogDir, sub))
.filter((f) => f.endsWith(".mdx"))
.map((f) => ({ sub, file: f, path: join(catalogDir, sub, f) })),
);
it("generates at least one page in each catalog subdirectory", () => {
expect(pages.length).toBeGreaterThan(0);
});
it.each(pages)("$sub/$file ends with a Related topics section", ({ path }) => {
const body = readFileSync(path, "utf-8").trimEnd();
const lastHeading = body
.split("\n")
.filter((l) => l.startsWith("## "))
.at(-1);
expect(lastHeading).toBe("## Related topics");
});
});