|
@ -5,12 +5,12 @@ const jsDocUrl = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/' + |
|
|
const jsPrimitiveUrl = 'https://developer.mozilla.org/en-US/docs/Web/' + |
|
|
const jsPrimitiveUrl = 'https://developer.mozilla.org/en-US/docs/Web/' + |
|
|
'JavaScript/Data_structures'; |
|
|
'JavaScript/Data_structures'; |
|
|
const jsPrimitives = { |
|
|
const jsPrimitives = { |
|
|
'Integer': 'Number', // this is for extending
|
|
|
'integer': 'Number', // this is for extending
|
|
|
'Number': 'Number', |
|
|
'number': 'Number', |
|
|
'String': 'String', |
|
|
'string': 'String', |
|
|
'Boolean': 'Boolean', |
|
|
'boolean': 'Boolean', |
|
|
'Null': 'Null', |
|
|
'null': 'Null', |
|
|
'Symbol': 'Symbol' |
|
|
'symbol': 'Symbol' |
|
|
}; |
|
|
}; |
|
|
const jsGlobalTypes = [ |
|
|
const jsGlobalTypes = [ |
|
|
'Error', 'Object', 'Function', 'Array', 'TypedArray', 'Uint8Array', |
|
|
'Error', 'Object', 'Function', 'Array', 'TypedArray', 'Uint8Array', |
|
@ -49,7 +49,16 @@ module.exports = { |
|
|
typeText = typeText.trim(); |
|
|
typeText = typeText.trim(); |
|
|
if (typeText) { |
|
|
if (typeText) { |
|
|
let typeUrl = null; |
|
|
let typeUrl = null; |
|
|
const primitive = jsPrimitives[typeText]; |
|
|
|
|
|
|
|
|
// To support type[], 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); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const primitive = jsPrimitives[typeText.toLowerCase()]; |
|
|
|
|
|
|
|
|
if (primitive !== undefined) { |
|
|
if (primitive !== undefined) { |
|
|
typeUrl = `${jsPrimitiveUrl}#${primitive}_type`; |
|
|
typeUrl = `${jsPrimitiveUrl}#${primitive}_type`; |
|
|
} else if (jsGlobalTypes.indexOf(typeText) !== -1) { |
|
|
} else if (jsGlobalTypes.indexOf(typeText) !== -1) { |
|
@ -60,9 +69,9 @@ module.exports = { |
|
|
|
|
|
|
|
|
if (typeUrl) { |
|
|
if (typeUrl) { |
|
|
typeLinks.push('<a href="' + typeUrl + '" class="type"><' + |
|
|
typeLinks.push('<a href="' + typeUrl + '" class="type"><' + |
|
|
typeText + '></a>'); |
|
|
typeTextFull + '></a>'); |
|
|
} else { |
|
|
} else { |
|
|
typeLinks.push('<span class="type"><' + typeText + '></span>'); |
|
|
typeLinks.push('<span class="type"><' + typeTextFull + '></span>'); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|