Merge pull request #11715 from ahocevar/legacy-full
Add all symbols to the legacy build
This commit is contained in:
@@ -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;
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -11,7 +11,6 @@
|
||||
},
|
||||
"plugins": [
|
||||
"jsdoc-plugin-typescript",
|
||||
"config/jsdoc/info/api-plugin",
|
||||
"config/jsdoc/info/define-plugin",
|
||||
"config/jsdoc/info/virtual-plugin"
|
||||
],
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/**
|
||||
* @fileoverview Generates JSON output based on exportable symbols (those with
|
||||
* an api tag) and boolean defines (with a define tag and a default value).
|
||||
* @fileoverview Generates JSON output based on exportable symbols.
|
||||
*/
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
@@ -20,26 +19,27 @@ exports.publish = function (data, opts) {
|
||||
return types;
|
||||
}
|
||||
|
||||
// get all doclets with the "api" property or define (excluding events)
|
||||
// get all doclets that have exports
|
||||
const classes = {};
|
||||
const docs = data(
|
||||
[
|
||||
{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 +77,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 +136,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 +145,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];
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user