From c3d26e801a40e1595b859df1d7730cfe526edc45 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 6 Nov 2017 01:36:50 +0800 Subject: 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 Reviewed-By: Yuta Hiroto Reviewed-By: Anatoli Papirovski Reviewed-By: James M Snell --- tools/doc/html.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tools') 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 `#`; +} 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(' ') + `* ` + `${tok.text}`); - tok.text += `#`; + tok.text += getMark(id); + if (realFilename === 'errors' && apiName.startsWith('ERR_')) { + tok.text += getMark(apiName); + } }); toc = marked.parse(toc.join('\n')); -- cgit v1.2.3