mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
minor cleanup
This commit is contained in:
parent
cefe615263
commit
33cd4c5fbb
@ -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;
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user