mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Added support for @typedef tag.
git-svn-id: https://jsdoc.googlecode.com/svn/trunk/@13 d5942f49-e6af-b5c1-9d01-85772c7ca168
This commit is contained in:
parent
ff90450af5
commit
6af99edab7
@ -195,7 +195,7 @@
|
||||
function visitNode(node) {
|
||||
var e,
|
||||
commentSrc;
|
||||
|
||||
|
||||
// look for stand-alone doc comments
|
||||
if (node.type === Token.SCRIPT && node.comments) {
|
||||
// note: ALL comments are seen in this block...
|
||||
|
||||
@ -399,7 +399,24 @@
|
||||
onTagged: function(doclet, tag) {
|
||||
if (tag.value.type) { doclet.type = tag.value.type; }
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
dictionary.defineTag('typedef', {
|
||||
canHaveType: true,
|
||||
canHaveName: true,
|
||||
onTagged: function(doclet, tag) {
|
||||
setDocletKindToTitle(doclet, tag);
|
||||
|
||||
if (tag.value) {
|
||||
if (tag.value.name) {
|
||||
doclet.addTag('name', tag.value.name);
|
||||
}
|
||||
if (tag.value.type) {
|
||||
doclet.type = tag.value.type;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dictionary.defineTag('undocumented', {
|
||||
mustNotHaveValue: true,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jsdoc",
|
||||
"version": "3.0.0beta1",
|
||||
"revision": "2011-02-06-0040",
|
||||
"revision": "2011-02-08-2004",
|
||||
"description": "An automatic documentation generator for javascript.",
|
||||
"keywords": [ "documentation", "javascript" ],
|
||||
"licenses": [
|
||||
|
||||
5
test/cases/typedeftag.js
Normal file
5
test/cases/typedeftag.js
Normal file
@ -0,0 +1,5 @@
|
||||
/** @typedef {(string|number)} calc.NumberLike */
|
||||
|
||||
/** @param {calc.NumberLike} x A number or a string. */
|
||||
calc.readNumber = function(x) {
|
||||
}
|
||||
@ -122,6 +122,7 @@ testFile('test/t/cases/seetag.js');
|
||||
testFile('test/t/cases/sincetag.js');
|
||||
testFile('test/t/cases/thistag.js');
|
||||
testFile('test/t/cases/typetag.js');
|
||||
testFile('test/t/cases/typedeftag.js');
|
||||
testFile('test/t/cases/variations.js');
|
||||
testFile('test/t/cases/versiontag.js');
|
||||
|
||||
|
||||
24
test/t/cases/typedeftag.js
Normal file
24
test/t/cases/typedeftag.js
Normal file
@ -0,0 +1,24 @@
|
||||
(function() {
|
||||
var docSet = testhelpers.getDocSetFromFile('test/cases/typedeftag.js'),
|
||||
numberlike = docSet.getByLongname('calc.NumberLike')[0];
|
||||
|
||||
//dump(docSet.doclets); exit(0);
|
||||
|
||||
test('When a symbol has an @typedef tag, the doclet has a kind property set to "typedef".', function() {
|
||||
assert.equal(numberlike.kind, 'typedef');
|
||||
});
|
||||
|
||||
test('When a symbol has an @typedef tag with a type, the doclet has a type property set to that type.', function() {
|
||||
assert.equal(typeof numberlike.type, 'object');
|
||||
assert.equal(typeof numberlike.type.names, 'object');
|
||||
assert.equal(numberlike.type.names.length, 2);
|
||||
assert.equal(numberlike.type.names[0], 'string');
|
||||
assert.equal(numberlike.type.names[1], 'number');
|
||||
});
|
||||
|
||||
test('When a symbol has an @typedef tag with a name, the doclet has a name property set to that name.', function() {
|
||||
assert.equal(numberlike.name, 'NumberLike');
|
||||
assert.equal(numberlike.longname, 'calc.NumberLike');
|
||||
});
|
||||
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user