use 'defaultvalue' property, not 'default', to hold the default value (closes #180)

This commit is contained in:
Jeff Williams 2012-09-09 21:12:35 -07:00
parent e9a9dc988e
commit c8ce159342
3 changed files with 10 additions and 10 deletions

View File

@ -72,7 +72,7 @@ exports.Tag = function(tagTitle, tagBody, meta) {
this.value.optional = tagType.optional;
this.value.nullable = tagType.nullable;
this.value.variable = tagType.variable;
this.value['default'] = tagType['default'];
this.value.defaultvalue = tagType.defaultvalue;
}
if (tagType.text && tagType.text.length) {

View File

@ -71,7 +71,7 @@ var getTagInfo = exports.getTagInfo = function(tagValue, canHaveName, canHaveTyp
@param {string} tagValue
@param {boolean} canHaveName
@param {boolean} canHaveType
@returns {object} Hash with name, type, text, optional, nullable, variable, and default properties
@returns {object} Hash with name, type, text, optional, nullable, variable, and defaultvalue properties
*/
exports.parse = function(tagValue, canHaveName, canHaveType) {
if (typeof tagValue !== 'string') { tagValue = ''; }
@ -89,6 +89,6 @@ exports.parse = function(tagValue, canHaveName, canHaveType) {
optional: tagInfo.optional,
nullable: tagInfo.nullable,
variable: tagInfo.variable,
'default': tagInfo['default']
defaultvalue: tagInfo['default']
};
};

View File

@ -20,27 +20,27 @@ describe("jsdoc/tag/type/jsdocType", function() {
var info = jsdocType.parse( { name: "[foo]" } );
expect(info.name).toEqual("foo");
expect(info.optional).toEqual(true);
expect( info['default'] ).toEqual(null);
expect( info.defaultvalue ).toEqual(null);
info = jsdocType.parse( { name: "[ bar ]" } );
expect(info.name).toEqual("bar");
expect(info.optional).toEqual(true);
expect( info['default'] ).toEqual(null);
expect( info.defaultvalue ).toEqual(null);
});
it("should recognize optional properties with default values", function() {
var info = jsdocType.parse( { name: "[foo=bar]" } );
expect(info.name).toEqual("foo");
expect(info.optional).toEqual(true);
expect( info['default'] ).toEqual("bar");
expect( info.defaultvalue ).toEqual("bar");
info = jsdocType.parse( { name: "[ baz = qux ]" } );
expect(info.name).toEqual("baz");
expect(info.optional).toEqual(true);
expect( info['default'] ).toEqual("qux");
expect( info.defaultvalue ).toEqual("qux");
});
it("should only change the `name`, `optional`, and `default` properties", function() {
it("should only change the `name`, `optional`, and `defaultvalue` properties", function() {
var obj = {
name: "[foo=bar]",
type: "boolean|string",
@ -48,9 +48,9 @@ describe("jsdoc/tag/type/jsdocType", function() {
optional: null,
nullable: null,
variable: null,
'default': null
defaultvalue: null
};
var shouldChange = [ "name", "optional", "default" ];
var shouldChange = [ "name", "optional", "defaultvalue" ];
var info = jsdocType.parse(obj);
for (var key in info) {