Added support for @access tag.

This commit is contained in:
Michael Mathews 2011-01-15 11:16:29 +00:00
parent fc5319020f
commit 8507f83e88
4 changed files with 50 additions and 1 deletions

View File

@ -7,7 +7,21 @@
*/
(function() {
exports.defineTags = function(dictionary) {
dictionary.defineTag('access', {
musHaveValue: true,
onTagged: function(doclet, tag) {
if ( /^(private|protected)$/.test(tag.value) ) {
doclet.access = tag.value;
}
else if (tag.value === 'public') {
delete doclet.access;
}
return true;
}
});
dictionary.defineTag('borrows', {
mustHaveValue: true,
onTagged: function(doclet, tag) {

13
test/cases/accesstag.js Normal file
View File

@ -0,0 +1,13 @@
/** @constructor */
function Thingy() {
/** @access private */
var foo = 0;
/** @access protected */
this._bar = 1;
/** @access public */
this.pez = 2;
}

View File

@ -89,6 +89,7 @@ testFile('test/t/cases/modules/data/mod-2.js');
testFile('test/t/cases/alias.js');
testFile('test/t/cases/alias2.js');
testFile('test/t/cases/accesstag.js');
testFile('test/t/cases/globaltag.js');
report();

21
test/t/cases/accesstag.js Normal file
View File

@ -0,0 +1,21 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/accesstag.js'),
foo = docSet.getByLongname('Thingy~foo')[0],
_bar = docSet.getByLongname('Thingy#_bar')[0],
pez = docSet.getByLongname('Thingy#pez')[0];
//dump(docSet.doclets);
test('When a symbol has a @private tag, the doclet has a access="private" property.', function() {
assert.equal(foo.access, 'private');
});
test('When a symbol has a @protected tag, the doclet has a access="protected" property.', function() {
assert.equal(_bar.access, 'protected');
});
test('When a symbol has a @public tag, the doclet has no access property.', function() {
assert.equal(typeof pez.access, 'undefined');
});
})();