mirror of
https://github.com/jsdoc/jsdoc.git
synced 2026-02-01 16:45:41 +00:00
use 'defaultvalue' property, not 'default', to hold the default value (closes #180)
This commit is contained in:
parent
e9a9dc988e
commit
c8ce159342
@ -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) {
|
||||
|
||||
@ -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']
|
||||
};
|
||||
};
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user