mirror of
https://github.com/documentationjs/documentation.git
synced 2026-01-25 14:26:29 +00:00
Correctly infer @typedef name (fixes #90)
This commit is contained in:
parent
3ab94ab425
commit
42e8aee478
@ -21,20 +21,21 @@ module.exports = function () {
|
||||
return;
|
||||
}
|
||||
|
||||
// If this comment has a @class tag with a name, use it
|
||||
// as a title
|
||||
if (comment.tags[i].title === 'class' && comment.tags[i].name) {
|
||||
comment.tags.push({ title: 'name', name: comment.tags[i].name });
|
||||
this.push(comment);
|
||||
return;
|
||||
}
|
||||
// If this comment has a @class, @event, or @typedef tag with a name,
|
||||
// use it.
|
||||
var explicitNameTags = {
|
||||
'class': 'name',
|
||||
'event': 'description',
|
||||
'typedef': 'description'
|
||||
};
|
||||
|
||||
// If this comment has an @event tag with a name, use it
|
||||
// as a title
|
||||
if (comment.tags[i].title === 'event' && comment.tags[i].description) {
|
||||
comment.tags.push({ title: 'name', name: comment.tags[i].description });
|
||||
this.push(comment);
|
||||
return;
|
||||
for (var title in explicitNameTags) {
|
||||
var value = explicitNameTags[title];
|
||||
if (comment.tags[i].title === title && comment.tags[i][value]) {
|
||||
comment.tags.push({ title: 'name', name: comment.tags[i][value] });
|
||||
this.push(comment);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -121,3 +121,36 @@ test('inferName - explicit name', function (t) {
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('inferName - class', function (t) {
|
||||
evaluate(function () {
|
||||
/** @class ExplicitClass */
|
||||
function ImplicitClass() {}
|
||||
return ImplicitClass;
|
||||
}, function (result) {
|
||||
t.equal(result[ 0 ].name, 'ExplicitClass');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('inferName - event', function (t) {
|
||||
evaluate(function () {
|
||||
/** @event explicitEvent */
|
||||
function implicitName() {}
|
||||
return implicitName;
|
||||
}, function (result) {
|
||||
t.equal(result[ 0 ].name, 'explicitEvent');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('inferName - typedef', function (t) {
|
||||
evaluate(function () {
|
||||
/** @typedef {Object} ExplicitTypedef */
|
||||
function implicitName() {}
|
||||
return implicitName;
|
||||
}, function (result) {
|
||||
t.equal(result[ 0 ].name, 'ExplicitTypedef');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user