Added support for @readonly tag.

This commit is contained in:
Michael Mathews 2011-01-16 12:20:49 +00:00
parent 8f5f41f78c
commit 97ae97b46f
4 changed files with 35 additions and 3 deletions

View File

@ -9,7 +9,7 @@
exports.defineTags = function(dictionary) {
dictionary.defineTag('access', {
musHaveValue: true,
mustHaveValue: true,
onTagged: function(doclet, tag) {
if ( /^(private|protected)$/.test(tag.value) ) {
doclet.access = tag.value;
@ -23,7 +23,7 @@
});
dictionary.defineTag('author', {
musHaveValue: true,
mustHaveValue: true,
onTagged: function(doclet, tag) {
doclet.author = tag.value;
@ -75,7 +75,7 @@
.synonym('const');
dictionary.defineTag('copyright', {
musHaveValue: true,
mustHaveValue: true,
onTagged: function(doclet, tag) {
doclet.copyright = tag.value;
@ -319,6 +319,16 @@
}
});
// use this instead of old deprecated @final tag
dictionary.defineTag('readonly', {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.readonly = true;
return false;
}
});
dictionary.defineTag('requires', {
mustHaveValue: true,
onTagged: function(doclet, tag) {

10
test/cases/readonlytag.js Normal file
View File

@ -0,0 +1,10 @@
/**
* @constructor
*/
function Collection() {
/** @readonly */
this.length = 0;
}

View File

@ -99,6 +99,7 @@ testFile('test/t/cases/globaltag.js');
testFile('test/t/cases/ignoretag.js');
testFile('test/t/cases/paramtag.js');
testFile('test/t/cases/privatetag.js');
testFile('test/t/cases/readonlytag.js');
testFile('test/t/cases/requirestag.js');
testFile('test/t/cases/returnstag.js');
testFile('test/t/cases/seetag.js');

View File

@ -0,0 +1,11 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/readonlytag.js'),
Collection = docSet.getByLongname('Collection')[0],
length = docSet.getByLongname('Collection#length')[0];
//dump(docSet.doclets); exit(0);
test('When a symbol has an @readonly tag, the doclet has an readonly property that is true.', function() {
assert.equal(length.readonly, true);
});
})();