mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
handle typedefs that contain functions (#292)
This commit is contained in:
parent
fd8fc800af
commit
a693262c66
@ -35,6 +35,27 @@ function hashToLink(doclet, hash) {
|
||||
return '<a href="' + url + '">' + hash + '</a>';
|
||||
}
|
||||
|
||||
function needsSignature(doclet) {
|
||||
var needsSig = false;
|
||||
|
||||
// function and class definitions always get a signature
|
||||
if ( doclet.kind === ('function' || 'class') ) {
|
||||
needsSig = true;
|
||||
}
|
||||
// typedefs that contain functions get a signature, too
|
||||
else if (doclet.kind === 'typedef' && doclet.type && doclet.type.names &&
|
||||
doclet.type.names.length) {
|
||||
for (var i = 0, l = doclet.type.names.length; i < l; i++) {
|
||||
if (doclet.type.names[i].toLowerCase() === 'function') {
|
||||
needsSig = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return needsSig;
|
||||
}
|
||||
|
||||
function addSignatureParams(f) {
|
||||
var params = helper.getSignatureParams(f, 'optional');
|
||||
|
||||
@ -365,7 +386,7 @@ exports.publish = function(taffyData, opts, tutorials) {
|
||||
doclet.id = doclet.name;
|
||||
}
|
||||
|
||||
if (doclet.kind === 'function' || doclet.kind === 'class') {
|
||||
if ( needsSignature(doclet) ) {
|
||||
addSignatureParams(doclet);
|
||||
addSignatureReturns(doclet);
|
||||
addAttribs(doclet);
|
||||
|
||||
@ -120,11 +120,20 @@
|
||||
var typedefs = self.find({kind: 'typedef', memberof: title === 'Global' ? {isUndefined: true} : doc.longname});
|
||||
if (typedefs && typedefs.length && typedefs.forEach) {
|
||||
?>
|
||||
<h3 class="subsection-title">TypeDefs</h3>
|
||||
<h3 class="subsection-title">Type Definitions</h3>
|
||||
|
||||
<dl><?js typedefs.forEach(function(e) { ?>
|
||||
<?js= self.partial('members.tmpl', e) ?>
|
||||
<?js }); ?></dl>
|
||||
<dl><?js typedefs.forEach(function(e) {
|
||||
if (e.signature) {
|
||||
?>
|
||||
<?js= self.partial('method.tmpl', e) ?>
|
||||
<?js
|
||||
}
|
||||
else {
|
||||
?>
|
||||
<?js= self.partial('members.tmpl', e) ?>
|
||||
<?js
|
||||
}
|
||||
}); ?></dl>
|
||||
<?js } ?>
|
||||
|
||||
<?js
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user