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);
|
||||
}
|
||||
tag.value.optional = tagType.optional;
|
||||
tag.value.nullable = tagType.nullable;
|
||||
tag.value.variable = tagType.variable;
|
||||
tag.value.defaultvalue = tagType.defaultvalue;
|
||||
|
||||
['optional', 'nullable', 'variable', 'defaultvalue'].forEach(function(prop) {
|
||||
if (typeof tagType[prop] !== 'undefined') {
|
||||
tag.value[prop] = tagType[prop];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (tagType.text && tagType.text.length) {
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
/*global afterEach, beforeEach, describe, env, expect, it, spyOn */
|
||||
'use strict';
|
||||
|
||||
var hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
@ -43,6 +42,7 @@ describe('jsdoc/tag', function() {
|
||||
var tagExample;
|
||||
var tagExampleIndented;
|
||||
var tagParam;
|
||||
var tagParamWithType;
|
||||
var tagType;
|
||||
|
||||
// allow each test to recreate the tags (for example, after enabling debug mode)
|
||||
@ -51,6 +51,8 @@ describe('jsdoc/tag', function() {
|
||||
tagArg = new jsdoc.tag.Tag('arg ', text, meta);
|
||||
// @param with no type, but with optional and defaultvalue
|
||||
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
|
||||
tagExample = new jsdoc.tag.Tag('example', textExample, meta);
|
||||
// @example that needs indentation to be removed
|
||||
@ -205,6 +207,12 @@ describe('jsdoc/tag', function() {
|
||||
|
||||
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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user