mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
remove cruft from Tag objects
This commit is contained in:
parent
bfddc53034
commit
d17ecfd8ec
@ -92,10 +92,12 @@ function processTagText(tag, tagDef) {
|
|||||||
};
|
};
|
||||||
addHiddenProperty(tag.value.type, 'parsedType', tagType.parsedType);
|
addHiddenProperty(tag.value.type, 'parsedType', tagType.parsedType);
|
||||||
}
|
}
|
||||||
tag.value.optional = tagType.optional;
|
|
||||||
tag.value.nullable = tagType.nullable;
|
['optional', 'nullable', 'variable', 'defaultvalue'].forEach(function(prop) {
|
||||||
tag.value.variable = tagType.variable;
|
if (typeof tagType[prop] !== 'undefined') {
|
||||||
tag.value.defaultvalue = tagType.defaultvalue;
|
tag.value[prop] = tagType[prop];
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tagType.text && tagType.text.length) {
|
if (tagType.text && tagType.text.length) {
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/*global afterEach, beforeEach, describe, env, expect, it, spyOn */
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var hasOwnProp = Object.prototype.hasOwnProperty;
|
var hasOwnProp = Object.prototype.hasOwnProperty;
|
||||||
@ -43,6 +42,7 @@ describe('jsdoc/tag', function() {
|
|||||||
var tagExample;
|
var tagExample;
|
||||||
var tagExampleIndented;
|
var tagExampleIndented;
|
||||||
var tagParam;
|
var tagParam;
|
||||||
|
var tagParamWithType;
|
||||||
var tagType;
|
var tagType;
|
||||||
|
|
||||||
// allow each test to recreate the tags (for example, after enabling debug mode)
|
// allow each test to recreate the tags (for example, after enabling debug mode)
|
||||||
@ -51,8 +51,10 @@ describe('jsdoc/tag', function() {
|
|||||||
tagArg = new jsdoc.tag.Tag('arg ', text, meta);
|
tagArg = new jsdoc.tag.Tag('arg ', text, meta);
|
||||||
// @param with no type, but with optional and defaultvalue
|
// @param with no type, but with optional and defaultvalue
|
||||||
tagParam = new jsdoc.tag.Tag('param', '[foo=1]', meta);
|
tagParam = new jsdoc.tag.Tag('param', '[foo=1]', meta);
|
||||||
|
// @param with type and no type modifiers (such as optional)
|
||||||
|
tagParamWithType = new jsdoc.tag.Tag('param', '{string} foo', meta);
|
||||||
// @example that does not need indentation to be removed
|
// @example that does not need indentation to be removed
|
||||||
tagExample = new jsdoc.tag.Tag('example', textExample, meta);
|
tagExample = new jsdoc.tag.Tag('example', textExample, meta);
|
||||||
// @example that needs indentation to be removed
|
// @example that needs indentation to be removed
|
||||||
tagExampleIndented = new jsdoc.tag.Tag('example', textExampleIndented, meta);
|
tagExampleIndented = new jsdoc.tag.Tag('example', textExampleIndented, meta);
|
||||||
// for testing that onTagText is run when necessary
|
// for testing that onTagText is run when necessary
|
||||||
@ -205,6 +207,12 @@ describe('jsdoc/tag', function() {
|
|||||||
|
|
||||||
expect(tagType.value.name).not.toBeDefined();
|
expect(tagType.value.name).not.toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('if the tag has a type without modifiers, tag.value should not include properties for the modifiers', function() {
|
||||||
|
['optional', 'nullable', 'variable', 'defaultvalue'].forEach(function(modifier) {
|
||||||
|
expect( hasOwnProp.call(tagParamWithType.value, modifier) ).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// further tests for this sort of thing are in jsdoc/tag/validator.js tests.
|
// further tests for this sort of thing are in jsdoc/tag/validator.js tests.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user