Skip to content

Commit 61968c7

Browse files
davedoesdevtmcw
authored andcommittedJun 23, 2017
fix: Show () for callbacks
* Show callback signatures * Add output test for callback * Reformat is_function * Fix comparator * Use camelCase #818
1 parent e472550 commit 61968c7

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed
 
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* This takes a number and a callback and calls the callback with the number
3+
* plus 3.
4+
*
5+
* @param {Number} n - The number.
6+
* @param {simpleCallback} cb - The callback.
7+
*/
8+
function takesSimpleCallback(n, cb) {
9+
cb(null, n + 3);
10+
}
11+
12+
/**
13+
* This callback takes an error and a number.
14+
*
15+
* @callback simpleCallback
16+
* @param {?Error} err - The error.
17+
* @param {Number} n - The number.
18+
*/

‎src/default_theme/index.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ var fs = require('fs'),
99
LinkerStack = require('../').util.LinkerStack,
1010
hljs = require('highlight.js');
1111

12+
function isFunction(section) {
13+
return (
14+
section.kind === 'function' ||
15+
(section.kind === 'typedef' &&
16+
section.type.type === 'NameExpression' &&
17+
section.type.name === 'Function')
18+
);
19+
}
20+
1221
module.exports = function(
1322
comments: Array<Comment>,
1423
config: DocumentationConfig
@@ -34,7 +43,7 @@ module.exports = function(
3443
var prefix = '';
3544
if (section.kind === 'class') {
3645
prefix = 'new ';
37-
} else if (section.kind !== 'function') {
46+
} else if (!isFunction(section)) {
3847
return section.name;
3948
}
4049
return prefix + section.name + formatters.parameters(section, true);
@@ -44,7 +53,7 @@ module.exports = function(
4453
var prefix = '';
4554
if (section.kind === 'class') {
4655
prefix = 'new ';
47-
} else if (section.kind !== 'function') {
56+
} else if (!isFunction(section)) {
4857
return section.name;
4958
}
5059
if (section.returns.length) {

0 commit comments

Comments
 (0)