mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
expose parsed type in doclets (#576)
Author: Alexey Malutin (https://github.com/Alexey-Malutin)
This commit is contained in:
parent
cfd9743eaa
commit
2dec7bd4e0
@ -110,6 +110,62 @@ var TYPE_PROPERTY_SCHEMA = exports.TYPE_PROPERTY_SCHEMA = {
|
|||||||
items: {
|
items: {
|
||||||
type: STRING
|
type: STRING
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// type parser output
|
||||||
|
parsedType: {
|
||||||
|
id: '#parsedType',
|
||||||
|
type: OBJECT,
|
||||||
|
additionalProperties: false,
|
||||||
|
properties: {
|
||||||
|
type: {
|
||||||
|
type: STRING,
|
||||||
|
enum: [
|
||||||
|
'AllLiteral',
|
||||||
|
'FieldType',
|
||||||
|
'FunctionType',
|
||||||
|
'NameExpression',
|
||||||
|
'NullLiteral',
|
||||||
|
'RecordType',
|
||||||
|
'TypeApplication',
|
||||||
|
'TypeUnion',
|
||||||
|
'UndefinedLiteral',
|
||||||
|
'UnknownLiteral'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
expression: {
|
||||||
|
'$ref': '#parsedType'
|
||||||
|
},
|
||||||
|
applications: {
|
||||||
|
type : ARRAY,
|
||||||
|
items: {
|
||||||
|
'$ref': '#parsedType'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
name: STRING,
|
||||||
|
elements: {
|
||||||
|
type : ARRAY,
|
||||||
|
items: {
|
||||||
|
'$ref': '#parsedType'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
params: ARRAY,
|
||||||
|
reservedWord: BOOLEAN,
|
||||||
|
nullable: BOOLEAN,
|
||||||
|
optional: BOOLEAN,
|
||||||
|
repeatable: BOOLEAN,
|
||||||
|
fields: {
|
||||||
|
type: ARRAY,
|
||||||
|
items: {
|
||||||
|
type: OBJECT,
|
||||||
|
additionalProperties: false,
|
||||||
|
properties: {
|
||||||
|
type: STRING,
|
||||||
|
key: STRING,
|
||||||
|
value: OBJECT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -69,7 +69,8 @@ function processTagText(tag, tagDef) {
|
|||||||
if (tagType.type) {
|
if (tagType.type) {
|
||||||
if (tagType.type.length) {
|
if (tagType.type.length) {
|
||||||
tag.value.type = {
|
tag.value.type = {
|
||||||
names: tagType.type
|
names: tagType.type,
|
||||||
|
parsedType: tagType.parsedType
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
tag.value.optional = tagType.optional;
|
tag.value.optional = tagType.optional;
|
||||||
|
|||||||
@ -254,6 +254,7 @@ function parseTypeExpression(tagInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tagInfo.type = tagInfo.type.concat( getTypeStrings(parsedType, true) );
|
tagInfo.type = tagInfo.type.concat( getTypeStrings(parsedType, true) );
|
||||||
|
tagInfo.parsedType = parsedType;
|
||||||
|
|
||||||
// Catharsis and JSDoc use the same names for 'optional' and 'nullable'...
|
// Catharsis and JSDoc use the same names for 'optional' and 'nullable'...
|
||||||
['optional', 'nullable'].forEach(function(key) {
|
['optional', 'nullable'].forEach(function(key) {
|
||||||
|
|||||||
13
test/fixtures/type.js
vendored
Normal file
13
test/fixtures/type.js
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* @param {number=} Optional
|
||||||
|
* @param {...number} Variable (repeatable)
|
||||||
|
* @param {*} All
|
||||||
|
* @param {?number} Nullable
|
||||||
|
* @param {!number} Non nullable
|
||||||
|
* @param {Array.<string>}
|
||||||
|
* @param {Object.<string, *>}
|
||||||
|
* @param {{a: string, b}} Record
|
||||||
|
* @param {Object.<string, {a, b}}>}
|
||||||
|
*/
|
||||||
|
function testFunction() {
|
||||||
|
}
|
||||||
4
test/specs/jsdoc/typeParser.js
Normal file
4
test/specs/jsdoc/typeParser.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
describe("@param tag", function() {
|
||||||
|
//To put doclets to jasmine.parseResults for jsdoc/schema test.
|
||||||
|
var docSet = jasmine.getDocSetFromFile('test/fixtures/type.js');
|
||||||
|
})
|
||||||
Loading…
x
Reference in New Issue
Block a user