Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorVse Mozhet Byt <vsemozhetbyt@gmail.com>2017-10-15 01:40:17 +0300
committerMichaƫl Zasso <targos@protonmail.com>2017-10-18 09:35:00 +0300
commit0776c8060617b4207387250ee93b0c4eaabaa425 (patch)
tree55443871150eb79272dfd5d246bf6a890620f5ee /tools
parent191e39011b0488a8122064810d7241ed39ed5be6 (diff)
doc: support multidimensional arrays in type link
Currently, we have at least one multidimensional array in type signature: see `records` parameter in https://nodejs.org/api/dns.html#dns_dns_resolvetxt_hostname_callback Our type parser does not linkify these signatures properly. This PR tries to fix this. PR-URL: https://github.com/nodejs/node/pull/16207 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/doc/type-parser.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/tools/doc/type-parser.js b/tools/doc/type-parser.js
index fd2fc708f07..43af1cb9781 100644
--- a/tools/doc/type-parser.js
+++ b/tools/doc/type-parser.js
@@ -58,6 +58,8 @@ const typeMap = {
'URLSearchParams': 'url.html#url_class_urlsearchparams'
};
+const arrayPart = /(?:\[])+$/;
+
module.exports = {
toLink: function(typeInput) {
const typeLinks = [];
@@ -69,12 +71,10 @@ module.exports = {
if (typeText) {
let typeUrl = null;
- // To support type[], we store the full string and use
- // the bracket-less version to lookup the type URL
+ // To support type[], type[][] etc., we store the full string
+ // and use the bracket-less version to lookup the type URL
const typeTextFull = typeText;
- if (/\[]$/.test(typeText)) {
- typeText = typeText.slice(0, -2);
- }
+ typeText = typeText.replace(arrayPart, '');
const primitive = jsPrimitives[typeText.toLowerCase()];