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 <[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]>
  • Loading branch information
rubys authored and vsemozhetbyt committed Jul 22, 2018
1 parent 2ba3b57 commit 78039b5
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 78039b5

Please sign in to comment.