Added support for @class.

This commit is contained in:
Michael Mathews 2010-07-09 21:51:52 +01:00
parent 6db800da84
commit 30812f4e94
5 changed files with 60 additions and 3 deletions

View File

@ -259,12 +259,16 @@
isFile = false, // TODO this should be handled by an event handler in tag dictionary
tagAbout;
for (var i = 0, leni = tags.length; i < leni; i++) {
for (var i = 0; i < tags.length; i++) {
tagAbout = tagDictionary.lookUp(tags[i].name);
if (tagAbout.setsDocletAccess) {
tags[tags.length] = parse_tag.fromText('access '+tags[i].name);
}
if (tagAbout.impliesTag) { // TODO allow a template string?
tags[tags.length] = parse_tag.fromText(tagAbout.impliesTag);
}
if (tags[i].name === 'readonly') {
tags[tags.length] = parse_tag.fromText('attribute readonly');

View File

@ -21,7 +21,8 @@
'fileoverview':'file',
'const': 'constant',
'augments': 'extends',
'throws': 'exception'
'throws': 'exception',
'class': 'classdesc'
};
TagDictionary.resolveSynonyms = function(name) {
@ -57,7 +58,8 @@
canHaveType : false, // this tag can have a {type}
canHavePname : false, // this tag can have a parameter-type name
canHavePdesc : false, // this tag can have a parameter-type desc
keepsWhitespace: false // don't try to tidy up the whitespace in this tag?
keepsWhitespace: false, // don't try to tidy up the whitespace in this tag?
impliesTag : false // this tag implies another tag
};
/** Syntax: @attribute <text>
@ -128,6 +130,15 @@
setsDocletName: true
});
/** Syntax: @classdesc|class <text>
@property {TagDefinition} class
@memberOf module:jsdoc/tagdictionary.tagDefinitions
*/
new TagDefinition('classdesc', { //t
isExported: true,
impliesTag: 'constructor'
});
/** Syntax: @constant|const <docletType> <docletName>
@property {TagDefinition} constant
@memberOf module:jsdoc/tagdictionary.tagDefinitions

View File

@ -15,6 +15,7 @@ load(BASEDIR + '/test/tests/14_tag_member.js');
load(BASEDIR + '/test/tests/15_tag_type.js');
load(BASEDIR + '/test/tests/16_tag_return.js');
load(BASEDIR + '/test/tests/17_tag_example.js');
load(BASEDIR + '/test/tests/18_tag_class.js');
load(BASEDIR + '/test/tests/20_tag_file.js');
load(BASEDIR + '/test/tests/21_tag_const.js');

View File

@ -0,0 +1,6 @@
/**
@name Foo
@class This is the foo class.
@constructor
*/

View File

@ -0,0 +1,35 @@
(function() {
var jsdoc,
doclets;
JSpec.describe('@class', function() {
before(function() {
// docsets can only be created by parsers
jsdoc = {
tag: require('jsdoc/tag'),
parser: require('jsdoc/parser')
};
jsdoc.parser.parseFiles(BASEDIR + 'test/samples/tag_class.js');
doclets = jsdoc.parser.result.map(function($){ return $.toObject(); });
});
describe('A doclet from a class tag with a name tag and no code', function() {
it('should have an `isa` property set to "constructor"', function() {
var doclet = doclets[0];
expect(doclet).to(have_property, 'isa');
expect(doclet.isa).to(eql, 'constructor');
});
it('should have a `name` property set to the given name"', function() {
var doclet = doclets[0];
expect(doclet).to(have_property, 'name');
expect(doclet.name).to(eql, 'Foo');
});
});
});
})();