Browse Source

doc,tool: add ref to Integer

We documented most types as Integer, but we don't have link for that.

PR-URL: https://github.com/nodejs/node/pull/8740
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
v6
yorkie 8 years ago
parent
commit
eaa08062f3
  1. 18
      tools/doc/type-parser.js

18
tools/doc/type-parser.js

@ -4,11 +4,16 @@ const jsDocUrl = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/' +
'Reference/Global_Objects/'; 'Reference/Global_Objects/';
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 = {
'Number', 'String', 'Boolean', 'Null', 'Symbol' 'Integer': 'Number', // this is for extending
]; 'Number': 'Number',
'String': 'String',
'Boolean': 'Boolean',
'Null': 'Null',
'Symbol': 'Symbol'
};
const jsGlobalTypes = [ const jsGlobalTypes = [
'Error', 'Object', 'Function', 'Array', 'Uint8Array', 'Error', 'Object', 'Function', 'Array', 'TypedArray', 'Uint8Array',
'Uint16Array', 'Uint32Array', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint16Array', 'Uint32Array', 'Int8Array', 'Int16Array', 'Int32Array',
'Uint8ClampedArray', 'Float32Array', 'Float64Array', 'Date', 'RegExp', 'Uint8ClampedArray', 'Float32Array', 'Float64Array', 'Date', 'RegExp',
'ArrayBuffer', 'DataView', 'Promise', 'EvalError', 'RangeError', 'ArrayBuffer', 'DataView', 'Promise', 'EvalError', 'RangeError',
@ -38,8 +43,9 @@ module.exports = {
typeText = typeText.trim(); typeText = typeText.trim();
if (typeText) { if (typeText) {
let typeUrl = null; let typeUrl = null;
if (jsPrimitives.indexOf(typeText) !== -1) { const primitive = jsPrimitives[typeText];
typeUrl = jsPrimitiveUrl + '#' + typeText + '_type'; if (primitive !== undefined) {
typeUrl = `${jsPrimitiveUrl}#${primitive}_type`;
} else if (jsGlobalTypes.indexOf(typeText) !== -1) { } else if (jsGlobalTypes.indexOf(typeText) !== -1) {
typeUrl = jsDocUrl + typeText; typeUrl = jsDocUrl + typeText;
} else if (typeMap[typeText]) { } else if (typeMap[typeText]) {

Loading…
Cancel
Save