// Third-party validation of the pages this project actually authors — the // Astro-rendered marketing and docs pages. rustdoc's own output under // dist/api/ is excluded: it is not ours to fix and gets its own review // upstream in rustdoc itself. import { readFileSync } from "node:fs"; import { HtmlValidate } from "html-validate"; import { distDir, requireDist, walkHtmlFiles, fail, report } from "./lib.mjs"; requireDist(); const htmlvalidate = new HtmlValidate({ extends: ["html-validate:recommended"], rules: { // Astro emits void elements without a trailing slash and that is fine. "void-style": "off", // The generated docs pages carry a `docs/foo.md` breadcrumb, // and rustdoc-style external anchors elsewhere use rel-less targets that // this rule otherwise flags; not worth a per-link exemption comment. "external-link": "off", // docs/running-locally.md has hand-written inline styles on some of its // tables (real, reviewed content this branch renders rather than edits — // see scripts/prepare-docs.mjs). Flagging them here would be flagging // someone else's markdown, not this site's own markup. "no-inline-style": "off", }, }); const files = walkHtmlFiles().filter((path) => !path.includes("/api/")); for (const file of files) { const html = readFileSync(file, "utf8"); const report_ = htmlvalidate.validateStringSync(html, file); if (!report_.valid) { for (const result of report_.results) { for (const message of result.messages) { fail(`${file}:${message.line}:${message.column}: ${message.ruleId} ${message.message}`); } } } } report("check-html");