tools: validate apidoc links
PR-URL: https://github.com/nodejs/node/pull/21889 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
2ba3b57c76
commit
78039b5f87
@ -73,3 +73,16 @@ all = all.slice(0, apiStart.index + apiStart[0].length) +
|
|||||||
|
|
||||||
// Write results.
|
// Write results.
|
||||||
fs.writeFileSync(source + '/all.html', all, 'utf8');
|
fs.writeFileSync(source + '/all.html', all, 'utf8');
|
||||||
|
|
||||||
|
// Validate all hrefs have a target.
|
||||||
|
const ids = new Set();
|
||||||
|
const idRe = / id="(\w+)"/g;
|
||||||
|
let match;
|
||||||
|
while (match = idRe.exec(all)) {
|
||||||
|
ids.add(match[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const hrefRe = / href="#(\w+)"/g;
|
||||||
|
while (match = hrefRe.exec(all)) {
|
||||||
|
if (!ids.has(match[1])) throw new Error(`link not found: ${match[1]}`);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user