mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
treat foo="bar" as a non-optional version of [foo="bar"] (#791)
This commit is contained in:
parent
d17ecfd8ec
commit
df1f4bda22
@ -153,9 +153,13 @@ function getTagInfo(tagValue, canHaveName, canHaveType) {
|
||||
*/
|
||||
function parseName(tagInfo) {
|
||||
// like '[foo]' or '[ foo ]' or '[foo=bar]' or '[ foo=bar ]' or '[ foo = bar ]'
|
||||
if ( /^\[\s*(.+?)\s*\]$/.test(tagInfo.name) ) {
|
||||
tagInfo.name = RegExp.$1;
|
||||
tagInfo.optional = true;
|
||||
// or 'foo=bar' or 'foo = bar'
|
||||
if ( /^(\[)?\s*(.+?)\s*(\])?$/.test(tagInfo.name) ) {
|
||||
tagInfo.name = RegExp.$2;
|
||||
// were the "optional" brackets present?
|
||||
if (RegExp.$1 && RegExp.$3) {
|
||||
tagInfo.optional = true;
|
||||
}
|
||||
|
||||
// like 'foo=bar' or 'foo = bar'
|
||||
if ( /^(.+?)\s*=\s*(.+)$/.test(tagInfo.name) ) {
|
||||
|
||||
12
test/fixtures/propertytag.js
vendored
12
test/fixtures/propertytag.js
vendored
@ -1,13 +1,15 @@
|
||||
/**
|
||||
* @namespace
|
||||
* @property {Object} defaults The default values.
|
||||
* @property {Number} defaults.a The a property of the defaults.
|
||||
* @property {String} defaults.b The b property of the defaults.
|
||||
* @property {String} id=abc123 The identifier.
|
||||
* @property {Object} defaults The default values.
|
||||
* @property {Number} defaults.a The a property of the defaults.
|
||||
* @property {String} defaults.b The b property of the defaults.
|
||||
*/
|
||||
myobject = {
|
||||
var myobject = {
|
||||
id: "abc123",
|
||||
defaults: {
|
||||
a: 1,
|
||||
b: "Hit the light",
|
||||
c: true
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@ -1,15 +1,21 @@
|
||||
describe("@property tag", function() {
|
||||
'use strict';
|
||||
|
||||
describe('@property tag', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/propertytag.js'),
|
||||
myobject = docSet.getByLongname('myobject')[0];
|
||||
|
||||
it('When a symbol has an @property tag with a those properties appear in the parsed object.', function() {
|
||||
it('When a symbol has a @property tag, the property appears in the doclet.', function() {
|
||||
expect(typeof myobject.properties).toBe('object');
|
||||
expect(myobject.properties.length).toBe(3);
|
||||
expect(myobject.properties[0].name).toBe('defaults');
|
||||
expect(myobject.properties[1].name).toBe('defaults.a');
|
||||
expect(myobject.properties[2].name).toBe('defaults.b');
|
||||
expect(myobject.properties[0].description).toBe('The default values.');
|
||||
expect(myobject.properties[0].type.names[0]).toBe('Object');
|
||||
});
|
||||
expect(myobject.properties.length).toBe(4);
|
||||
|
||||
});
|
||||
expect(myobject.properties[0].name).toBe('id');
|
||||
expect(myobject.properties[1].name).toBe('defaults');
|
||||
expect(myobject.properties[2].name).toBe('defaults.a');
|
||||
expect(myobject.properties[3].name).toBe('defaults.b');
|
||||
|
||||
expect(myobject.properties[0].defaultvalue).toBe('abc123');
|
||||
|
||||
expect(myobject.properties[1].description).toBe('The default values.');
|
||||
expect(myobject.properties[1].type.names[0]).toBe('Object');
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user