Skip to content

Commit ba62b0e

Browse files
vsemozhetbytMylesBorins
authored andcommitted
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: #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>
1 parent e5fbc03 commit ba62b0e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tools/doc/type-parser.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const typeMap = {
4040
'http.ServerResponse': 'http.html#http_class_http_serverresponse',
4141
};
4242

43+
const arrayPart = /(?:\[])+$/;
44+
4345
module.exports = {
4446
toLink: function(typeInput) {
4547
const typeLinks = [];
@@ -51,12 +53,10 @@ module.exports = {
5153
if (typeText) {
5254
let typeUrl = null;
5355

54-
// To support type[], we store the full string and use
55-
// the bracket-less version to lookup the type URL
56+
// To support type[], type[][] etc., we store the full string
57+
// and use the bracket-less version to lookup the type URL
5658
const typeTextFull = typeText;
57-
if (/\[]$/.test(typeText)) {
58-
typeText = typeText.slice(0, -2);
59-
}
59+
typeText = typeText.replace(arrayPart, '');
6060

6161
const primitive = jsPrimitives[typeText.toLowerCase()];
6262

0 commit comments

Comments
 (0)