Extract types in a separate function
This commit is contained in:
@@ -13,6 +13,15 @@ var path = require('path');
|
|||||||
* @param {Object} opts Options.
|
* @param {Object} opts Options.
|
||||||
*/
|
*/
|
||||||
exports.publish = function(data, opts) {
|
exports.publish = function(data, opts) {
|
||||||
|
|
||||||
|
function getTypes(data) {
|
||||||
|
var types = [];
|
||||||
|
data.forEach(function(name) {
|
||||||
|
types.push(name.replace(/^function$/, 'Function'));
|
||||||
|
});
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
var cwd = process.cwd();
|
var cwd = process.cwd();
|
||||||
|
|
||||||
// get all doclets with the "api" property or define (excluding enums,
|
// get all doclets with the "api" property or define (excluding enums,
|
||||||
@@ -52,11 +61,7 @@ exports.publish = function(data, opts) {
|
|||||||
path: path.join(doc.meta.path, doc.meta.filename)
|
path: path.join(doc.meta.path, doc.meta.filename)
|
||||||
};
|
};
|
||||||
if (doc.type) {
|
if (doc.type) {
|
||||||
types = [];
|
symbol.types = getTypes(doc.type.names);
|
||||||
doc.type.names.forEach(function(name) {
|
|
||||||
types.push(name.replace(/^function$/, 'Function'));
|
|
||||||
});
|
|
||||||
symbol.types = types;
|
|
||||||
}
|
}
|
||||||
if (doc.params) {
|
if (doc.params) {
|
||||||
var params = [];
|
var params = [];
|
||||||
@@ -65,11 +70,7 @@ exports.publish = function(data, opts) {
|
|||||||
name: param.name
|
name: param.name
|
||||||
};
|
};
|
||||||
params.push(paramInfo);
|
params.push(paramInfo);
|
||||||
var types = [];
|
paramInfo.types = getTypes(param.type.names);
|
||||||
param.type.names.forEach(function(name) {
|
|
||||||
types.push(name.replace(/^function$/, 'Function'));
|
|
||||||
});
|
|
||||||
paramInfo.types = types;
|
|
||||||
if (typeof param.variable == 'boolean') {
|
if (typeof param.variable == 'boolean') {
|
||||||
paramInfo.variable = param.variable;
|
paramInfo.variable = param.variable;
|
||||||
}
|
}
|
||||||
@@ -80,11 +81,7 @@ exports.publish = function(data, opts) {
|
|||||||
symbol.params = params;
|
symbol.params = params;
|
||||||
}
|
}
|
||||||
if (doc.returns) {
|
if (doc.returns) {
|
||||||
var returns = [];
|
symbol.returns = getTypes(doc.returns[0].type.names);
|
||||||
doc.returns[0].type.names.forEach(function(name) {
|
|
||||||
returns.push(name.replace(/^function$/, 'Function'));
|
|
||||||
});
|
|
||||||
symbol.returns = returns;
|
|
||||||
}
|
}
|
||||||
if (doc.tags) {
|
if (doc.tags) {
|
||||||
doc.tags.every(function(tag) {
|
doc.tags.every(function(tag) {
|
||||||
|
|||||||
Reference in New Issue
Block a user