Skip to content

Commit 5e71d63

Browse files
rubystargos
authored andcommitted
tools: validate apidoc links
PR-URL: #21889 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 5e562fd commit 5e71d63

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tools/doc/allhtml.js

+13
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,16 @@ all = all.slice(0, apiStart.index + apiStart[0].length) +
7373

7474
// Write results.
7575
fs.writeFileSync(source + '/all.html', all, 'utf8');
76+
77+
// Validate all hrefs have a target.
78+
const ids = new Set();
79+
const idRe = / id="(\w+)"/g;
80+
let match;
81+
while (match = idRe.exec(all)) {
82+
ids.add(match[1]);
83+
}
84+
85+
const hrefRe = / href="#(\w+)"/g;
86+
while (match = hrefRe.exec(all)) {
87+
if (!ids.has(match[1])) throw new Error(`link not found: ${match[1]}`);
88+
}

0 commit comments

Comments
 (0)