Add all symbols to the legacy build

This commit is contained in:
Andreas Hocevar
2020-11-04 19:56:24 +01:00
parent 00415c6774
commit 68d6a6b84c
4 changed files with 24 additions and 37 deletions

View File

@@ -1,11 +0,0 @@
/**
* Handle the api annotation.
* @param {Object} dictionary The tag dictionary.
*/
exports.defineTags = function (dictionary) {
dictionary.defineTag('api', {
onTagged: function (doclet, tag) {
doclet.api = true;
},
});
};

View File

@@ -11,7 +11,6 @@
},
"plugins": [
"jsdoc-plugin-typescript",
"config/jsdoc/info/api-plugin",
"config/jsdoc/info/define-plugin",
"config/jsdoc/info/virtual-plugin"
],

View File

@@ -27,19 +27,20 @@ exports.publish = function (data, opts) {
{define: {isObject: true}},
function () {
if (this.kind == 'class') {
if (!('extends' in this) || typeof this.api == 'boolean') {
classes[this.longname] = this;
return true;
}
classes[this.longname] = this;
return true;
}
return (
typeof this.api == 'boolean' ||
(this.meta && /[\\\/]externs$/.test(this.meta.path))
this.meta &&
this.meta.path &&
this.longname.indexOf('<anonymous>') !== 0 &&
this.longname !== 'module:ol'
);
},
],
{kind: {'!is': 'file'}},
{kind: {'!is': 'event'}}
{kind: {'!is': 'event'}},
{kind: {'!is': 'module'}}
).get();
// get symbols data, filter out those that are members of private classes
@@ -77,7 +78,7 @@ exports.publish = function (data, opts) {
path: path.join(doc.meta.path, doc.meta.filename),
default: doc.define.default,
});
} else if (doc.kind == 'typedef' || doc.isEnum === true) {
} else if (doc.type && (doc.kind == 'typedef' || doc.isEnum === true)) {
typedefs.push({
name: doc.longname,
types: getTypes(doc.type.names),
@@ -136,7 +137,7 @@ exports.publish = function (data, opts) {
});
}
const target = isExterns ? externs : doc.api ? symbols : base;
const target = isExterns ? externs : symbols;
const existingSymbol = symbolsByName[symbol.name];
if (existingSymbol) {
const idx = target.indexOf(existingSymbol);
@@ -145,10 +146,9 @@ exports.publish = function (data, opts) {
target.push(symbol);
symbolsByName[symbol.name] = symbol;
if (doc.api && symbol.extends) {
if (symbol.extends) {
while (
symbol.extends in classes &&
!classes[symbol.extends].api &&
classes[symbol.extends].augments
) {
symbol.extends = classes[symbol.extends].augments[0];

View File

@@ -20,7 +20,7 @@ async function getSymbols() {
function getImport(symbol, member) {
const defaultExport = symbol.name.split('~');
const namedExport = symbol.name.split('.');
if (defaultExport.length > 1) {
if (defaultExport.length > 1 && defaultExport[0].indexOf('.') === -1) {
const from = defaultExport[0].replace(/^module\:/, './');
const importName = from.replace(/[.\/]+/g, '$');
return `import ${importName} from '${from}';`;
@@ -53,8 +53,11 @@ function formatSymbolExport(symbol, namespaces, imports) {
namespaces[line] =
(line in namespaces ? namespaces[line] : true) && i < ii - 1;
}
line += ` = ${importName};`;
imports[getImport(symbol, nsParts.pop())] = true;
line += ` = ${importName} || {};`;
const imp = getImport(symbol, nsParts.pop());
if (imp) {
imports[imp] = true;
}
return line;
}
@@ -68,18 +71,15 @@ function formatSymbolExport(symbol, namespaces, imports) {
function generateExports(symbols) {
const namespaces = {};
const imports = [];
let blocks = [];
const blocks = [];
symbols.forEach(function (symbol) {
const name = symbol.name;
if (name.indexOf('#') == -1) {
const imp = getImport(symbol);
if (imp) {
imports[getImport(symbol)] = true;
}
const block = formatSymbolExport(symbol, namespaces, imports);
if (block !== blocks[blocks.length - 1]) {
blocks.push(block);
imports[imp] = true;
}
blocks.push(formatSymbolExport(symbol, namespaces, imports));
}
});
const nsdefs = [];
@@ -89,11 +89,10 @@ function generateExports(symbols) {
nsdefs.push(`${ns[i]} = {};`);
}
}
blocks = Object.keys(imports)
.concat('\nvar ol = {};\n', nsdefs.sort())
.concat(blocks.sort());
blocks.push('', 'export default ol;');
return blocks.join('\n');
const defs = ['\nvar ol = {};'].concat(nsdefs, [...new Set(blocks)]);
const lines = Object.keys(imports).concat(defs.sort());
lines.push('', 'export default ol;');
return lines.join('\n');
}
/**