Throw an error with more detail in publish.js and remove olx.control
This commit is contained in:
@@ -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,43 +24,43 @@ 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() {
|
||||||
if (this.kind == 'class') {
|
if (this.kind == 'class') {
|
||||||
if (!('extends' in this) || typeof this.api == 'boolean') {
|
if (!('extends' in this) || typeof this.api == 'boolean') {
|
||||||
classes[this.longname] = this;
|
classes[this.longname] = this;
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return (typeof this.api == 'boolean' ||
|
|
||||||
this.meta && (/[\\\/]externs$/).test(this.meta.path));
|
|
||||||
}
|
}
|
||||||
],
|
return (typeof this.api == 'boolean' ||
|
||||||
{kind: {'!is': 'file'}},
|
this.meta && (/[\\\/]externs$/).test(this.meta.path));
|
||||||
{kind: {'!is': 'event'}}).get();
|
}
|
||||||
|
],
|
||||||
|
{kind: {'!is': 'file'}},
|
||||||
|
{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);
|
||||||
include = false;
|
include = false;
|
||||||
}
|
}
|
||||||
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,12 +68,15 @@ 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('|') + ')}')
|
||||||
.replace('{, ', '{');
|
.replace('{, ', '{');
|
||||||
}
|
}
|
||||||
} else if (doc.define) {
|
} else if (doc.define) {
|
||||||
defines.push({
|
defines.push({
|
||||||
@@ -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);
|
||||||
@@ -168,13 +171,13 @@ exports.publish = function(data, opts) {
|
|||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
process.stdout.write(
|
process.stdout.write(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
symbols: symbols,
|
symbols: symbols,
|
||||||
defines: defines,
|
defines: defines,
|
||||||
typedefs: typedefs,
|
typedefs: typedefs,
|
||||||
externs: externs,
|
externs: externs,
|
||||||
base: base
|
base: base
|
||||||
}, null, 2));
|
}, null, 2));
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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),
|
||||||
|
|||||||
Reference in New Issue
Block a user