summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2017-11-06 01:36:50 +0800
committerRich Trott <rtrott@gmail.com>2017-11-08 14:02:00 +0000
commitc3d26e801a40e1595b859df1d7730cfe526edc45 (patch)
tree67534cbede01175188b8bed59c1b5ba978283d3b /tools
parent3ee524b14c6aa429af1c62b6e3d69b0cc3ff200c (diff)
downloadandroid-node-v8-c3d26e801a40e1595b859df1d7730cfe526edc45.tar.gz
android-node-v8-c3d26e801a40e1595b859df1d7730cfe526edc45.tar.bz2
android-node-v8-c3d26e801a40e1595b859df1d7730cfe526edc45.zip
tools: add direct anchors for error codes
This adds direct anchors for the error codes in errors.html. For example, previously the anchor for ERR_ASSERTION is #errors_err_assertion, now there is also #ERR_ASSERTION. PR-URL: https://github.com/nodejs/node/pull/16779 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/doc/html.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/doc/html.js b/tools/doc/html.js
index 6729dbba18..5534dd03b7 100644
--- a/tools/doc/html.js
+++ b/tools/doc/html.js
@@ -472,6 +472,9 @@ function getSection(lexed) {
return '';
}
+function getMark(anchor) {
+ return `<span><a class="mark" href="#${anchor}" id="${anchor}">#</a></span>`;
+}
function buildToc(lexed, filename, cb) {
var toc = [];
@@ -499,12 +502,15 @@ function buildToc(lexed, filename, cb) {
depth = tok.depth;
const realFilename = path.basename(realFilenames[0], '.md');
- const id = getId(`${realFilename}_${tok.text.trim()}`);
+ const apiName = tok.text.trim();
+ const id = getId(`${realFilename}_${apiName}`);
toc.push(new Array((depth - 1) * 2 + 1).join(' ') +
`* <span class="stability_${tok.stability}">` +
`<a href="#${id}">${tok.text}</a></span>`);
- tok.text += `<span><a class="mark" href="#${id}"` +
- `id="${id}">#</a></span>`;
+ tok.text += getMark(id);
+ if (realFilename === 'errors' && apiName.startsWith('ERR_')) {
+ tok.text += getMark(apiName);
+ }
});
toc = marked.parse(toc.join('\n'));