Rename generate-symbols.js to generate-info.js
This task generates build related metadata for the library based on doc annotations. Since it is about more than writing out exportable symbols, it makes sense to have a more general name.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @fileoverview Generates JSON output based on exportable symbols (those with
|
||||
* an api tag) and boolean defines (with a define tag and a default value).
|
||||
*/
|
||||
var assert = require('assert');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
|
||||
/**
|
||||
* Publish hook for the JSDoc template. Writes to JSON stdout.
|
||||
* @param {function} data The root of the Taffy DB containing doclet records.
|
||||
* @param {Object} opts Options.
|
||||
*/
|
||||
exports.publish = function(data, opts) {
|
||||
var cwd = process.cwd();
|
||||
|
||||
// get all doclets with the "api" property or define (excluding enums,
|
||||
// typedefs and events)
|
||||
var docs = data(
|
||||
[{define: {isObject: true}}, {api: {isString: true}}],
|
||||
{isEnum: {'!is': true}},
|
||||
{kind: {'!is': 'typedef'}},
|
||||
{kind: {'!is': 'event'}}).get();
|
||||
|
||||
// get symbols data, filter out those that are members of private classes
|
||||
var symbols = [];
|
||||
var defines = [];
|
||||
docs.filter(function(doc) {
|
||||
var include = true;
|
||||
var constructor = doc.memberof;
|
||||
if (constructor && constructor.substr(-1) === '_') {
|
||||
assert.strictEqual(doc.inherited, true,
|
||||
'Unexpected export on private class: ' + doc.longname);
|
||||
include = false;
|
||||
}
|
||||
return include;
|
||||
}).forEach(function(doc) {
|
||||
if (doc.define) {
|
||||
defines.push({
|
||||
name: doc.longname,
|
||||
path: path.join(doc.meta.path, doc.meta.filename),
|
||||
default: doc.define.default
|
||||
});
|
||||
} else {
|
||||
symbols.push({
|
||||
name: doc.longname,
|
||||
extends: doc.augments,
|
||||
path: path.join(doc.meta.path, doc.meta.filename)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
process.stdout.write(
|
||||
JSON.stringify({symbols: symbols, defines: defines}, null, 2));
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user