Files
openlayers/buildcfg/jsdoc/symbols/publish.js
Tim Schaub 9800b38250 Adding a JSDoc configuration for generating metadata on exported symbols
This generates info for all symbols annotated with "@todo api" (when Plovr is replaced, this will become "@api").  Generated metadata is written to stdout.  A separate process will handle the output.
2014-04-29 09:53:05 -06:00

36 lines
898 B
JavaScript

/**
* @fileoverview Generates JSON output based on doclets with the "api" tag.
*/
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();
process.stdout.write('{"symbols": [');
// stream JSON for each doclet
docs.forEach(function(doc, i) {
var metadata = {
name: doc.longname,
extends: doc.augments || [],
package: doc.api,
path: path.join(doc.meta.path, doc.meta.filename)
};
var sep = i > 0 ? ',' : '';
process.stdout.write(sep + JSON.stringify(metadata));
});
process.stdout.write(']}\n');
};