minor cleanup

This commit is contained in:
Jeff Williams 2015-01-29 14:43:40 -08:00
parent cefe615263
commit 33cd4c5fbb
2 changed files with 19 additions and 12 deletions

View File

@ -41,21 +41,15 @@ function applyTag(doclet, tag) {
// use the meta info about the source code to guess what the doclet kind should be
function codeToKind(code) {
var parent;
var isFunction = jsdoc.src.astnode.isFunction;
// default
var kind = 'member';
var node = code.node;
if (code.type === Syntax.FunctionDeclaration || code.type === Syntax.FunctionExpression) {
if ( isFunction(code.type) ) {
kind = 'function';
}
else if (code.node && code.node.parent) {
parent = code.node.parent;
if ( isFunction(parent) ) {
kind = 'param';
}
else if ( code.node && code.node.parent && isFunction(code.node.parent) ) {
kind = 'param';
}
return kind;

View File

@ -12,11 +12,24 @@ var uid = 100000000;
* Check whether an AST node represents a function.
*
* @alias module:jsdoc/src/astnode.isFunction
* @param {Object} node - The AST node to check.
* @param {(Object|string)} node - The AST node to check, or the `type` property of a node.
* @return {boolean} Set to `true` if the node is a function or `false` in all other cases.
*/
var isFunction = exports.isFunction = function(node) {
return node.type === Syntax.FunctionDeclaration || node.type === Syntax.FunctionExpression;
var type;
if (!node) {
return false;
}
if (typeof node === 'string') {
type = node;
}
else {
type = node.type;
}
return type === Syntax.FunctionDeclaration || type === Syntax.FunctionExpression;
};
/**