Files
openlayers/buildcfg/jsdoc/symbols/publish.js
Tim Schaub 88d67b7370 Regenerate symbols if parents have changed
The generate-symbols.js task runs JSDoc on source files.  Because this takes a long time (13s) to run on the whole library, the resulting symbols file includes additional metadata to make it possible to do incremental symbol generation on subsequent runs.  The 'path' and 'extends' metadata for a symbol are used to determine what needs to be regenerated.
2014-04-29 09:53:06 -06:00

41 lines
1.1 KiB
JavaScript

/**
* @fileoverview Generates JSON output based on doclets with the "api" tag.
*/
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.
var docs = data({api: {isString: true}}).get();
// get symbols data, filter out those that are members of private classes
var symbols = 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;
}).map(function(doc) {
return {
name: doc.longname,
extends: doc.augments,
path: path.join(doc.meta.path, doc.meta.filename)
};
});
process.stdout.write(JSON.stringify({symbols: symbols}, null, 2));
};