diff options
author | Sam Ruby <rubys@intertwingly.net> | 2018-07-19 12:12:38 -0400 |
---|---|---|
committer | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2018-07-22 19:33:55 +0300 |
commit | 78039b5f87938125d9761367dc08a16812bb9f54 (patch) | |
tree | af31647f0a2e74c5448bed55a147f60ea7c7890a /tools/doc | |
parent | 2ba3b57c76a25dbc6fabcdfb2c7143c204328fac (diff) | |
download | android-node-v8-78039b5f87938125d9761367dc08a16812bb9f54.tar.gz android-node-v8-78039b5f87938125d9761367dc08a16812bb9f54.tar.bz2 android-node-v8-78039b5f87938125d9761367dc08a16812bb9f54.zip |
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>
Diffstat (limited to 'tools/doc')
-rw-r--r-- | tools/doc/allhtml.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/doc/allhtml.js b/tools/doc/allhtml.js index d185538ab6..3de538e424 100644 --- a/tools/doc/allhtml.js +++ b/tools/doc/allhtml.js @@ -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]}`); +} |