Throw an error with more detail in publish.js and remove olx.control

This commit is contained in:
Tim Schaub
2018-03-11 11:17:45 -06:00
parent e059a50131
commit de9d9ffce1
2 changed files with 49 additions and 53 deletions
+26 -23
View File
@@ -2,8 +2,8 @@
* @fileoverview Generates JSON output based on exportable symbols (those with * @fileoverview Generates JSON output based on exportable symbols (those with
* an api tag) and boolean defines (with a define tag and a default value). * an api tag) and boolean defines (with a define tag and a default value).
*/ */
var assert = require('assert'); const assert = require('assert');
var path = require('path'); const path = require('path');
/** /**
@@ -15,7 +15,7 @@ var path = require('path');
exports.publish = function(data, opts) { exports.publish = function(data, opts) {
function getTypes(data) { function getTypes(data) {
var types = []; const types = [];
data.forEach(function(name) { data.forEach(function(name) {
types.push(name.replace(/^function$/, 'Function')); types.push(name.replace(/^function$/, 'Function'));
}); });
@@ -24,8 +24,8 @@ exports.publish = function(data, opts) {
// get all doclets with the "api" property or define (excluding events) or // get all doclets with the "api" property or define (excluding events) or
// with olx namespace // with olx namespace
var classes = {}; const classes = {};
var docs = data( const docs = data(
[ [
{define: {isObject: true}}, {define: {isObject: true}},
function() { function() {
@@ -43,16 +43,16 @@ exports.publish = function(data, opts) {
{kind: {'!is': 'event'}}).get(); {kind: {'!is': 'event'}}).get();
// get symbols data, filter out those that are members of private classes // get symbols data, filter out those that are members of private classes
var symbols = []; const symbols = [];
var defines = []; const defines = [];
var typedefs = []; const typedefs = [];
var externs = []; const externs = [];
var base = []; let base = [];
var augments = {}; const augments = {};
var symbolsByName = {}; const symbolsByName = {};
docs.filter(function(doc) { docs.filter(function(doc) {
var include = true; let include = true;
var constructor = doc.memberof; const constructor = doc.memberof;
if (constructor && constructor.substr(-1) === '_' && constructor.indexOf('module:') === -1) { if (constructor && constructor.substr(-1) === '_' && constructor.indexOf('module:') === -1) {
assert.strictEqual(doc.inherited, true, assert.strictEqual(doc.inherited, true,
'Unexpected export on private class: ' + doc.longname); 'Unexpected export on private class: ' + doc.longname);
@@ -60,7 +60,7 @@ exports.publish = function(data, opts) {
} }
return include; return include;
}).forEach(function(doc) { }).forEach(function(doc) {
var isExterns = (/[\\\/]externs$/).test(doc.meta.path); const isExterns = (/[\\\/]externs$/).test(doc.meta.path);
if (isExterns && doc.longname.indexOf('olx.') === 0) { if (isExterns && doc.longname.indexOf('olx.') === 0) {
if (doc.kind == 'typedef') { if (doc.kind == 'typedef') {
typedefs.push({ typedefs.push({
@@ -68,8 +68,11 @@ exports.publish = function(data, opts) {
types: ['{}'] types: ['{}']
}); });
} else { } else {
var typedef = typedefs[typedefs.length - 1]; const typedef = typedefs[typedefs.length - 1];
var type = typedef.types[0]; if (!typedef) {
throw new Error(`Expected to see a typedef before ${doc.longname} at ${doc.meta.filename}:${doc.meta.lineno}`);
}
const type = typedef.types[0];
typedef.types[0] = type typedef.types[0] = type
.replace(/\}$/, ', ' + doc.longname.split('#')[1] + .replace(/\}$/, ', ' + doc.longname.split('#')[1] +
': (' + getTypes(doc.type.names).join('|') + ')}') ': (' + getTypes(doc.type.names).join('|') + ')}')
@@ -88,7 +91,7 @@ exports.publish = function(data, opts) {
types: getTypes(doc.type.names) types: getTypes(doc.type.names)
}); });
} else { } else {
var symbol = { const symbol = {
name: doc.longname, name: doc.longname,
kind: doc.kind, kind: doc.kind,
description: doc.classdesc || doc.description, description: doc.classdesc || doc.description,
@@ -104,9 +107,9 @@ exports.publish = function(data, opts) {
symbol.types = getTypes(doc.type.names); symbol.types = getTypes(doc.type.names);
} }
if (doc.params) { if (doc.params) {
var params = []; const params = [];
doc.params.forEach(function(param) { doc.params.forEach(function(param) {
var paramInfo = { const paramInfo = {
name: param.name name: param.name
}; };
params.push(paramInfo); params.push(paramInfo);
@@ -141,10 +144,10 @@ exports.publish = function(data, opts) {
}); });
} }
var target = isExterns ? externs : (doc.api ? symbols : base); const target = isExterns ? externs : (doc.api ? symbols : base);
var existingSymbol = symbolsByName[symbol.name]; const existingSymbol = symbolsByName[symbol.name];
if (existingSymbol) { if (existingSymbol) {
var idx = target.indexOf(existingSymbol); const idx = target.indexOf(existingSymbol);
target.splice(idx, 1); target.splice(idx, 1);
} }
target.push(symbol); target.push(symbol);
-7
View File
@@ -5,13 +5,6 @@
let olx; let olx;
/**
* Namespace.
* @type {Object}
*/
olx.control;
/** /**
* @typedef {{collapsed: (boolean|undefined), * @typedef {{collapsed: (boolean|undefined),
* collapseLabel: (string|Element|undefined), * collapseLabel: (string|Element|undefined),