handle typedefs that contain functions (#292)

This commit is contained in:
Jeff Williams 2013-01-23 22:03:29 -08:00
parent fd8fc800af
commit a693262c66
2 changed files with 35 additions and 5 deletions

View File

@ -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);

View File

@ -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