Skip to content

Commit

Permalink
[INTERNAL] JSDoc: prepare for the use of JSDoc 4.0.0
Browse files Browse the repository at this point in the history
Avoid the use of TaffyDB APIs in the active publishing variants
(apijson, apixml, fullapixml) as not all TaffyDB APIs are supported by
the replacement 'Salty' in JSDoc 4.0.0.

The get() API is still used, all other operations are replaced with
native array operations.

Legacy publishing variants (apijs, full, public, demokit,
demokit-internal) are not adapted as they are no longer functional.
They'll be cleaned up in a later change.

Change-Id: I2e71ca909cefb13bdd16847f81fdfed593b6e61a
JIRA: https://jira.tools.sap/browse/CPOUI5FOUNDATION-595
  • Loading branch information
codeworrior committed Feb 4, 2023
1 parent 315fde3 commit 187bc3e
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions lib/jsdoc/ui5/template/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ let conf = {};

let view;

let __db;
let __symbols;
let __longnames;
let __missingLongnames = {};

Expand Down Expand Up @@ -120,12 +120,10 @@ function merge(target, source) {
return target;
}

function lookup(longname /*, variant*/) {
let key = longname; // variant ? longname + "|" + variant : longname;
function lookup(key) {
if ( !Object.prototype.hasOwnProperty.call(__longnames, key) ) {
__missingLongnames[key] = (__missingLongnames[key] || 0) + 1;
let oResult = __db({longname: longname /*, variant: variant ? variant : {isUndefined: true}*/});
__longnames[key] = oResult.first();
__longnames[key] = __symbols.find((symbol) => symbol.longname === key);
}
return __longnames[key];
}
Expand Down Expand Up @@ -408,19 +406,21 @@ function publish(symbolSet) {
// create output dir
fs.mkPath(env.opts.destination);

// if ( symbolSet().count() < 20000 ) {
__symbols = symbolSet().get();

// if ( __symbols.length < 20000 ) {
// const rawSymbolsFile = path.join(env.opts.destination, "symbols-unpruned-ui5.json");
// info(`writing raw symbols to ${rawSymbolsFile}`);
// fs.writeFileSync(rawSymbolsFile, JSON.stringify(symbolSet().get(), filter, "\t"), 'utf8');
// fs.writeFileSync(rawSymbolsFile, JSON.stringify(__symbols, filter, "\t"), 'utf8');
// }

info(`before prune: ${symbolSet().count()} symbols.`);
info(`before prune: ${__symbols.length} symbols.`);
symbolSet = helper.prune(symbolSet);
info(`after prune: ${symbolSet().count()} symbols.`);
__symbols = symbolSet().get();
info(`after prune: ${__symbols.length} symbols.`);

__db = symbolSet;
__longnames = {};
__db().each(function($) {
__symbols.forEach(function($) {
__longnames[$.longname] = $;
});

Expand Down Expand Up @@ -470,17 +470,17 @@ function publish(symbolSet) {
collectMembers();
mergeEventDocumentation();

if ( symbolSet().count() < 20000 ) {
if ( __symbols.length < 20000 ) {
const rawSymbolsFile = path.join(env.opts.destination, "symbols-pruned-ui5.json");
info(`writing raw symbols to ${rawSymbolsFile}`);
fs.writeFileSync(rawSymbolsFile, JSON.stringify(symbolSet().get(), filter, "\t"), 'utf8');
fs.writeFileSync(rawSymbolsFile, JSON.stringify(__symbols, filter, "\t"), 'utf8');
}

// used to allow Link to check the details of things being linked to
Link.symbolSet = symbolSet;

// get an array version of the symbol set, useful for filtering
const symbols = symbolSet().get();
const symbols = __symbols;

// -----

Expand Down Expand Up @@ -662,10 +662,10 @@ function publish(symbolSet) {
*/
function createNamespaceTree() {

info(`create namespace tree (${__db().count()} symbols)`);
info(`create namespace tree (${__symbols.length} symbols)`);

const aRootNamespaces = [];
const aTypes = __db(function() { return isFirstClassSymbol(this); }).get();
const aTypes = __symbols.filter((symbol) => isFirstClassSymbol(symbol));

for (let i = 0; i < aTypes.length; i++) { // loop with a for-loop as it can handle concurrent modifications

Expand All @@ -677,7 +677,7 @@ function createNamespaceTree() {
warning(`create missing namespace '${symbol.memberof}' (referenced by ${symbol.longname})`);
parent = makeNamespace(symbol.memberof);
__longnames[symbol.memberof] = parent;
__db.insert(parent);
__symbols.push(parent);
aTypes.push(parent); // concurrent modification: parent will be processed later in this loop
}
symbol.__ui5.parent = parent;
Expand Down Expand Up @@ -732,13 +732,13 @@ function createInheritanceTree() {
const newDoclet = new doclet.Doclet("/**\n * " + lines.join("\n * ") + "\n */", {});
newDoclet.__ui5 = {};
__longnames[longname] = newDoclet;
__db.insert(newDoclet);
__symbols.push(newDoclet);
return newDoclet;
}

info(`create inheritance tree (${__db().count()} symbols)`);
info(`create inheritance tree (${__symbols.length} symbols)`);

const oTypes = __db(function() { return supportsInheritance(this); });
const aTypes = __symbols.filter((symbol) => supportsInheritance(symbol));
const aRootTypes = [];

let oObject = lookup("Object");
Expand Down Expand Up @@ -780,7 +780,7 @@ function createInheritanceTree() {
}

// link them according to the inheritance infos
oTypes.each((oClass) => {
aTypes.forEach((oClass) => {

if ( oClass.longname === 'Object') {
return;
Expand Down Expand Up @@ -849,7 +849,7 @@ function createInheritanceTree() {

// check for cyclic inheritance (not supported)
// Note: the check needs to run bottom up, not top down as a typical cyclic dependency never will end at the root node
oTypes.each((oStartClass) => {
aTypes.forEach((oStartClass) => {
const visited = {};
function visit(oClass) {
if ( visited[oClass.longname] ) {
Expand All @@ -869,7 +869,7 @@ function createInheritanceTree() {
}

function collectMembers() {
__db().each(function($) {
__symbols.forEach(function($) {
if ( $.memberof ) {
const parent = lookup($.memberof);
if ( parent /* && supportsInheritance(parent) */ ) {
Expand All @@ -884,9 +884,9 @@ function mergeEventDocumentation() {

debug("merging JSDoc event documentation into UI5 metadata");

const oTypes = __db(function() { return isaClass(this); });
const aTypes = __symbols.filter((symbol) => isaClass(symbol));

oTypes.each((symbol) => {
aTypes.forEach((symbol) => {

const metadata = symbol.__ui5.metadata;
const members = symbol.__ui5.members;
Expand Down

0 comments on commit 187bc3e

Please sign in to comment.