mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Added tests for @class tag.
This commit is contained in:
parent
a00113b32c
commit
22fc216425
@ -11,11 +11,12 @@
|
||||
dictionary.defineTag('access', {
|
||||
mustHaveValue: true,
|
||||
onTagged: function(doclet, tag) {
|
||||
if ( /^(private|protected)$/.test(tag.value) ) {
|
||||
doclet.access = tag.value;
|
||||
// only valid values are private and protected, public is default
|
||||
if ( /^(private|protected)$/i.test(tag.value) ) {
|
||||
doclet.access = tag.value.toLowerCase();
|
||||
}
|
||||
else if (tag.value === 'public') {
|
||||
delete doclet.access;
|
||||
else {
|
||||
delete doclet.access;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -313,7 +314,7 @@
|
||||
dictionary.defineTag('public', {
|
||||
mustNotHaveValue: true,
|
||||
onTagged: function(doclet, tag) {
|
||||
doclet.access = 'public';
|
||||
delete doclet.access; // public is default
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -10,4 +10,20 @@ function Thingy() {
|
||||
/** @access public */
|
||||
this.pez = 2;
|
||||
|
||||
}
|
||||
|
||||
// same as...
|
||||
|
||||
/** @constructor */
|
||||
function OtherThingy() {
|
||||
|
||||
/** @private */
|
||||
var foo = 0;
|
||||
|
||||
/** @protected */
|
||||
this._bar = 1;
|
||||
|
||||
/** @public */
|
||||
this.pez = 2;
|
||||
|
||||
}
|
||||
8
test/cases/classtag.js
Normal file
8
test/cases/classtag.js
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
This function creates a new Foo.
|
||||
@constructor
|
||||
@class The class of Foo represent all those foo things.
|
||||
*/
|
||||
function Foo() {
|
||||
|
||||
}
|
||||
@ -4,7 +4,7 @@ function foo() {
|
||||
|
||||
}
|
||||
|
||||
/** @deprec v1.0.2
|
||||
/** @deprec since version 2.0
|
||||
*/
|
||||
function bar() {
|
||||
|
||||
|
||||
@ -92,6 +92,7 @@ testFile('test/t/cases/alias2.js');
|
||||
testFile('test/t/cases/augmentstag.js');
|
||||
testFile('test/t/cases/accesstag.js');
|
||||
testFile('test/t/cases/authortag.js');
|
||||
testFile('test/t/cases/classtag.js');
|
||||
testFile('test/t/cases/copyrighttag.js');
|
||||
testFile('test/t/cases/deprecatedtag.js');
|
||||
testFile('test/t/cases/exceptiontag.js');
|
||||
|
||||
@ -6,6 +6,24 @@
|
||||
|
||||
//dump(docSet.doclets);
|
||||
|
||||
test('When a symbol has a @access private tag, the doclet has a access="private" property.', function() {
|
||||
assert.equal(foo.access, 'private');
|
||||
});
|
||||
|
||||
test('When a symbol has a @access protected tag, the doclet has a access="protected" property.', function() {
|
||||
assert.equal(_bar.access, 'protected');
|
||||
});
|
||||
|
||||
test('When a symbol has a @access public tag, the doclet has no access property.', function() {
|
||||
assert.equal(typeof pez.access, 'undefined');
|
||||
});
|
||||
|
||||
// same as...
|
||||
|
||||
foo = docSet.getByLongname('OtherThingy~foo')[0];
|
||||
_bar = docSet.getByLongname('OtherThingy#_bar')[0];
|
||||
pez = docSet.getByLongname('OtherThingy#pez')[0];
|
||||
|
||||
test('When a symbol has a @private tag, the doclet has a access="private" property.', function() {
|
||||
assert.equal(foo.access, 'private');
|
||||
});
|
||||
|
||||
15
test/t/cases/classtag.js
Normal file
15
test/t/cases/classtag.js
Normal file
@ -0,0 +1,15 @@
|
||||
(function() {
|
||||
var docSet = testhelpers.getDocSetFromFile('test/cases/classtag.js'),
|
||||
foo = docSet.getByLongname('Foo')[0];
|
||||
|
||||
//dump(docSet.doclets); exit(0);
|
||||
|
||||
test('When a symbol has a @class tag, the doclet has a classdesc property with that value.', function() {
|
||||
assert.equal(foo.classdesc, 'The class of Foo represent all those foo things.');
|
||||
});
|
||||
|
||||
test('When a symbol has a @class tag, the doclet doclet description is separate from the classdesc.', function() {
|
||||
assert.equal(foo.description, 'This function creates a new Foo.');
|
||||
});
|
||||
|
||||
})();
|
||||
@ -10,7 +10,7 @@
|
||||
});
|
||||
|
||||
test('When a symbol has a @deprec tag with a value, the doclet has a deprecated property set to that value.', function() {
|
||||
assert.equal(bar.deprecated, 'v1.0.2');
|
||||
assert.equal(bar.deprecated, 'since version 2.0');
|
||||
});
|
||||
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user