fix for "variable" (repeatable) params (#381)

This commit is contained in:
Jeff Williams 2013-04-02 07:41:53 -07:00
parent eb9d95fa60
commit a9405a8d10
2 changed files with 17 additions and 1 deletions

View File

@ -167,11 +167,17 @@ function parseTypeExpression(tagInfo) {
if (parsedType) {
tagInfo.type = tagInfo.type.concat( getTypeStrings(parsedType) );
['optional', 'nullable', 'variable'].forEach(function(key) {
// Catharsis and JSDoc use the same names for 'optional' and 'nullable'...
['optional', 'nullable'].forEach(function(key) {
if (parsedType[key] !== null && parsedType[key] !== undefined) {
tagInfo[key] = parsedType[key];
}
});
// ...but not 'variable'.
if (parsedType.repeatable !== null && parsedType.repeatable !== undefined) {
tagInfo.variable = parsedType.repeatable;
}
}
return tagInfo;

View File

@ -179,5 +179,15 @@ describe('jsdoc/tag/type', function() {
expect(info.defaultvalue).toBe('hooray');
});
});
// TODO: add more tests related to how JSDoc mangles the Catharsis parse results
describe('Closure Compiler-style type info', function() {
it('should recognize variable (repeatable) parameters', function() {
var desc = '{...string} foo - Foo.';
var info = jsdoc.tag.type.parse(desc, true, true);
expect(info.type).toEqual( ['string'] );
expect(info.variable).toBe(true);
});
});
});
});