diff --git a/__tests__/fixture/simple-callback.input.js b/__tests__/fixture/simple-callback.input.js new file mode 100644 index 000000000..f96275827 --- /dev/null +++ b/__tests__/fixture/simple-callback.input.js @@ -0,0 +1,18 @@ +/** + * This takes a number and a callback and calls the callback with the number + * plus 3. + * + * @param {Number} n - The number. + * @param {simpleCallback} cb - The callback. + */ +function takesSimpleCallback(n, cb) { + cb(null, n + 3); +} + +/** + * This callback takes an error and a number. + * + * @callback simpleCallback + * @param {?Error} err - The error. + * @param {Number} n - The number. + */ diff --git a/src/default_theme/index.js b/src/default_theme/index.js index 48ef6682a..1cae8fdf7 100644 --- a/src/default_theme/index.js +++ b/src/default_theme/index.js @@ -9,6 +9,15 @@ var fs = require('fs'), LinkerStack = require('../').util.LinkerStack, hljs = require('highlight.js'); +function isFunction(section) { + return ( + section.kind === 'function' || + (section.kind === 'typedef' && + section.type.type === 'NameExpression' && + section.type.name === 'Function') + ); +} + module.exports = function( comments: Array, config: DocumentationConfig @@ -34,7 +43,7 @@ module.exports = function( var prefix = ''; if (section.kind === 'class') { prefix = 'new '; - } else if (section.kind !== 'function') { + } else if (!isFunction(section)) { return section.name; } return prefix + section.name + formatters.parameters(section, true); @@ -44,7 +53,7 @@ module.exports = function( var prefix = ''; if (section.kind === 'class') { prefix = 'new '; - } else if (section.kind !== 'function') { + } else if (!isFunction(section)) { return section.name; } if (section.returns.length) {