Write out sorted symbols, excluding inherited ones on private classes
There are cases where a private class may inherit an exportable member (e.g. ol.DebugTile_#getTileCoord comes from ol.Tile#getTileCoord). We want to avoid making these exportable.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @fileoverview Generates JSON output based on doclets with the "api" tag.
|
* @fileoverview Generates JSON output based on doclets with the "api" tag.
|
||||||
*/
|
*/
|
||||||
|
var assert = require('assert');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
@@ -16,20 +17,25 @@ exports.publish = function(data, opts) {
|
|||||||
// get all doclets with the "api" property.
|
// get all doclets with the "api" property.
|
||||||
var docs = data({api: {isString: true}}).get();
|
var docs = data({api: {isString: true}}).get();
|
||||||
|
|
||||||
process.stdout.write('{"symbols": [');
|
// get sorted symbols, filter out those that are members of private classes
|
||||||
|
var symbols = docs.filter(function(doc) {
|
||||||
// stream JSON for each doclet
|
var include = true;
|
||||||
docs.forEach(function(doc, i) {
|
var constructor = doc.memberof;
|
||||||
var metadata = {
|
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,
|
name: doc.longname,
|
||||||
extends: doc.augments || [],
|
|
||||||
package: doc.api,
|
|
||||||
path: path.join(doc.meta.path, doc.meta.filename)
|
path: path.join(doc.meta.path, doc.meta.filename)
|
||||||
};
|
};
|
||||||
var sep = i > 0 ? ',' : '';
|
}).sort(function(a, b) {
|
||||||
process.stdout.write(sep + JSON.stringify(metadata));
|
return a.name < b.name ? -1 : 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
process.stdout.write(']}\n');
|
process.stdout.write(JSON.stringify({symbols: symbols}, null, 2));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user