Skip to content

Commit

Permalink
tools: validate apidoc links
Browse files Browse the repository at this point in the history
PR-URL: #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>
  • Loading branch information
rubys authored and targos committed Jul 24, 2018
1 parent 5e562fd commit 5e71d63
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tools/doc/allhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,16 @@ all = all.slice(0, apiStart.index + apiStart[0].length) +

// Write results.
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]}`);
}

0 comments on commit 5e71d63

Please sign in to comment.