Build externs file from info.json
This change adds all information that is needed to generate the externs file to build/info.json, so tasks/generate-externs.js no longer needs to spawn JSDoc.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
/**
|
||||
* Handle the api annotation.
|
||||
* @param {Object} dictionary The tag dictionary.
|
||||
*/
|
||||
exports.defineTags = function(dictionary) {
|
||||
|
||||
dictionary.defineTag('api', {
|
||||
onTagged: function(doclet, tag) {
|
||||
doclet.api = tag.text || 'experimental';
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
@@ -10,7 +10,7 @@
|
||||
"includePattern": "\\.js$"
|
||||
},
|
||||
"plugins": [
|
||||
"buildcfg/jsdoc/api-plugin",
|
||||
"buildcfg/jsdoc/define-plugin"
|
||||
"buildcfg/jsdoc/info/api-plugin",
|
||||
"buildcfg/jsdoc/info/define-plugin"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @fileoverview This plugin extracts info from boolean defines. This only
|
||||
* handles boolean defines with the default value in the description. Default
|
||||
* is assumed to be provided with something like "default is `true`" (case
|
||||
* insensitive, with or without ticks).
|
||||
*/
|
||||
|
||||
|
||||
var DEFAULT_VALUE = /default\s+is\s+`?(true|false)`?/i;
|
||||
|
||||
|
||||
/**
|
||||
* Hook to define new tags.
|
||||
* @param {Object} dictionary The tag dictionary.
|
||||
*/
|
||||
exports.defineTags = function(dictionary) {
|
||||
|
||||
dictionary.defineTag('define', {
|
||||
canHaveType: true,
|
||||
mustHaveValue: true,
|
||||
onTagged: function(doclet, tag) {
|
||||
var types = tag.value.type.names;
|
||||
if (types.length === 1 && types[0] === 'boolean') {
|
||||
var match = tag.value.description.match(DEFAULT_VALUE);
|
||||
if (match) {
|
||||
doclet.define = {
|
||||
default: match[1] === 'true'
|
||||
};
|
||||
doclet.description = tag.value.description;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
@@ -44,12 +44,58 @@ exports.publish = function(data, opts) {
|
||||
default: doc.define.default
|
||||
});
|
||||
} else {
|
||||
symbols.push({
|
||||
var types;
|
||||
var symbol = {
|
||||
name: doc.longname,
|
||||
kind: doc.kind,
|
||||
description: doc.classdesc || doc.description,
|
||||
path: path.join(doc.meta.path, doc.meta.filename)
|
||||
});
|
||||
};
|
||||
if (doc.type) {
|
||||
var types = [];
|
||||
doc.type.names.forEach(function(name) {
|
||||
types.push(name);
|
||||
});
|
||||
symbol.types = types;
|
||||
}
|
||||
if (doc.params) {
|
||||
var params = [];
|
||||
doc.params.forEach(function(param) {
|
||||
var paramInfo = {
|
||||
name: param.name
|
||||
};
|
||||
params.push(paramInfo);
|
||||
var types = [];
|
||||
param.type.names.forEach(function(name) {
|
||||
types.push(name);
|
||||
});
|
||||
paramInfo.types = types;
|
||||
if (typeof param.variable == 'boolean') {
|
||||
paramInfo.variable = param.variable;
|
||||
}
|
||||
if (typeof param.optional == 'boolean') {
|
||||
paramInfo.optional = param.optional;
|
||||
}
|
||||
});
|
||||
symbol.params = params;
|
||||
}
|
||||
if (doc.returns) {
|
||||
var returns = [];
|
||||
doc.returns[0].type.names.forEach(function(name) {
|
||||
returns.push(name);
|
||||
});
|
||||
symbol.returns = returns;
|
||||
}
|
||||
if (doc.tags) {
|
||||
doc.tags.every(function(tag) {
|
||||
if (tag.title == 'template') {
|
||||
symbol.template = tag.value;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
symbols.push(symbol);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user