diff options
author | Roman Reiss <me@silverwind.io> | 2017-04-19 19:22:52 +0200 |
---|---|---|
committer | Roman Reiss <me@silverwind.io> | 2017-04-19 19:24:12 +0200 |
commit | 0584aeb30a97d8ca81f242f4ddc05a0c6f9b7684 (patch) | |
tree | e4e2e8c3642369ca354ee9ba210227048b146a3e /tools | |
parent | d33b3d10860d31cbb8d63fd8f6e93555d8cd1c88 (diff) | |
download | node-new-0584aeb30a97d8ca81f242f4ddc05a0c6f9b7684.tar.gz |
tools: add table parsing capability to the doctool
PR-URL: https://github.com/nodejs/node/pull/9532
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/doc/html.js | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/tools/doc/html.js b/tools/doc/html.js index 38031b4c80..8a071b2e46 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -183,13 +183,35 @@ function analyticsScript(analytics) { `; } +// replace placeholders in text tokens +function replaceInText(text) { + return linkJsTypeDocs(linkManPages(text)); +} + // handle general body-text replacements // for example, link man page references to the actual page function parseText(lexed) { lexed.forEach(function(tok) { - if (tok.text && tok.type !== 'code') { - tok.text = linkManPages(tok.text); - tok.text = linkJsTypeDocs(tok.text); + if (tok.type === 'table') { + if (tok.cells) { + tok.cells.forEach((row, x) => { + row.forEach((_, y) => { + if (tok.cells[x] && tok.cells[x][y]) { + tok.cells[x][y] = replaceInText(tok.cells[x][y]); + } + }); + }); + } + + if (tok.header) { + tok.header.forEach((_, i) => { + if (tok.header[i]) { + tok.header[i] = replaceInText(tok.header[i]); + } + }); + } + } else if (tok.text && tok.type !== 'code') { + tok.text = replaceInText(tok.text); } }); } |