Use symbols.json for determining the API
Also to get rid of regular expression parsing, instead of collecting exports for observables from the source files, we use the 'observable' annotations.
This commit is contained in:
committed by
Tim Schaub
parent
758eed357e
commit
b758d92790
@@ -8,25 +8,12 @@
|
|||||||
|
|
||||||
var api = [];
|
var api = [];
|
||||||
var unexported = [];
|
var unexported = [];
|
||||||
|
var observablesByClass = {};
|
||||||
|
|
||||||
function collectExports(source) {
|
function collectExports(source) {
|
||||||
var i, ii, symbol, property;
|
var symbols = JSON.parse(source).symbols;
|
||||||
var syms = source.match(/goog\.exportSymbol\([^\)]*\)/g);
|
for (var i = 0, ii = symbols.length; i < ii; ++i) {
|
||||||
if (syms) {
|
api.push(symbols[i].name);
|
||||||
i = 0; ii = syms.length;
|
|
||||||
for (; i < ii; ++i) {
|
|
||||||
symbol = syms[i].match(/'([^']*)'/)[1];
|
|
||||||
api.push(symbol);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var props = source.match(/goog\.exportProperty\([^\)]*\)/g);
|
|
||||||
if (props) {
|
|
||||||
i = 0; ii = props.length;
|
|
||||||
for (; i < ii; ++i) {
|
|
||||||
property = props[i].match(/[^,]*,[^,]*,\r?\n? *([^\)]*)\)/)[1]
|
|
||||||
.replace('.prototype.', '#');
|
|
||||||
api.push(property);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,18 +31,12 @@ function collectOliExports(source) {
|
|||||||
|
|
||||||
var encoding = env.conf.encoding || 'utf8';
|
var encoding = env.conf.encoding || 'utf8';
|
||||||
var fs = require('jsdoc/fs');
|
var fs = require('jsdoc/fs');
|
||||||
collectExports(fs.readFileSync('build/exports.js', encoding));
|
collectExports(fs.readFileSync('build/symbols.json', encoding));
|
||||||
collectOliExports(fs.readFileSync('externs/oli.js', encoding));
|
collectOliExports(fs.readFileSync('externs/oli.js', encoding));
|
||||||
|
|
||||||
|
|
||||||
exports.handlers = {
|
exports.handlers = {
|
||||||
|
|
||||||
beforeParse: function(e) {
|
|
||||||
if (/\.js$/.test(e.filename)) {
|
|
||||||
collectExports(e.source);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
newDoclet: function(e) {
|
newDoclet: function(e) {
|
||||||
var i, ii, j, jj;
|
var i, ii, j, jj;
|
||||||
if (e.doclet.meta.filename == "olx.js" && e.doclet.longname != 'olx') {
|
if (e.doclet.meta.filename == "olx.js" && e.doclet.longname != 'olx') {
|
||||||
@@ -87,6 +68,12 @@ exports.handlers = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (e.doclet.observables) {
|
||||||
|
var observables = observablesByClass[e.doclet.longname] = [];
|
||||||
|
for (i = e.doclet.observables.length - 1; i >= 0; --i) {
|
||||||
|
observables.push(e.doclet.observables[i].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
parseComplete: function(e) {
|
parseComplete: function(e) {
|
||||||
@@ -109,6 +96,14 @@ exports.handlers = {
|
|||||||
}
|
}
|
||||||
var fqn = doclet.longname;
|
var fqn = doclet.longname;
|
||||||
if (fqn) {
|
if (fqn) {
|
||||||
|
var getterOrSetter = fqn.match(/([^#]*)#[gs]et(.*)/);
|
||||||
|
if (getterOrSetter) {
|
||||||
|
var observables = observablesByClass[getterOrSetter[1]];
|
||||||
|
if (observables && observables.indexOf(getterOrSetter[2].toLowerCase()) > -1) {
|
||||||
|
// Always document getters/setters of observables
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
doclet.unexported = (api.indexOf(fqn) === -1 && unexported.indexOf(fqn) !== -1);
|
doclet.unexported = (api.indexOf(fqn) === -1 && unexported.indexOf(fqn) !== -1);
|
||||||
if (api.indexOf(fqn) === -1 && unexported.indexOf(fqn) === -1) {
|
if (api.indexOf(fqn) === -1 && unexported.indexOf(fqn) === -1) {
|
||||||
e.doclets.splice(j, 1);
|
e.doclets.splice(j, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user