From 399af060b86069ad30ba99b4299b275c81f377a6 Mon Sep 17 00:00:00 2001
From: Merlin Beutlberger ' : options.beforeParagraph;
- var afterParagraph = options.afterParagraph === undefined ? ' " : options.beforeParagraph;
+ const afterParagraph = options.afterParagraph === undefined ? "
';
+ target.forEach(function(element) {
+ result += element + "
";
});
}
@@ -784,15 +761,18 @@ module.exports = function transformer(sInputFile, sOutputFile, sLibraryFile) {
/**
* Formats the namespace of annotations
- * @param namespace - the namespace to be formatted
- * @returns string - the formatted text
+ *
+ * @param {string} namespace - the namespace to be formatted
+ * @returns {string} - the formatted text
*/
- formatAnnotationNamespace: function (namespace) {
- var result,
- aNamespaceParts = namespace.split(".");
+ formatAnnotationNamespace: function(namespace) {
+ let result;
+
+
+ const aNamespaceParts = namespace.split(".");
if (aNamespaceParts[0] === "Org" && aNamespaceParts[1] === "OData") {
- result = '' + namespace + '';
+ result = "" + namespace + "";
} else {
result = namespace;
}
@@ -803,55 +783,56 @@ module.exports = function transformer(sInputFile, sOutputFile, sLibraryFile) {
/**
* Formats the description of annotations
- * @param description - the description of the annotation
- * @param since - the since version information of the annotation
- * @returns string - the formatted description
+ *
+ * @param {string} description - the description of the annotation
+ * @param {string} since - the since version information of the annotation
+ * @returns {string} - the formatted description
*/
- formatAnnotationDescription: function (description, since) {
- var result = description || "";
+ formatAnnotationDescription: function(description, since) {
+ let result = description || "";
- result += '
For more information, see ' + 'OData v4 Annotations';
+ result += "
For more information, see " + "OData v4 Annotations";
if (since) {
- result += '
Since: ' + since + '.';
+ result += "
Since: " + since + ".";
}
result = this._preProcessLinksInTextBlock(result);
return result;
},
- formatExceptionLink: function (linkText) {
- linkText = linkText || '';
- return linkText.indexOf('sap.ui.') !== -1;
+ formatExceptionLink: function(linkText) {
+ linkText = linkText || "";
+ return linkText.indexOf("sap.ui.") !== -1;
},
- formatMethodCode: function (sName, aParams, aReturnValue) {
- var result = '' + sName + '(';
+ formatMethodCode: function(sName, aParams, aReturnValue) {
+ let result = "
" + sName + "(";
if (aParams && aParams.length > 0) {
/* We consider only root level parameters so we get rid of all that are not on the root level */
- aParams = aParams.filter(oElem => {
+ aParams = aParams.filter((oElem) => {
return oElem.depth === undefined;
});
- aParams.forEach(function (element, index, array) {
+ aParams.forEach(function(element, index, array) {
result += element.name;
if (element.optional) {
- result += '?';
+ result += "?";
}
if (index < array.length - 1) {
- result += ', ';
+ result += ", ";
}
});
}
- result += ') : ';
+ result += ") : ";
if (aReturnValue) {
result += aReturnValue.type;
} else {
- result += 'void';
+ result += "void";
}
result += "
";
@@ -861,35 +842,38 @@ module.exports = function transformer(sInputFile, sOutputFile, sLibraryFile) {
/**
* Formats method deprecation message and pre-process jsDoc link and code blocks
+ *
* @param {string} sSince since text
* @param {string} sDescription deprecation description text
* @returns {string} formatted deprecation message
*/
- formatMethodDeprecated: function (sSince, sDescription) {
+ formatMethodDeprecated: function(sSince, sDescription) {
return this.formatDeprecated(sSince, sDescription, "methods");
},
/**
* Formats event deprecation message and pre-process jsDoc link and code blocks
+ *
* @param {string} sSince since text
* @param {string} sDescription deprecation description text
* @returns {string} formatted deprecation message
*/
- formatEventDeprecated: function (sSince, sDescription) {
+ formatEventDeprecated: function(sSince, sDescription) {
return this.formatDeprecated(sSince, sDescription, "events");
},
/**
* Formats the description of control properties
- * @param description - the description of the property
- * @param since - the since version information of the property
- * @returns string - the formatted description
+ *
+ * @param {string} description - the description of the property
+ * @param {string} since - the since version information of the property
+ * @returns {string} - the formatted description
*/
- formatDescriptionSince: function (description, since) {
- var result = description || "";
+ formatDescriptionSince: function(description, since) {
+ let result = description || "";
if (since) {
- result += '
Since: ' + since + '.';
+ result += "
Since: " + since + ".";
}
result = this._preProcessLinksInTextBlock(result);
@@ -898,62 +882,64 @@ module.exports = function transformer(sInputFile, sOutputFile, sLibraryFile) {
/**
* Formats the default value of the property as a string.
- * @param defaultValue - the default value of the property
- * @returns string - The default value of the property formatted as a string.
+ *
+ * @param {string} defaultValue - the default value of the property
+ * @returns {string} - The default value of the property formatted as a string.
*/
- formatDefaultValue: function (defaultValue) {
- var sReturn;
+ formatDefaultValue: function(defaultValue) {
+ let sReturn;
switch (defaultValue) {
- case null:
- case undefined:
- sReturn = '';
- break;
- case '':
- sReturn = 'empty string';
- break;
- default:
- sReturn = defaultValue;
+ case null:
+ case undefined:
+ sReturn = "";
+ break;
+ case "":
+ sReturn = "empty string";
+ break;
+ default:
+ sReturn = defaultValue;
}
- return Array.isArray(sReturn) ? sReturn.join(', ') : sReturn;
+ return Array.isArray(sReturn) ? sReturn.join(", ") : sReturn;
},
/**
* Formats the constructor of the class
- * @param name
- * @param params
- * @returns string - The code needed to create an object of that class
+ *
+ * @param {string} name
+ * @param {Array} params
+ * @returns {string} - The code needed to create an object of that class
*/
- formatConstructor: function (name, params) {
- var result = 'new ';
+ formatConstructor: function(name, params) {
+ let result = "
";
}
return result;
},
- formatExample: function (sCaption, sText) {
+ formatExample: function(sCaption, sText) {
return this.formatDescription(
["Example: ",
sCaption,
@@ -965,21 +951,21 @@ module.exports = function transformer(sInputFile, sOutputFile, sLibraryFile) {
/**
* Formats the name of a property or a method depending on if it's static or not
- * @param sName {string} - Name
- * @param sClassName {string} - Name of the class
- * @param bStatic {boolean} - If it's static
+ *
+ * @param {string} sName - Name
+ * @param {string} sClassName - Name of the class
+ * @param {boolean} bStatic - If it's static
* @returns {string} - Formatted name
*/
- formatEntityName: function (sName, sClassName, bStatic) {
+ formatEntityName: function(sName, sClassName, bStatic) {
return (bStatic === true) ? sClassName + "." + sName : sName;
},
- JSDocUtil: function () {
-
- var rEscapeRegExp = /[[\]{}()*+?.\\^$|]/g;
+ getJSDocUtil: function() {
+ const rEscapeRegExp = /[[\]{}()*+?.\\^$|]/g;
// Local mocked methods
- var escapeRegExp = function escapeRegExp(sString) {
+ const escapeRegExp = function escapeRegExp(sString) {
return sString.replace(rEscapeRegExp, "\\$&");
};
@@ -988,13 +974,15 @@ module.exports = function transformer(sInputFile, sOutputFile, sLibraryFile) {
}
function format(src, options) {
-
options = options || {};
- var beforeParagraph = options.beforeParagraph === undefined ? 'new ";
if (name) {
- result += name + '(';
+ result += name + "(";
}
if (params) {
- params.forEach(function (element, index, array) {
+ params.forEach(function(element, index, array) {
result += element.name;
if (element.optional) {
- result += '?';
+ result += "?";
}
if (index < array.length - 1) {
- result += ', ';
+ result += ", ";
}
});
}
if (name) {
- result += ')
';
+ result += ") block -] [---- some header ----] [---- an inline [@link ...} tag ----] [---------- an empty line ---------] */
- var r = /(
");
+ if ( p.optional ) {
+ r.push("?");
+ }
}
}
}
- r.push(')');
- return r.join('');
+ r.push(")");
+ return r.join("");
}
@@ -1484,110 +1497,120 @@ function makeSignature(params) {
* group 7: an empty line which implicitly starts a new paragraph
*
* [------- )|(<\/pre>)|(
)|(<\/pre>)|(
...
pattern
- sDescription = sDescription.replace(/(\S+)<\/code>/gi, function (sMatch, sCodeEntity) {
- return ['', sCodeEntity, ''].join("");
- }
+ sDescription = sDescription.replace(/
(\S+)<\/code>/gi, function(sMatch, sCodeEntity) {
+ return ["", sCodeEntity, ""].join("");
+ }
);
// Evaluate links in the deprecation description
@@ -1283,30 +1299,32 @@ module.exports = function transformer(sInputFile, sOutputFile, sLibraryFile) {
return aResult.join("");
},
- _formatChildDescription: function (description) {
+ _formatChildDescription: function(description) {
if (description) {
return this._extractFirstSentence(description);
}
},
- /** Just the first sentence (up to a full stop). Should not break on dotted variable names. */
+ /* Just the first sentence (up to a full stop). Should not break on dotted variable names. */
_extractFirstSentence: function(desc) {
if ( desc ) {
- desc = String(desc).replace(/\s+/g, ' ').
- replace(/^(<\/?p>|
|
|mSettings
that defines initial",
"property values, aggregated and associated objects as well as event handlers.",
- "See {@link sap.ui.base.ManagedObject#constructor} for a general description of the syntax of the settings object."
+ "See {@link sap.ui.base.ManagedObject#constructor} for a general description of " +
+ "the syntax of the settings object."
);
}
// add the settings section only if there are any settings
if ( !isEmpty(oClassInfo.properties)
- || !isEmpty(oClassInfo.aggregations)
- || !isEmpty(oClassInfo.associations)
- || !isEmpty(oClassInfo.events) ) {
-
+ || !isEmpty(oClassInfo.aggregations)
+ || !isEmpty(oClassInfo.associations)
+ || !isEmpty(oClassInfo.events) ) {
lines.push(
"",
includeSettings ? "" : "@ui5-settings",
@@ -1201,7 +1204,10 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
lines.push("");
for (n in oClassInfo.properties) {
- lines.push("
");
lines.push("");
for (n in oClassInfo.aggregations) {
if ( oClassInfo.aggregations[n].visibility !== "hidden" ) {
- lines.push("
");
@@ -1221,7 +1228,8 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
lines.push("");
for (n in oClassInfo.associations) {
- lines.push("
");
lines.push("");
for (n in oClassInfo.events) {
- lines.push("
");
lines.push("sClassName
",
"and enriches it with the information contained in oClassInfo
.",
"",
- "oClassInfo
might contain the same kind of information as described in {@link " + (oClassInfo.baseType ? oClassInfo.baseType + ".extend" : "sap.ui.base.Object.extend Object.extend") + "}.",
+ "oClassInfo
might contain the same kind of information as described in {@link " +
+ (oClassInfo.baseType ? oClassInfo.baseType + ".extend" : "sap.ui.base.Object.extend Object.extend") + "}.",
"",
"@param {string} sClassName Name of the class being created",
"@param {object} [oClassInfo] Object literal with information about the class",
@@ -1306,11 +1312,11 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
for (n in oClassInfo.properties ) {
info = oClassInfo.properties[n];
- if ( info.visibility === 'hidden' ) {
+ if ( info.visibility === "hidden" ) {
continue;
}
// link = newStyle ? "{@link #setting:" + n + " " + n + "}" : "" + n + "
";
- link = "{@link " + (newStyle ? "#setting:" + n : rname("get", n)) + " " + n + "}";
+ link = "{@link " + (newStyle ? "#setting:" + n : rname("get", n)) + " " + n + "}";
newJSDoc([
"Gets current value of property " + link + ".",
"",
@@ -1322,7 +1328,7 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
info.deprecation ? "@deprecated " + info.deprecation : "",
info.experimental ? "@experimental " + info.experimental : "",
"@public",
- "@name " + name("get",n),
+ "@name " + name("get", n),
"@function"
]);
newJSDoc([
@@ -1333,13 +1339,13 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
"When called with a value of null
or undefined
, the default value of the property will be restored.",
"",
info.defaultValue !== null ? "Default value is " + (info.defaultValue === "" ? "empty string" : info.defaultValue) + "
." : "",
- "@param {" + info.type + "} " + varname(n,info.type,true) + " New value for property " + n + "
",
+ "@param {" + info.type + "} " + varname(n, info.type, true) + " New value for property " + n + "
",
"@returns {" + oClassInfo.name + "} Reference to this
in order to allow method chaining",
info.since ? "@since " + info.since : "",
info.deprecation ? "@deprecated " + info.deprecation : "",
info.experimental ? "@experimental " + info.experimental : "",
"@public",
- "@name " + name("set",n),
+ "@name " + name("set", n),
"@function"
]);
if ( info.bindable ) {
@@ -1354,7 +1360,7 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
info.deprecation ? "@deprecated " + info.deprecation : "",
info.experimental ? "@experimental " + info.experimental : "",
"@public",
- "@name " + name("bind",n),
+ "@name " + name("bind", n),
"@function"
]);
newJSDoc([
@@ -1364,7 +1370,7 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
info.deprecation ? "@deprecated " + info.deprecation : "",
info.experimental ? "@experimental " + info.experimental : "",
"@public",
- "@name " + name("unbind",n),
+ "@name " + name("unbind", n),
"@function"
]);
}
@@ -1372,11 +1378,11 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
for (n in oClassInfo.aggregations ) {
info = oClassInfo.aggregations[n];
- if ( info.visibility === 'hidden' ) {
+ if ( info.visibility === "hidden" ) {
continue;
}
// link = newStyle ? "{@link #setting:" + n + " " + n + "}" : "" + n + "
";
- link = "{@link " + (newStyle ? "#setting:" + n : rname("get", n)) + " " + n + "}";
+ link = "{@link " + (newStyle ? "#setting:" + n : rname("get", n)) + " " + n + "}";
newJSDoc([
"Gets content of aggregation " + link + ".",
"",
@@ -1388,7 +1394,7 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
info.deprecation ? "@deprecated " + info.deprecation : "",
info.experimental ? "@experimental " + info.experimental : "",
"@public",
- "@name " + name("get",n),
+ "@name " + name("get", n),
"@function"
]);
if ( info.cardinality == "0..n" ) {
@@ -1397,7 +1403,7 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
"Inserts a " + n1 + " into the aggregation " + link + ".",
"",
"@param {" + makeTypeString(info, true) + "}",
- " " + varname(n1,info.altTypes ? "variant" : info.type) + " The " + n1 + " to insert; if empty, nothing is inserted",
+ " " + varname(n1, info.altTypes ? "variant" : info.type) + " The " + n1 + " to insert; if empty, nothing is inserted",
"@param {int}",
" iIndex The 0
-based index the " + n1 + " should be inserted at; for",
" a negative value of iIndex
, the " + n1 + " is inserted at position 0; for a value",
@@ -1408,26 +1414,26 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
info.deprecation ? "@deprecated " + info.deprecation : "",
info.experimental ? "@experimental " + info.experimental : "",
"@public",
- "@name " + name("insert",n1),
+ "@name " + name("insert", n1),
"@function"
]);
newJSDoc([
"Adds some " + n1 + " to the aggregation " + link + ".",
"@param {" + makeTypeString(info, true) + "}",
- " " + varname(n1,info.altTypes ? "variant" : info.type) + " The " + n1 + " to add; if empty, nothing is inserted",
+ " " + varname(n1, info.altTypes ? "variant" : info.type) + " The " + n1 + " to add; if empty, nothing is inserted",
"@returns {" + oClassInfo.name + "} Reference to this
in order to allow method chaining",
info.since ? "@since " + info.since : "",
info.deprecation ? "@deprecated " + info.deprecation : "",
info.experimental ? "@experimental " + info.experimental : "",
"@public",
- "@name " + name("add",n1),
+ "@name " + name("add", n1),
"@function"
]);
newJSDoc([
"Removes a " + n1 + " from the aggregation " + link + ".",
"",
- "@param {int | string | " + makeTypeString(info, true) + "} " + varname(n1,"variant") + " The " + n1 + " to remove or its index or id",
+ "@param {int | string | " + makeTypeString(info, true) + "} " + varname(n1, "variant") + " The " + n1 + " to remove or its index or id",
"@returns {" + makeTypeString(info, true) + "} The removed " + n1 + " or null
",
info.since ? "@since " + info.since : "",
info.deprecation ? "@deprecated " + info.deprecation : "",
@@ -1496,7 +1502,7 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
info.deprecation ? "@deprecated " + info.deprecation : "",
info.experimental ? "@experimental " + info.experimental : "",
"@public",
- "@name " + name("bind",n),
+ "@name " + name("bind", n),
"@function"
]);
newJSDoc([
@@ -1506,7 +1512,7 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
info.deprecation ? "@deprecated " + info.deprecation : "",
info.experimental ? "@experimental " + info.experimental : "",
"@public",
- "@name " + name("unbind",n),
+ "@name " + name("unbind", n),
"@function"
]);
}
@@ -1514,11 +1520,11 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
for (n in oClassInfo.associations ) {
info = oClassInfo.associations[n];
- if ( info.visibility === 'hidden' ) {
+ if ( info.visibility === "hidden" ) {
continue;
}
// link = newStyle ? "{@link #setting:" + n + " " + n + "}" : "" + n + "
";
- link = "{@link " + (newStyle ? "#setting:" + n : rname("get", n)) + " " + n + "}";
+ link = "{@link " + (newStyle ? "#setting:" + n : rname("get", n)) + " " + n + "}";
newJSDoc([
info.cardinality === "0..n" ?
"Returns array of IDs of the elements which are the current targets of the association " + link + "." :
@@ -1531,7 +1537,7 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
info.deprecation ? "@deprecated " + info.deprecation : "",
info.experimental ? "@experimental " + info.experimental : "",
"@public",
- "@name " + name("get",n),
+ "@name " + name("get", n),
"@function"
]);
if ( info.cardinality === "0..n" ) {
@@ -1539,18 +1545,20 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
newJSDoc([
"Adds some " + n1 + " into the association " + link + ".",
"",
- "@param {sap.ui.core.ID | " + info.type + "} " + varname(n1, "variant") + " The " + n + " to add; if empty, nothing is inserted",
+ "@param {sap.ui.core.ID | " + info.type + "} " + varname(n1, "variant") + " The " + n +
+ " to add; if empty, nothing is inserted",
"@returns {" + oClassInfo.name + "} Reference to this
in order to allow method chaining",
info.since ? "@since " + info.since : "",
info.deprecation ? "@deprecated " + info.deprecation : "",
info.experimental ? "@experimental " + info.experimental : "",
"@public",
- "@name " + name("add",n1),
+ "@name " + name("add", n1),
"@function"
]);
newJSDoc([
"Removes an " + n1 + " from the association named " + link + ".",
- "@param {int | sap.ui.core.ID | " + info.type + "} " + varname(n1,"variant") + " The " + n1 + " to be removed or its index or ID",
+ "@param {int | sap.ui.core.ID | " + info.type + "} " + varname(n1, "variant") + " The " + n1 +
+ " to be removed or its index or ID",
"@returns {sap.ui.core.ID} The removed " + n1 + " or null
",
info.since ? "@since " + info.since : "",
info.deprecation ? "@deprecated " + info.deprecation : "",
@@ -1572,7 +1580,9 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
} else {
newJSDoc([
"Sets the associated " + link + ".",
- "@param {sap.ui.core.ID | " + info.type + "} " + varname(n, info.type) + " ID of an element which becomes the new target of this " + n + " association; alternatively, an element instance may be given",
+ "@param {sap.ui.core.ID | " + info.type + "} " + varname(n, info.type) +
+ " ID of an element which becomes the new target of this " + n +
+ " association; alternatively, an element instance may be given",
"@returns {" + oClassInfo.name + "} Reference to this
in order to allow method chaining",
info.since ? "@since " + info.since : "",
info.deprecation ? "@deprecated " + info.deprecation : "",
@@ -1586,7 +1596,7 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
for (n in oClassInfo.events ) {
info = oClassInfo.events[n];
- //link = newStyle ? "{@link #event:" + n + " " + n + "}" : "" + n + "
";
+ // link = newStyle ? "{@link #event:" + n + " " + n + "}" : "" + n + "
";
link = "{@link #event:" + n + " " + n + "}";
lines = [
@@ -1610,19 +1620,23 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
newJSDoc(lines);
newJSDoc([
- "Attaches event handler fnFunction
to the " + link + " event of this " + oClassInfo.name + "
.",
+ "Attaches event handler fnFunction
to the " + link + " event of this " +
+ oClassInfo.name + "
.",
"",
- "When called, the context of the event handler (its this
) will be bound to oListener
if specified, ",
+ "When called, the context of the event handler (its this
) will be bound to " +
+ "oListener
if specified, ",
"otherwise it will be bound to this " + oClassInfo.name + "
itself.",
"",
!newStyle && info.doc ? info.doc : "",
"",
"@param {object}",
- " [oData] An application-specific payload object that will be passed to the event handler along with the event object when firing the event",
+ " [oData] An application-specific payload object that will be passed to the event handler " +
+ "along with the event object when firing the event",
"@param {function}",
" fnFunction The function to be called when the event occurs",
"@param {object}",
- " [oListener] Context object to call the event handler with. Defaults to this " + oClassInfo.name + "
itself",
+ " [oListener] Context object to call the event handler with. Defaults to this " +
+ oClassInfo.name + "
itself",
"",
"@returns {" + oClassInfo.name + "} Reference to this
in order to allow method chaining",
"@public",
@@ -1633,7 +1647,8 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
"@function"
]);
newJSDoc([
- "Detaches event handler fnFunction
from the " + link + " event of this " + oClassInfo.name + "
.",
+ "Detaches event handler fnFunction
from the " + link + " event of this " +
+ oClassInfo.name + "
.",
"",
"The passed function and listener object must match the ones used for event registration.",
"",
@@ -1656,9 +1671,10 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
];
if ( info.allowPreventDefault ) {
lines.push(
- "",
- "Listeners may prevent the default action of this event by using the preventDefault
-method on the event object.",
- "");
+ "",
+ "Listeners may prevent the default action of this event by using the " +
+ "preventDefault
-method on the event object.",
+ "");
}
lines.push(
"",
@@ -1667,7 +1683,8 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
if ( !isEmpty(info.parameters) ) {
for (pName in info.parameters) {
lines.push(
- "@param {" + (info.parameters[pName].type || "any") + "} [mParameters." + pName + "] " + (info.parameters[pName].doc || "")
+ "@param {" + (info.parameters[pName].type || "any") + "} [mParameters." + pName + "] " +
+ (info.parameters[pName].doc || "")
);
}
lines.push("");
@@ -1675,7 +1692,8 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
if ( info.allowPreventDefault ) {
lines.push("@returns {boolean} Whether or not to prevent the default action");
} else {
- lines.push("@returns {" + oClassInfo.name + "} Reference to this
in order to allow method chaining");
+ lines.push("@returns {" + oClassInfo.name +
+ "} Reference to this
in order to allow method chaining");
}
lines.push(
"@protected",
@@ -1687,7 +1705,6 @@ function createAutoDoc(oClassInfo, classComment, node, parser, filename, comment
);
newJSDoc(lines);
}
-
}
function createDataTypeAutoDoc(oTypeInfo, classComment, node, parser, filename) {
@@ -1695,11 +1712,12 @@ function createDataTypeAutoDoc(oTypeInfo, classComment, node, parser, filename)
/**
* Creates a human readable location info for a given doclet.
- * @param doclet
- * @returns {String}
+ *
+ * @param {Object} doclet
+ * @returns {string}
*/
function location(doclet) {
- var filename = (doclet.meta && doclet.meta.filename) || "unknown";
+ const filename = (doclet.meta && doclet.meta.filename) || "unknown";
return " #" + ui5data(doclet).id + "@" + filename + (doclet.meta.lineno != null ? ":" + doclet.meta.lineno : "") + (doclet.synthetic ? "(synthetic)" : "");
}
@@ -1707,23 +1725,22 @@ function location(doclet) {
// --- comment related functions that depend on the JSdoc version (e.g. on the used parser)
-var isDocComment;
-var getLeadingCommentNode;
+let isDocComment;
+let getLeadingCommentNode;
-// JSDoc added the node type Syntax.File
with the same change that activated Babylon
+// JSDoc added the node type Syntax.File
with the same change that activated Babylon
// See https://github.com/jsdoc3/jsdoc/commit/ffec4a42291de6d68e6240f304b68d6abb82a869
-if ( Syntax.File === 'File' ) {
-
+if ( Syntax.File === "File" ) {
// JSDoc starting with version 3.5.0
isDocComment = function isDocCommentBabylon(comment) {
- return comment && comment.type === 'CommentBlock' && comment.value && comment.value.charAt(0) === '*';
- }
+ return comment && comment.type === "CommentBlock" && comment.value && comment.value.charAt(0) === "*";
+ };
getLeadingCommentNode = function getLeadingCommentNodeBabylon(node, longname) {
- var leadingComments = node.leadingComments;
+ let leadingComments = node.leadingComments;
if ( Array.isArray(leadingComments) ) {
- // in babylon, all comments are already attached to the node
+ // in babylon, all comments are already attached to the node
// and the last one is the closest one and should win
// non-block comments have to be filtered out
leadingComments = leadingComments.filter(isDocComment);
@@ -1731,19 +1748,19 @@ if ( Syntax.File === 'File' ) {
return leadingComments[leadingComments.length - 1];
}
}
- }
-
+ };
} else {
-
// JSDoc versions before 3.5.0
isDocComment = function isDoccommentEsprima(comment) {
- return comment && comment.type === 'Block';
+ return comment && comment.type === "Block";
};
getLeadingCommentNode = function getLeadingCommentNodeEsprima(node, longname) {
- var comment,
- leadingComments = node.leadingComments;
+ let comment;
+
+
+ let leadingComments = node.leadingComments;
// when espree is used, JSDOc attached the leading comment and the first one was picked
if (Array.isArray(leadingComments) && leadingComments.length && leadingComments[0].raw) {
@@ -1751,48 +1768,50 @@ if ( Syntax.File === 'File' ) {
}
// also check all comments attached to the Program node (if found) whether they refer to the same longname
- // TODO check why any matches here override the direct leading comment from above
+ // TODO check why any matches here override the direct leading comment from above
if ( longname && currentProgram && currentProgram.leadingComments && currentProgram.leadingComments.length ) {
leadingComments = currentProgram.leadingComments;
- var rLongname = new RegExp("@(name|alias|class|namespace)\\s+" + longname.replace(/\./g, '\\.'));
- for ( var i = 0; i < leadingComments.length; i++ ) {
- var raw = getRawComment(leadingComments[i]);
+ const rLongname = new RegExp("@(name|alias|class|namespace)\\s+" + longname.replace(/\./g, "\\."));
+ for ( let i = 0; i < leadingComments.length; i++ ) {
+ const raw = getRawComment(leadingComments[i]);
if ( /^\/\*\*[\s\S]*\*\/$/.test(raw) && rLongname.test(raw) ) {
comment = leadingComments[i];
- // console.log("\n\n**** alternative comment found for " + longname + " on program level\n\n", comment);
+ // console.log("\n\n**** alternative comment found for " + longname +
+ // " on program level\n\n", comment);
break;
}
}
}
return comment;
- }
+ };
}
-//--- comment related functions that are independent from the JSdoc version
+// --- comment related functions that are independent from the JSdoc version
function getLeadingComment(node) {
- var comment = getLeadingCommentNode(node);
+ const comment = getLeadingCommentNode(node);
return comment ? getRawComment(comment) : null;
}
function getLeadingDoclet(node, preprocess) {
- var comment = getLeadingComment(node)
+ let comment = getLeadingComment(node);
if ( comment && preprocess ) {
- comment = preprocessComment({comment:comment, lineno: node.loc.start.line });
+ comment = preprocessComment({comment: comment, lineno: node.loc.start.line});
}
return comment ? new Doclet(comment, {}) : null;
}
/**
- * Determines the raw comment string (source code form, including leading and trailing comment markers / *...* /) from a comment node.
+ * Determines the raw comment string (source code form, including leading and trailing comment markers / *...* /) from a comment node.
* Works for Esprima and Babylon based JSDoc versions.
- * @param commentNode
- * @returns
+ *
+ * @param {Object} commentNode
+ * @returns {string}
*/
function getRawComment(commentNode) {
- // in esprima, there's a 'raw' property, in babylon, the 'raw' string has to be reconstructed from the 'value' by adding the markers
- return commentNode ? commentNode.raw || '/*' + commentNode.value + '*/' : '';
+ // in esprima, there's a 'raw' property, in babylon, the 'raw' string has to be reconstructed from the 'value' by adding the markers
+ return commentNode ? commentNode.raw || "/*" + commentNode.value + "*/" : "";
}
function setRawComment(commentNode, newRawComment) {
@@ -1803,53 +1822,57 @@ function setRawComment(commentNode, newRawComment) {
}
/**
- * Removes the mandatory comment markers and the optional but common asterisks at the beginning of each JSDoc comment line.
+ * Removes the mandatory comment markers and the optional but common asterisks at the beginning of
+ * each JSDoc comment line.
*
* The result is easier to parse/analyze.
*
* Implementation is a 1:1 copy from JSDoc's lib/jsdoc/doclet.js (closure function, not directly reusable)
- *
+ *
* @param {string} docletSrc the source comment with or without block comment markers
* @returns {string} the unwrapped content of the JSDoc comment
- *
+ *
*/
function unwrap(docletSrc) {
- if (!docletSrc) { return ''; }
+ if (!docletSrc) {
+ return "";
+ }
// note: keep trailing whitespace for @examples
// extra opening/closing stars are ignored
// left margin is considered a star and a space
// use the /m flag on regex to avoid having to guess what this platform's newline is
docletSrc =
- docletSrc.replace(/^\/\*\*+/, '') // remove opening slash+stars
- .replace(/\**\*\/$/, "\\Z") // replace closing star slash with end-marker
- .replace(/^\s*(\* ?|\\Z)/gm, '') // remove left margin like: spaces+star or spaces+end-marker
- .replace(/\s*\\Z$/g, ''); // remove end-marker
+ docletSrc.replace(/^\/\*\*+/, "") // remove opening slash+stars
+ .replace(/\**\*\/$/, "\\Z") // replace closing star slash with end-marker
+ .replace(/^\s*(\* ?|\\Z)/gm, "") // remove left margin like: spaces+star or spaces+end-marker
+ .replace(/\s*\\Z$/g, ""); // remove end-marker
return docletSrc;
}
/**
* Inverse operation of unwrap.
- *
+ *
* The prefix for lines is fixed to be " * ", lines are separated with '\n', independent from the platform.
+ *
+ * @param {string|Array} lines
*/
function wrap(lines) {
if ( typeof lines === "string" ) {
lines = lines.split(/\r\n?|\n/);
}
- return "/**\n * " + lines.join('\n * ') + "\n */";
+ return "/**\n * " + lines.join("\n * ") + "\n */";
}
/**
* Preprocesses a JSDoc comment string to ensure some UI5 standards.
- *
- * @param {event} e Event for the new comment
+ *
+ * @param {event} e Event for the new comment
* @returns {event}
*/
function preprocessComment(e) {
-
- var src = e.comment;
+ let src = e.comment;
// add a default visibility
if ( !/@private|@public|@protected|@sap-restricted|@ui5-restricted/.test(src) ) {
@@ -1860,15 +1883,15 @@ function preprocessComment(e) {
}
if ( /@class/.test(src) && /@static/.test(src) ) {
- warning("combination of @class and @static is no longer supported with jsdoc3, converting it to @namespace and @classdesc: (line " + e.lineno + ")");
+ warning("combination of @class and @static is no longer supported with jsdoc3, converting it to @namespace " +
+ "and @classdesc: (line " + e.lineno + ")");
src = unwrap(src);
src = src.replace(/@class/, "@classdesc").replace(/@static/, "@namespace");
src = wrap(src);
- //console.log(src);
+ // console.log(src);
}
return src;
-
}
// ---- other functionality ---------------------------------------------------------------------------
@@ -1876,7 +1899,7 @@ function preprocessComment(e) {
// HACK: override cli.exit() to avoid that JSDoc3 exits the VM
if ( pluginConfig.noExit ) {
info("disabling exit() call");
- require( path.join(global.env.dirname, 'cli') ).exit = function(retval) {
+ require( path.join(global.env.dirname, "cli") ).exit = function(retval) {
info("cli.exit(): do nothing (ret val=" + retval + ")");
};
}
@@ -1885,19 +1908,20 @@ if ( pluginConfig.noExit ) {
// ---- exports ----------------------------------------------------------------------------------------
exports.defineTags = function(dictionary) {
-
/**
* a special value that is not 'falsy' but results in an empty string when output
* Used for the disclaimer and experimental tag
*/
- var EMPTY = {
- toString: function() { return ""; }
+ const EMPTY = {
+ toString: function() {
+ return "";
+ }
};
/**
* A sapui5 specific tag to add a disclaimer to a symbol
*/
- dictionary.defineTag('disclaimer', {
+ dictionary.defineTag("disclaimer", {
// value is optional
onTagged: function(doclet, tag) {
doclet.disclaimer = tag.value || EMPTY;
@@ -1907,7 +1931,7 @@ exports.defineTags = function(dictionary) {
/**
* A sapui5 specific tag to mark a symbol as experimental.
*/
- dictionary.defineTag('experimental', {
+ dictionary.defineTag("experimental", {
// value is optional
onTagged: function(doclet, tag) {
doclet.experimental = tag.value || EMPTY;
@@ -1915,9 +1939,10 @@ exports.defineTags = function(dictionary) {
});
/**
- * Re-introduce the deprecated 'final tag. JSDoc used it as a synonym for readonly, but we use it to mark classes as final
+ * Re-introduce the deprecated 'final tag. JSDoc used it as a synonym for readonly,
+ * but we use it to mark classes as final
*/
- dictionary.defineTag('final', {
+ dictionary.defineTag("final", {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.final_ = true;
@@ -1929,11 +1954,11 @@ exports.defineTags = function(dictionary) {
* 'interface' is like 'class', but without a constructor.
* Support for 'interface' might not be complete (only standard UI5 use cases tested)
*/
- dictionary.defineTag('interface', {
- //mustNotHaveValue: true,
+ dictionary.defineTag("interface", {
+ // mustNotHaveValue: true,
onTagged: function(doclet, tag) {
// debug("setting kind of " + doclet.name + " to 'interface'");
- doclet.kind = 'interface';
+ doclet.kind = "interface";
if ( tag.value ) {
doclet.classdesc = tag.value;
}
@@ -1943,7 +1968,7 @@ exports.defineTags = function(dictionary) {
/**
* Classes can declare that they implement a set of interfaces
*/
- dictionary.defineTag('implements', {
+ dictionary.defineTag("implements", {
mustHaveValue: true,
onTagged: function(doclet, tag) {
// console.log("setting implements of " + doclet.name + " to 'interface'");
@@ -1959,25 +1984,25 @@ exports.defineTags = function(dictionary) {
});
/**
- * Set the visibility of a doclet to 'restricted'.
+ * Set the visibility of a doclet to 'restricted'.
*/
- dictionary.defineTag('ui5-restricted', {
+ dictionary.defineTag("ui5-restricted", {
onTagged: function(doclet, tag) {
- doclet.access = 'restricted';
+ doclet.access = "restricted";
if ( tag.value ) {
ui5data(doclet).stakeholders = tag.value.trim().split(/(?:\s*,\s*|\s+)/);
}
}
});
- dictionary.defineSynonym('ui5-restricted', 'sap-restricted');
+ dictionary.defineSynonym("ui5-restricted", "sap-restricted");
/**
* Mark a doclet as synthetic.
- *
+ *
* Used for doclets that the autodoc generation creates. This helps the template
* later to recognize such doclets and maybe filter them out.
*/
- dictionary.defineTag('synthetic', {
+ dictionary.defineTag("synthetic", {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.synthetic = true;
@@ -1987,7 +2012,7 @@ exports.defineTags = function(dictionary) {
/**
* Mark a doclet that intentionally updates a previous doclet
*/
- dictionary.defineTag('ui5-updated-doclet', {
+ dictionary.defineTag("ui5-updated-doclet", {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
ui5data(doclet).updatedDoclet = true;
@@ -1995,25 +2020,26 @@ exports.defineTags = function(dictionary) {
});
/**
- * The @hideconstructor tag tells JSDoc that the generated documentation should not display the constructor for a class.
+ * The @hideconstructor tag tells JSDoc that the generated documentation should not display
+ * the constructor for a class.
* Note: this tag will be natively available in JSDoc >= 3.5.0
*/
- dictionary.defineTag('hideconstructor', {
+ dictionary.defineTag("hideconstructor", {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.hideconstructor = true;
}
});
-
};
exports.handlers = {
/**
* Before all files are parsed, determine the common path prefix of all filenames
+ *
+ * @param {Any} e
*/
- parseBegin : function(e) {
-
+ parseBegin: function(e) {
pathPrefixes = env.opts._.reduce(function(result, fileOrDir) {
fileOrDir = path.resolve( path.normalize(fileOrDir) );
if ( fs.statSync(fileOrDir).isDirectory() ) {
@@ -2030,7 +2056,7 @@ exports.handlers = {
}
resourceNamePrefixes.forEach(ensureEndingSlash);
while ( resourceNamePrefixes.length < pathPrefixes.length ) {
- resourceNamePrefixes.push('');
+ resourceNamePrefixes.push("");
}
debug("path prefixes " + JSON.stringify(pathPrefixes));
@@ -2039,8 +2065,10 @@ exports.handlers = {
/**
* Log each file before it is parsed
+ *
+ * @param {Any} e
*/
- fileBegin: function (e) {
+ fileBegin: function(e) {
currentProgram = undefined;
currentModule = {
name: null,
@@ -2051,7 +2079,7 @@ exports.handlers = {
debug(currentModule);
},
- fileComplete: function (e) {
+ fileComplete: function(e) {
currentSource = undefined;
currentProgram = undefined;
currentModule = undefined;
@@ -2067,15 +2095,15 @@ exports.handlers = {
},
newDoclet: function(e) {
-
- var _ui5data = ui5data(e.doclet);
+ const _ui5data = ui5data(e.doclet);
// remove code: this is a try to reduce the required heap size
if ( e.doclet.meta ) {
if ( e.doclet.meta.code ) {
e.doclet.meta.code = {};
}
- var filepath = (e.doclet.meta.path && e.doclet.meta.path !== 'null' ) ? path.join(e.doclet.meta.path, e.doclet.meta.filename) : e.doclet.meta.filename;
+ const filepath = (e.doclet.meta.path && e.doclet.meta.path !== "null" ) ?
+ path.join(e.doclet.meta.path, e.doclet.meta.filename) : e.doclet.meta.filename;
e.doclet.meta.__shortpath = getRelativePath(filepath);
_ui5data.resource = currentModule.resource;
_ui5data.module = currentModule.name || currentModule.module;
@@ -2087,7 +2115,8 @@ exports.handlers = {
if ( !e.doclet.longname ) {
if ( e.doclet.memberof ) {
e.doclet.longname = e.doclet.memberof + "." + e.doclet.name; // TODO '.' depends on scope?
- warning("found doclet without longname, derived longname: " + e.doclet.longname + " " + location(e.doclet));
+ warning("found doclet without longname, derived longname: " +
+ e.doclet.longname + " " + location(e.doclet));
} else {
error("found doclet without longname, could not derive longname " + location(e.doclet));
}
@@ -2097,36 +2126,34 @@ exports.handlers = {
// try to detect misused memberof
if ( e.doclet.memberof && e.doclet.longname.indexOf(e.doclet.memberof) !== 0 ) {
warning("potentially unsupported use of @name and @memberof " + location(e.doclet));
- //console.log(e.doclet);
+ // console.log(e.doclet);
}
if ( e.doclet.returns
- && e.doclet.returns.length > 0
- && e.doclet.returns[0]
- && e.doclet.returns[0].type
- && e.doclet.returns[0].type.names
- && e.doclet.returns[0].type.names[0] === 'this'
- && e.doclet.memberof ) {
+ && e.doclet.returns.length > 0
+ && e.doclet.returns[0]
+ && e.doclet.returns[0].type
+ && e.doclet.returns[0].type.names
+ && e.doclet.returns[0].type.names[0] === "this"
+ && e.doclet.memberof ) {
warning("fixing return type 'this' with " + e.doclet.memberof);
e.doclet.returns[0].type.names[0] = e.doclet.memberof;
}
},
- beforeParse : function(e) {
+ beforeParse: function(e) {
msgHeader("parsing " + getRelativePath(e.filename));
currentSource = e.source;
},
- parseComplete : function(e) {
-
- var doclets = e.doclets;
- var l = doclets.length,i,j,doclet;
- //var noprivate = !env.opts.private;
- var rAnonymous = /^new
) or as a normal function.
@@ -169,38 +172,42 @@ var Version = (function() {
*
* The parts of the version number (major, minor, patch, suffix) can be provided in several ways:
*
- *
*
* To keep the code size small, this implementation mainly validates the single string variant.
* All other variants are only validated to some degree. It is the responsibility of the caller to
* provide proper parts.
*
- * @param {int|string|any[]|jQuery.sap.Version} vMajor the major part of the version (int) or any of the single parameter variants explained above.
+ * @param {int|string|any[]|jQuery.sap.Version} vMajor the major part of the version (int) or any of the
+ * single parameter variants explained above.
* @param {int} iMinor the minor part of the version number
* @param {int} iPatch the patch part of the version number
* @param {string} sSuffix the suffix part of the version number
- * @return {jQuery.sap.Version} the version object as determined from the parameters
+ * @returns {jQuery.sap.Version} the version object as determined from the parameters
*
* @class Represents a version consisting of major, minor, patch version and suffix, e.g. '1.2.7-SNAPSHOT'.
*
* @author SAP SE
* @version ${version}
- * @constructor
+ * @class
* @public
* @since 1.15.0
* @name jQuery.sap.Version
*/
function Version(versionStr) {
-
- var match = rVersion.exec(versionStr) || [];
+ const match = rVersion.exec(versionStr) || [];
function norm(v) {
- v = parseInt(v,10);
+ v = parseInt(v, 10);
return isNaN(v) ? 0 : v;
}
@@ -220,7 +227,6 @@ var Version = (function() {
enumerable: true,
value: String(match[3] || "")
});
-
}
Version.prototype.toMajorMinor = function() {
@@ -232,23 +238,21 @@ var Version = (function() {
};
Version.prototype.compareTo = function(other) {
- return this.major - other.major ||
+ return this.major - other.major ||
this.minor - other.minor ||
this.patch - other.patch ||
((this.suffix < other.suffix) ? -1 : (this.suffix === other.suffix) ? 0 : 1);
};
return Version;
-
}());
// ---- Link class --------------------------------------------------------------------------------------------------------------------------------------------------------------
-//TODO move to separate module
-
-var Link = (function() {
+// TODO move to separate module
- var Link = function() {
+const Link = (function() {
+ const Link = function() {
};
Link.prototype.toSymbol = function(longname) {
@@ -256,7 +260,7 @@ var Link = (function() {
longname = String(longname);
if ( /#constructor$/.test(longname) ) {
if ( !this.innerName ) {
- this.innerName = 'constructor';
+ this.innerName = "constructor";
}
longname = longname.slice(0, -"#constructor".length);
}
@@ -281,19 +285,20 @@ var Link = (function() {
};
function _makeLink(href, target, tooltip, text) {
- return '' + text + '';
+ return "" + text + "";
}
Link.prototype.toString = function() {
- var longname = this.longname,
- linkString;
+ let longname = this.longname;
- if (longname) {
+ let linkString;
+
+ if (longname) {
if ( /^(?:(?:ftp|https?):\/\/|\.\.?\/)/.test(longname) ) {
// handle real hyperlinks (TODO should be handled with a different "to" method
linkString = _makeLink(longname, this.targetName, this.tooltip, this.text || longname);
@@ -304,7 +309,6 @@ var Link = (function() {
} else {
linkString = this._makeSymbolLink(longname);
}
-
} else if (this.file) {
linkString = _makeLink(Link.base + this.file, this.targetName, null, this.text || this.file);
}
@@ -312,53 +316,47 @@ var Link = (function() {
return linkString;
};
- var missingTypes = {};
+ const missingTypes = {};
Link.getMissingTypes = function() {
return Object.keys(missingTypes);
};
-
+
Link.prototype._makeSymbolLink = function(longname) {
-
// normalize .prototype. and #
- longname = longname.replace(/\.prototype\./g, '#');
+ longname = longname.replace(/\.prototype\./g, "#");
// if it is an internal reference, then don't validate against symbols, just create a link
- if ( longname.charAt(0) == "#" ) {
-
- return _makeLink(longname + (this.innerName ? "#" + this.innerName : ""), this.targetName, this.tooltip, this.text || longname.slice(1));
-
+ if ( longname.charAt(0) == "#" ) {
+ return _makeLink(longname + (this.innerName ? "#" + this.innerName : ""), this.targetName, this.tooltip,
+ this.text || longname.slice(1));
}
- var linkTo = lookup(longname);
- // if there is no symbol by that name just return the name unaltered
- if ( !linkTo ) {
-
+ const linkTo = lookup(longname);
+ // if there is no symbol by that name just return the name unaltered
+ if ( !linkTo ) {
missingTypes[longname] = true;
-
- return this.text || longname;
+ return this.text || longname;
}
-
- // it's a full symbol reference (potentially to another file)
- var mainSymbol, anchor;
- if ( (linkTo.kind === 'member' && !linkTo.isEnum) || linkTo.kind === 'constant' || linkTo.kind === 'function' || linkTo.kind === 'event' ) { // it's a method or property
+ // it's a full symbol reference (potentially to another file)
+ let mainSymbol; let anchor;
+ if ( (linkTo.kind === "member" && !linkTo.isEnum) || linkTo.kind === "constant" || linkTo.kind === "function" ||
+ linkTo.kind === "event" ) { // it's a method or property
mainSymbol = linkTo.memberof;
- anchor = ( linkTo.kind === 'event' ? "event:" : "") + Link.symbolNameToLinkName(linkTo);
-
+ anchor = ( linkTo.kind === "event" ? "event:" : "") + Link.symbolNameToLinkName(linkTo);
} else {
-
mainSymbol = linkTo.longname;
anchor = this.innerName;
-
}
- return _makeLink(Link.baseSymbols + __uniqueFilenames[mainSymbol] + conf.ext + (anchor ? "#" + anchor : ""), this.targetName, this.tooltip, this.text || longname);
- }
+ return _makeLink(Link.baseSymbols + __uniqueFilenames[mainSymbol] + conf.ext + (anchor ? "#" + anchor : ""),
+ this.targetName, this.tooltip, this.text || longname);
+ };
Link.symbolNameToLinkName = function(symbol) {
- var linker = "";
- if ( symbol.scope === 'static' ) {
+ let linker = "";
+ if ( symbol.scope === "static" ) {
linker = ".";
} else if (symbol.isInner) {
linker = "-"; // TODO-migrate?
@@ -367,26 +365,24 @@ var Link = (function() {
};
return Link;
-
}());
-
// ---- publish() - main entry point for JSDoc templates -------------------------------------------------------------------------------------------------------
-/** Called automatically by JsDoc Toolkit. */
+/* Called automatically by JsDoc Toolkit. */
function publish(symbolSet) {
-
info("entering sapui5 template");
// create output dir
fs.mkPath(env.opts.destination);
-// if ( symbolSet().count() < 20000 ) {
-// info("writing raw symbols to " + path.join(env.opts.destination, "symbols-unpruned-ui5.json"));
-// fs.writeFileSync(path.join(env.opts.destination, "symbols-unpruned-ui5.json"), JSON.stringify(symbolSet().get(), filter, "\t"), 'utf8');
-// }
-
+ // if ( symbolSet().count() < 20000 ) {
+ // info("writing raw symbols to " + path.join(env.opts.destination, "symbols-unpruned-ui5.json"));
+ // fs.writeFileSync(path.join(env.opts.destination, "symbols-unpruned-ui5.json"),
+ // JSON.stringify(symbolSet().get(), filter, "\t"), 'utf8');
+ // }
+
info("before prune: " + symbolSet().count() + " symbols.");
symbolSet = helper.prune(symbolSet);
info("after prune: " + symbolSet().count() + " symbols.");
@@ -401,35 +397,41 @@ function publish(symbolSet) {
info("loading external apis from folder '" + templateConf.apiJsonFolder + "'");
loadExternalSymbols(templateConf.apiJsonFolder);
}
-
- var templatePath = path.join(env.opts.template, 'tmpl/');
+
+ const templatePath = path.join(env.opts.template, "tmpl/");
info("using templates from '" + templatePath + "'");
view = new template.Template(templatePath);
- function filter(key,value) {
- if ( key === 'meta' ) {
- //return;
+ function filter(key, value) {
+ if ( key === "meta" ) {
+ // return;
}
- if ( key === '__ui5' && value ) {
- var v = {
+ if ( key === "__ui5" && value ) {
+ const v = {
resource: value.resource,
module: value.module,
stakeholders: value.stakeholders
};
if ( value.derived ) {
- v.derived = value.derived.map(function($) { return $.longname });
+ v.derived = value.derived.map(function($) {
+ return $.longname;
+ });
}
if ( value.base ) {
v.base = value.base.longname;
}
if ( value.implementations ) {
- v.base = value.implementations.map(function($) { return $.longname });
+ v.base = value.implementations.map(function($) {
+ return $.longname;
+ });
}
if ( value.parent ) {
v.parent = value.parent.longname;
}
if ( value.children ) {
- v.children = value.children.map(function($) { return $.longname });
+ v.children = value.children.map(function($) {
+ return $.longname;
+ });
}
return v;
}
@@ -437,60 +439,61 @@ function publish(symbolSet) {
}
// now resolve relationships
- var aRootNamespaces = createNamespaceTree();
- var hierarchyRoots = createInheritanceTree();
+ const aRootNamespaces = createNamespaceTree();
+ const hierarchyRoots = createInheritanceTree();
collectMembers();
mergeEventDocumentation();
if ( symbolSet().count() < 20000 ) {
info("writing raw symbols to " + path.join(env.opts.destination, "symbols-pruned-ui5.json"));
- fs.writeFileSync(path.join(env.opts.destination, "symbols-pruned-ui5.json"), JSON.stringify(symbolSet().get(), filter, "\t"), 'utf8');
+ fs.writeFileSync(path.join(env.opts.destination, "symbols-pruned-ui5.json"), JSON.stringify(symbolSet().get(),
+ 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
- var symbols = symbolSet().get();
+ const symbols = symbolSet().get();
// -----
- var PUBLISHING_VARIANTS = {
+ const PUBLISHING_VARIANTS = {
- "apixml" : {
- defaults : {
+ "apixml": {
+ defaults: {
apiXmlFile: path.join(env.opts.destination, "jsapi.xml")
},
- processor : function(conf) {
+ processor: function(conf) {
createAPIXML(symbols, conf.apiXmlFile, {
legacyContent: true
});
}
},
- "apijson" : {
- defaults : {
+ "apijson": {
+ defaults: {
apiJsonFile: path.join(env.opts.destination, "api.json")
},
- processor : function(conf) {
+ processor: function(conf) {
createAPIJSON(symbols, conf.apiJsonFile);
}
},
- "fullapixml" : {
- defaults : {
+ "fullapixml": {
+ defaults: {
fullXmlFile: path.join(env.opts.destination, "fulljsapi.xml")
},
- processor : function(conf) {
+ processor: function(conf) {
createAPIXML(symbols, conf.fullXmlFile, {
roots: aRootNamespaces,
- omitDefaults : conf.omitDefaultsInFullXml,
+ omitDefaults: conf.omitDefaultsInFullXml,
resolveInheritance: true
});
}
},
- "apijs" : {
+ "apijs": {
defaults: {
jsapiFile: path.join(env.opts.destination, "api.js")
},
@@ -499,8 +502,8 @@ function publish(symbolSet) {
}
},
- "full" : {
- defaults : {
+ "full": {
+ defaults: {
outdir: path.join(env.opts.destination, "full/"),
contentOnly: false,
hierarchyIndex: true
@@ -510,10 +513,12 @@ function publish(symbolSet) {
}
},
- "public" : {
+ "public": {
defaults: {
outdir: path.join(env.opts.destination, "public/"),
- filter: function($) { return $.access === 'public' || $.access === 'protected' || $.access == null; },
+ filter: function($) {
+ return $.access === "public" || $.access === "protected" || $.access == null;
+ },
contentOnly: false,
hierarchyIndex: true
},
@@ -522,10 +527,12 @@ function publish(symbolSet) {
}
},
- "demokit" : {
+ "demokit": {
defaults: {
outdir: path.join(env.opts.destination, "demokit/"),
- filter: function($) { return $.access === 'public' || $.access === 'protected' || $.access == null; },
+ filter: function($) {
+ return $.access === "public" || $.access === "protected" || $.access == null;
+ },
contentOnly: true,
modulePages: true,
hierarchyIndex: false,
@@ -541,10 +548,11 @@ function publish(symbolSet) {
}
},
- "demokit-internal" : {
+ "demokit-internal": {
defaults: {
outdir: path.join(env.opts.destination, "demokit-internal/"),
- // filter: function($) { return $.access === 'public' || $.access === 'protected' || $.access === 'restricted' || $.access == null; },
+ // filter: function($) { return $.access === 'public' || $.access === 'protected' || $.access ===
+ // 'restricted' || $.access == null; },
contentOnly: true,
modulePages: true,
hierarchyIndex: false,
@@ -562,20 +570,18 @@ function publish(symbolSet) {
};
- var now = new Date();
+ const now = new Date();
info("start publishing");
- for (var i = 0; i < templateConf.variants.length; i++) {
-
- var vVariant = templateConf.variants[i];
+ for (let i = 0; i < templateConf.variants.length; i++) {
+ let vVariant = templateConf.variants[i];
if ( typeof vVariant === "string" ) {
- vVariant = { variant : vVariant };
+ vVariant = {variant: vVariant};
}
info("");
if ( PUBLISHING_VARIANTS[vVariant.variant] ) {
-
// Merge different sources of configuration (listed in increasing priority order - last one wins)
// and expose the result in the global 'conf' variable
// - global defaults
@@ -586,13 +592,16 @@ function publish(symbolSet) {
// Note: trailing slash expected for dirs
conf = merge({
ext: ".html",
- filter: function($) { return true; },
+ filter: function($) {
+ return true;
+ },
templatesDir: "/templates/sapui5/",
symbolsDir: "symbols/",
modulesDir: "modules/",
topicUrlPattern: "../../guide/{{topic}}.html",
srcDir: "symbols/src/",
- creationDate : now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDay() + " " + now.getHours() + ":" + now.getMinutes(),
+ creationDate: now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDay() + " " +
+ now.getHours() + ":" + now.getMinutes(),
outdir: env.opts.destination
}, PUBLISHING_VARIANTS[vVariant.variant].defaults, templateConf, vVariant);
@@ -603,15 +612,12 @@ function publish(symbolSet) {
PUBLISHING_VARIANTS[vVariant.variant].processor(conf);
info("done with variant " + vVariant.variant);
-
} else {
-
info("cannot publish unknown variant '" + vVariant.variant + "' (ignored)");
-
}
}
- var builtinSymbols = templateConf.builtinSymbols;
+ const builtinSymbols = templateConf.builtinSymbols;
if ( builtinSymbols ) {
Link.getMissingTypes().filter(function($) {
return builtinSymbols.indexOf($) < 0;
@@ -620,28 +626,26 @@ function publish(symbolSet) {
});
}
info("publishing done.");
-
}
-//---- namespace tree --------------------------------------------------------------------------------
+// ---- namespace tree --------------------------------------------------------------------------------
/**
* Completes the tree of namespaces. Namespaces for which content is available
* but which have not been documented are created as dummy without documentation.
*/
function createNamespaceTree() {
-
info("create namespace tree (" + __db().count() + " symbols)");
- var aRootNamespaces = [];
- var aTypes = __db(function() { return isaClass(this); }).get();
-
- for (var i = 0; i < aTypes.length; i++) { // loop with a for-loop as it can handle concurrent modifications
+ const aRootNamespaces = [];
+ const aTypes = __db(function() {
+ return isaClass(this);
+ }).get();
- var symbol = aTypes[i];
+ for (let i = 0; i < aTypes.length; i++) { // loop with a for-loop as it can handle concurrent modifications
+ const symbol = aTypes[i];
if ( symbol.memberof ) {
-
- var parent = lookup(symbol.memberof);
+ let parent = lookup(symbol.memberof);
if ( !parent ) {
warning("create missing namespace '" + symbol.memberof + "' (referenced by " + symbol.longname + ")");
parent = makeNamespace(symbol.memberof);
@@ -652,11 +656,8 @@ function createNamespaceTree() {
symbol.__ui5.parent = parent;
parent.__ui5.children = parent.__ui5.children || [];
parent.__ui5.children.push(symbol);
-
} else if ( symbol.longname !== ANONYMOUS_LONGNAME ) {
-
aRootNamespaces.push(symbol);
-
}
}
@@ -664,23 +665,22 @@ function createNamespaceTree() {
}
function makeNamespace(memberof) {
-
info("adding synthetic namespace symbol " + memberof);
- var comment = [
+ const comment = [
"@name " + memberof,
"@namespace",
"@synthetic",
"@public"
];
- var symbol = new doclet.Doclet("/**\n * " + comment.join("\n * ") + "\n */", {});
+ const symbol = new doclet.Doclet("/**\n * " + comment.join("\n * ") + "\n */", {});
symbol.__ui5 = {};
return symbol;
}
-//---- inheritance hierarchy ----------------------------------------------------------------------------
+// ---- inheritance hierarchy ----------------------------------------------------------------------------
/**
* Calculates the inheritance hierarchy for all class/interface/namespace symbols.
@@ -695,10 +695,9 @@ function makeNamespace(memberof) {
*
*/
function createInheritanceTree() {
-
function makeDoclet(longname, lines) {
lines.push("@name " + longname);
- var newDoclet = new doclet.Doclet("/**\n * " + lines.join("\n * ") + "\n */", {});
+ const newDoclet = new doclet.Doclet("/**\n * " + lines.join("\n * ") + "\n */", {});
newDoclet.__ui5 = {};
__longnames[longname] = newDoclet;
__db.insert(newDoclet);
@@ -707,10 +706,12 @@ function createInheritanceTree() {
info("create inheritance tree (" + __db().count() + " symbols)");
- var oTypes = __db(function() { return isaClass(this); });
- var aRootTypes = [];
+ const oTypes = __db(function() {
+ return isaClass(this);
+ });
+ const aRootTypes = [];
- var oObject = lookup("Object");
+ let oObject = lookup("Object");
if ( !oObject ) {
oObject = makeDoclet("Object", [
"@class",
@@ -719,16 +720,16 @@ function createInheritanceTree() {
]);
aRootTypes.push(oObject);
}
-
+
function getOrCreateClass(sClass, sExtendingClass) {
- var oClass = lookup(sClass);
+ let oClass = lookup(sClass);
if ( !oClass ) {
warning("create missing class " + sClass + " (extended by " + sExtendingClass + ")");
- var sBaseClass = 'Object';
+ let sBaseClass = "Object";
if ( externalSymbols[sClass] ) {
- sBaseClass = externalSymbols[sClass].extends || sBaseClass;
+ sBaseClass = externalSymbols[sClass].extends || sBaseClass;
}
- var oBaseClass = getOrCreateClass(sBaseClass, sClass);
+ const oBaseClass = getOrCreateClass(sBaseClass, sClass);
oClass = makeDoclet(sClass, [
"@extends " + sBaseClass,
"@class",
@@ -744,12 +745,11 @@ function createInheritanceTree() {
// link them according to the inheritance infos
oTypes.each(function(oClass) {
-
- if ( oClass.longname === 'Object') {
+ if ( oClass.longname === "Object") {
return;
}
- var sBaseClass = "Object";
+ let sBaseClass = "Object";
if ( oClass.augments && oClass.augments.length > 0 ) {
if ( oClass.augments.length > 1 ) {
warning("multiple inheritance detected in " + oClass.longname);
@@ -759,14 +759,14 @@ function createInheritanceTree() {
aRootTypes.push(oClass);
}
- var oBaseClass = getOrCreateClass(sBaseClass, oClass.longname);
+ const oBaseClass = getOrCreateClass(sBaseClass, oClass.longname);
oClass.__ui5.base = oBaseClass;
oBaseClass.__ui5.derived = oBaseClass.__ui5.derived || [];
oBaseClass.__ui5.derived.push(oClass);
if ( oClass.implements ) {
- for (var j = 0; j < oClass.implements.length; j++) {
- var oInterface = lookup(oClass.implements[j]);
+ for (let j = 0; j < oClass.implements.length; j++) {
+ let oInterface = lookup(oClass.implements[j]);
if ( !oInterface ) {
warning("create missing interface " + oClass.implements[j]);
oInterface = makeDoclet(oClass.implements[j], [
@@ -790,9 +790,9 @@ function createInheritanceTree() {
return;
}
oSymbol.__ui5.stereotype = sStereotype;
- var derived = oSymbol.__ui5.derived;
+ const derived = oSymbol.__ui5.derived;
if ( derived ) {
- for (var i = 0; i < derived.length; i++ ) {
+ for (let i = 0; i < derived.length; i++ ) {
if ( !derived[i].__ui5.stereotype ) {
setStereotype(derived[i], sStereotype);
}
@@ -808,7 +808,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(function(oStartClass) {
- var visited = {};
+ const visited = {};
function visit(oClass) {
if ( visited[oClass.longname] ) {
throw new Error("cyclic inheritance detected: " + JSON.stringify(Object.keys(visited)));
@@ -834,7 +834,7 @@ function createInheritanceTree() {
function collectMembers() {
__db().each(function($) {
if ( $.memberof ) {
- var parent = lookup($.memberof);
+ const parent = lookup($.memberof);
if ( parent && isaClass(parent) ) {
parent.__ui5.members = parent.__ui5.members || [];
parent.__ui5.members.push($);
@@ -844,40 +844,39 @@ function collectMembers() {
}
function mergeEventDocumentation() {
-
console.log("merging JSDoc event documentation into UI5 metadata");
- var oTypes = __db(function() { return isaClass(this); });
+ const oTypes = __db(function() {
+ return isaClass(this);
+ });
oTypes.each(function(symbol) {
+ const metadata = symbol.__ui5.metadata;
+ const members = symbol.__ui5.members;
- var metadata = symbol.__ui5.metadata;
- var members = symbol.__ui5.members;
-
- if ( !metadata || !metadata.events || Object.keys(metadata.events).length <= 0 || !members ) {
+ if ( !metadata || !metadata.events || Object.keys(metadata.events).length <= 0 || !members ) {
return;
}
// console.log('mergeing events for ' + symbol.longname);
members.forEach(function($) {
- if ( $.kind === 'event' && !$.inherited
- && ($.access === 'public' || $.access === 'protected' || $.access == null)
- && metadata.events[$.name]
- && Array.isArray($.params)
- && !$.synthetic ) {
-
- var event = metadata.events[$.name];
- var modified = false;
- //console.log("<<<<<<<");
- //console.log(event);
- //console.log("=======");
- //console.log($);
+ if ( $.kind === "event" && !$.inherited
+ && ($.access === "public" || $.access === "protected" || $.access == null)
+ && metadata.events[$.name]
+ && Array.isArray($.params)
+ && !$.synthetic ) {
+ const event = metadata.events[$.name];
+ let modified = false;
+ // console.log("<<<<<<<");
+ // console.log(event);
+ // console.log("=======");
+ // console.log($);
$.params.forEach(function(param) {
- var m = /^\w+\.getParameters\.(.*)$/.exec(param.name);
+ const m = /^\w+\.getParameters\.(.*)$/.exec(param.name);
if ( m ) {
- var pname = m[1];
- var ui5param = event.parameters[pname] || ( event.parameters[pname] = {});
+ const pname = m[1];
+ const ui5param = event.parameters[pname] || ( event.parameters[pname] = {});
if ( ui5param.type == null ) {
ui5param.type = listTypes(param.type);
modified = true;
@@ -893,37 +892,37 @@ function mergeEventDocumentation() {
console.log(" merged documentation for managed event " + symbol.longname + "#" + $.name);
}
- //console.log("=======");
- //console.log(JSON.stringify(event, null, '\t'));
- //console.log(">>>>>>>");
+ // console.log("=======");
+ // console.log(JSON.stringify(event, null, '\t'));
+ // console.log(">>>>>>>");
}
});
-
});
-
}
// ---- publishing -----------------------------------------------------------------------
function publishClasses(symbols, aRootNamespaces, hierarchyRoots) {
-
// create output dir
fs.mkPath(path.join(conf.outdir, conf.symbolsDir));
// get a list of all the classes in the symbolset
- var classes = symbols(function() {
+ let classes = symbols(function() {
return isaClass(this) && conf.filter(this);
}).order("longname");
// create unique file names
__uniqueFilenames = {};
- var filenames = {};
+ let filenames = {};
classes.get().sort(sortByAlias).forEach(function(symbol) {
- var filename = escape(symbol.longname);
- if ( filenames.hasOwnProperty(filename.toUpperCase()) && (filenames[filename.toUpperCase()].longname !== symbol.longname) ) {
+ let filename = escape(symbol.longname);
+ if ( filenames.hasOwnProperty(filename.toUpperCase()) &&
+ (filenames[filename.toUpperCase()].longname !== symbol.longname) ) {
// find an unused filename by appending "-n" where n is an integer > 0
- for (var j = 1; filenames.hasOwnProperty(filename.toUpperCase() + "-" + j); j++);
- warning("duplicate symbol names " + filenames[filename.toUpperCase()].longname + " and " + symbol.longname + ", renaming the latter to " + filename + "-" + j);
+ let j;
+ for (j = 1; filenames.hasOwnProperty(filename.toUpperCase() + "-" + j); j++);
+ warning("duplicate symbol names " + filenames[filename.toUpperCase()].longname + " and " +
+ symbol.longname + ", renaming the latter to " + filename + "-" + j);
filename = filename + "-" + j;
}
filenames[filename.toUpperCase()] = symbol;
@@ -932,21 +931,21 @@ function publishClasses(symbols, aRootNamespaces, hierarchyRoots) {
filenames = null;
// create a class index, displayed in the left-hand column of every class page
- var classTemplate;
+ let classTemplate;
if ( !conf.contentOnly ) {
info("create embedded class index");
Link.base = "../";
Link.baseSymbols = "";
- classTemplate = 'classWithIndex.html.tmpl';
+ classTemplate = "classWithIndex.html.tmpl";
publish.header = processTemplate("_header.tmpl", classes);
publish.footer = processTemplate("_footer.tmpl", classes);
publish.classesIndex = processTemplate("_navIndex.tmpl", classes); // kept in memory
} else {
- var newStyle = !!pluginConf.newStyle;
+ const newStyle = !!pluginConf.newStyle;
classTemplate = newStyle ? "class-new.html.tmpl" : "class.html.tmpl";
- publish.header = '';
- publish.footer = '';
- publish.classesIndex = '';
+ publish.header = "";
+ publish.footer = "";
+ publish.classesIndex = "";
// instead create an index as XML
Link.base = "";
@@ -959,7 +958,7 @@ function publishClasses(symbols, aRootNamespaces, hierarchyRoots) {
Link.base = "../";
Link.baseSymbols = "";
classes.each(function(symbol) {
- var sOutName = path.join(conf.symbolsDir, __uniqueFilenames[symbol.longname]) + conf.ext;
+ const sOutName = path.join(conf.symbolsDir, __uniqueFilenames[symbol.longname]) + conf.ext;
processTemplateAndSave(classTemplate, symbol, sOutName);
});
@@ -969,7 +968,7 @@ function publishClasses(symbols, aRootNamespaces, hierarchyRoots) {
Link.baseSymbols = "../" + conf.symbolsDir;
fs.mkPath(path.join(conf.outdir, conf.modulesDir));
groupByModule(classes.get()).forEach(function(module) {
- var sOutName = path.join(conf.modulesDir, module.name.replace(/\//g, '_')) + conf.ext;
+ const sOutName = path.join(conf.modulesDir, module.name.replace(/\//g, "_")) + conf.ext;
processTemplateAndSave("module.html.tmpl", module, sOutName);
});
}
@@ -997,10 +996,10 @@ function publishClasses(symbols, aRootNamespaces, hierarchyRoots) {
info("create API by version index");
Link.base = "";
Link.baseSymbols = conf.symbolsDir;
- var sinceSymbols = symbols(function() {
- var r = !!this.since && !this.inherited && conf.filter(this);
+ const sinceSymbols = symbols(function() {
+ let r = !!this.since && !this.inherited && conf.filter(this);
if ( r && this.memberof ) {
- var parent = lookup(this.memberof);
+ const parent = lookup(this.memberof);
// filter out symbol when parent is filtered out
if ( !parent || !conf.filter(parent) ) {
debug("since index: filtering out " + this.longname + ", member of " + this.memberof);
@@ -1019,7 +1018,7 @@ function publishClasses(symbols, aRootNamespaces, hierarchyRoots) {
info("create deprecated API index");
Link.base = "";
Link.baseSymbols = conf.symbolsDir;
- var deprecatedSymbols = symbols(function() {
+ const deprecatedSymbols = symbols(function() {
return !!this.deprecated && !this.inherited && conf.filter(this);
}).order("longname");
processTemplateAndSave("deprecation.html.tmpl", deprecatedSymbols, "deprecation" + conf.ext);
@@ -1029,7 +1028,7 @@ function publishClasses(symbols, aRootNamespaces, hierarchyRoots) {
info("create experimental API index");
Link.base = "";
Link.baseSymbols = conf.symbolsDir;
- var experimentalSymbols = symbols(function() {
+ const experimentalSymbols = symbols(function() {
return !!this.experimental && !this.inherited && conf.filter(this);
}).order("longname");
processTemplateAndSave("experimental.html.tmpl", experimentalSymbols, "experimental" + conf.ext);
@@ -1038,16 +1037,16 @@ function publishClasses(symbols, aRootNamespaces, hierarchyRoots) {
if ( conf.securityIndex ) {
info("create Security Relevant API index");
- var securityRelevantSymbols = {};
+ const securityRelevantSymbols = {};
A_SECURITY_TAGS.forEach(function(oTagDef) {
- securityRelevantSymbols[oTagDef.name.toLowerCase()] = { tag : oTagDef, symbols: [] };
+ securityRelevantSymbols[oTagDef.name.toLowerCase()] = {tag: oTagDef, symbols: []};
});
symbols().each(function($) {
- var tags = $.tags;
- if ( !$.inherited && conf.filter($) && tags ) {
- for (var i = 0; i < tags.length; i++) {
+ const tags = $.tags;
+ if ( !$.inherited && conf.filter($) && tags ) {
+ for (let i = 0; i < tags.length; i++) {
if ( rSecurityTags.test(tags[i].title) ) {
- securityRelevantSymbols[tags[i].title.toLowerCase()].symbols.push({ symbol: $, tag : tags[i]});
+ securityRelevantSymbols[tags[i].title.toLowerCase()].symbols.push({symbol: $, tag: tags[i]});
}
}
}
@@ -1063,11 +1062,11 @@ function publishClasses(symbols, aRootNamespaces, hierarchyRoots) {
// copy needed mimes
info("copy mimes");
// copy the template's static files to outdir
- var templatePath = env.opts.template;
- var fromDir = path.join(templatePath, 'static');
- var staticFiles = fs.ls(fromDir, 3);
+ const templatePath = env.opts.template;
+ const fromDir = path.join(templatePath, "static");
+ const staticFiles = fs.ls(fromDir, 3);
staticFiles.forEach(function(fileName) {
- var toDir = fs.toDir( fileName.replace(fromDir, conf.outdir) );
+ const toDir = fs.toDir( fileName.replace(fromDir, conf.outdir) );
fs.mkPath(toDir);
fs.copyFileSync(fileName, toDir);
});
@@ -1079,70 +1078,70 @@ function publishClasses(symbols, aRootNamespaces, hierarchyRoots) {
// ---- helper functions for the templates ----
-var rSinceVersion = /^([0-9]+(?:\.[0-9]+(?:\.[0-9]+)?)?([-.][0-9A-Z]+)?)(?:\s|$)/i;
+const rSinceVersion = /^([0-9]+(?:\.[0-9]+(?:\.[0-9]+)?)?([-.][0-9A-Z]+)?)(?:\s|$)/i;
function extractVersion(value) {
-
if ( !value ) {
return;
}
if ( value === true ) {
- value = '';
+ value = "";
} else {
value = String(value);
}
- var m = rSinceVersion.exec(value);
+ const m = rSinceVersion.exec(value);
return m ? m[1] : undefined;
-
}
-var rSince = /^(?:as\s+of|since)(?:\s+version)?\s*([0-9]+(?:\.[0-9]+(?:\.[0-9]+)?)?([-.][0-9A-Z]+)?)(?:\.$|\.\s+|[,:]\s*|\s-\s*|\s|$)/i;
+const rSince = /^(?:as\s+of|since)(?:\s+version)?\s*([0-9]+(?:\.[0-9]+(?:\.[0-9]+)?)?([-.][0-9A-Z]+)?)(?:\.$|\.\s+|[,:]\s*|\s-\s*|\s|$)/i;
function extractSince(value) {
-
if ( !value ) {
return;
}
if ( value === true ) {
- value = '';
+ value = "";
} else {
value = String(value);
}
- var m = rSince.exec(value);
+ const m = rSince.exec(value);
if ( m ) {
return {
- since : m[1],
- pos : m[0].length,
- value : value.slice(m[0].length).trim()
- }
+ since: m[1],
+ pos: m[0].length,
+ value: value.slice(m[0].length).trim()
+ };
}
return {
- pos : 0,
+ pos: 0,
value: value.trim()
};
-
}
function sortByAlias(a, b) {
- var partsA = a.longname.split(/[.#]/);
- var partsB = b.longname.split(/[.#]/);
- var i = 0;
+ const partsA = a.longname.split(/[.#]/);
+ const partsB = b.longname.split(/[.#]/);
+ let i = 0;
while ( i < partsA.length && i < partsB.length ) {
- if ( partsA[i].toLowerCase() < partsB[i].toLowerCase() )
+ if ( partsA[i].toLowerCase() < partsB[i].toLowerCase() ) {
return -1;
- if ( partsA[i].toLowerCase() > partsB[i].toLowerCase() )
+ }
+ if ( partsA[i].toLowerCase() > partsB[i].toLowerCase() ) {
return 1;
+ }
i++;
}
- if ( partsA.length < partsB.length )
+ if ( partsA.length < partsB.length ) {
return -1;
- if ( partsA.length > partsB.length )
+ }
+ if ( partsA.length > partsB.length ) {
return 1;
+ }
// as a last resort, try to compare the aliases case sensitive in case we have aliases that only
// differ in case like with "sap.ui.model.type" and "sap.ui.model.Type"
if ( a.longname < b.longname ) {
@@ -1163,50 +1162,58 @@ function isNonEmptyNamespace($) {
($.children && $.children.length > 0));
};*/
-/** Just the first sentence (up to a full stop). Should not break on dotted variable names. */
+/* Just the first sentence (up to a full stop). Should not break on dotted variable names. */
function summarize(desc) {
if ( desc != null ) {
- desc = String(desc).replace(/\s+/g, ' ').
- replace(/"'/g, '"').
- replace(/^(<\/?p>|
|\s)+/, '');
+ desc = String(desc).replace(/\s+/g, " ").
+ replace(/"'/g, """).
+ replace(/^(<\/?p>|
|\s)+/, "");
- var match = /([\w\W]+?\.)[^a-z0-9_$]/i.exec(desc);
+ const match = /([\w\W]+?\.)[^a-z0-9_$]/i.exec(desc);
return match ? match[1] : desc;
}
}
-/** Make a symbol sorter by some attribute. */
-function makeSortby(/* fields ...*/) {
- var aFields = Array.prototype.slice.apply(arguments),
- aNorms = [],
- aFuncs = [];
- for (var i = 0; i < arguments.length; i++) {
+/* Make a symbol sorter by some attribute. */
+function makeSortby(...aFields) {
+ const aNorms = [];
+
+ const aFuncs = [];
+ for (let i = 0; i < arguments.length; i++) {
aNorms[i] = 1;
- if ( typeof aFields[i] === 'function' ) {
+ if ( typeof aFields[i] === "function" ) {
aFuncs[i] = aFields[i];
continue;
}
- aFuncs[i] = function($,n) { return $[n]; };
+ aFuncs[i] = function($, n) {
+ return $[n];
+ };
if ( aFields[i].indexOf("!") === 0 ) {
aNorms[i] = -1;
aFields[i] = aFields[i].slice(1);
}
- if ( aFields[i] === 'deprecated' ) {
- aFuncs[i] = function($,n) { return !!$[n]; };
- } else if ( aFields[i] === 'static' ) {
- aFields[i] = 'scope';
- aFuncs[i] = function($,n) { return $[n] === 'static'; };
+ if ( aFields[i] === "deprecated" ) {
+ aFuncs[i] = function($, n) {
+ return !!$[n];
+ };
+ } else if ( aFields[i] === "static" ) {
+ aFields[i] = "scope";
+ aFuncs[i] = function($, n) {
+ return $[n] === "static";
+ };
} else if ( aFields[i].indexOf("#") === 0 ) {
aFields[i] = aFields[i].slice(1);
- aFuncs[i] = function($,n) { return $.comment.getTag(n).length > 0; };
+ aFuncs[i] = function($, n) {
+ return $.comment.getTag(n).length > 0;
+ };
}
}
return function(a, b) {
// info("compare " + a.longname + " : " + b.longname);
- var r = 0,i,va,vb;
+ let r = 0; let i; let va; let vb;
for (i = 0; r === 0 && i < aFields.length; i++) {
- va = aFuncs[i](a,aFields[i]);
- vb = aFuncs[i](b,aFields[i]);
+ va = aFuncs[i](a, aFields[i]);
+ vb = aFuncs[i](b, aFields[i]);
if ( va && !vb ) {
r = -aNorms[i];
} else if ( !va && vb ) {
@@ -1220,19 +1227,19 @@ function makeSortby(/* fields ...*/) {
// debug(" " + aFields[i] + ": " + va + " ? " + vb + " = " + r);
}
return r;
- }
+ };
}
/** Pull in the contents of an external file at the given path. */
function processTemplateAndSave(sTemplateName, oData, sOutputName) {
- var sResult = processTemplate(sTemplateName, oData);
+ let sResult = processTemplate(sTemplateName, oData);
if ( conf.normalizeWhitespace && /\.html$/.test(sOutputName) ) {
sResult = normalizeWhitespace(sResult);
}
- var sOutpath = path.join(conf.outdir, sOutputName);
+ const sOutpath = path.join(conf.outdir, sOutputName);
try {
- fs.writeFileSync(sOutpath, sResult, 'utf8');
+ fs.writeFileSync(sOutpath, sResult, "utf8");
} catch (e) {
error("failed to write generated file '" + sOutpath + "':" + (e.message || String(e)));
}
@@ -1240,40 +1247,40 @@ function processTemplateAndSave(sTemplateName, oData, sOutputName) {
function processTemplate(sTemplateName, data) {
debug("processing template '" + sTemplateName + "' for " + data.longname);
-
+ let result;
try {
- var result = view.render(sTemplateName, {
- asPlainSummary: asPlainSummary,
- bySimpleName: bySimpleName,
- childrenOfKind: childrenOfKind,
- conf: conf,
- data: data,
- getConstructorDescription : getConstructorDescription,
- getNSClass: getNSClass,
- groupByVersion: groupByVersion,
- extractSince: extractSince,
- include: processTemplate,
- Link: Link,
- listTypes: listTypes,
- linkTypes: linkTypes,
- makeExample: makeExample,
- makeLinkList: makeLinkList,
- makeLinkToSymbolFile: makeLinkToSymbolFile,
- makeSignature: makeSignature,
- makeSortby: makeSortby,
- publish : publish,
- formatText: formatText,
- simpleNameOf: simpleNameOf,
- sortByAlias: sortByAlias,
- summarize: summarize,
- Version : Version
- });
+ result = view.render(sTemplateName, {
+ asPlainSummary: asPlainSummary,
+ bySimpleName: bySimpleName,
+ childrenOfKind: childrenOfKind,
+ conf: conf,
+ data: data,
+ getConstructorDescription: getConstructorDescription,
+ getNSClass: getNSClass,
+ groupByVersion: groupByVersion,
+ extractSince: extractSince,
+ include: processTemplate,
+ Link: Link,
+ listTypes: listTypes,
+ linkTypes: linkTypes,
+ makeExample: makeExample,
+ makeLinkList: makeLinkList,
+ makeLinkToSymbolFile: makeLinkToSymbolFile,
+ makeSignature: makeSignature,
+ makeSortby: makeSortby,
+ publish: publish,
+ formatText: formatText,
+ simpleNameOf: simpleNameOf,
+ sortByAlias: sortByAlias,
+ summarize: summarize,
+ Version: Version
+ });
} catch (e) {
if ( e.source ) {
- var filename = path.join(env.opts.destination, sTemplateName + ".js");
+ const filename = path.join(env.opts.destination, sTemplateName + ".js");
console.log("**** failed to process template, source written to " + filename);
fs.mkPath(path.dirname(filename));
- fs.writeFileSync(filename, e.source, 'utf8');
+ fs.writeFileSync(filename, e.source, "utf8");
}
console.log("error while processing " + sTemplateName);
throw e;
@@ -1283,24 +1290,25 @@ function processTemplate(sTemplateName, data) {
}
function groupByVersion(symbols, extractVersion) {
-
- var map = {};
+ const map = {};
symbols.forEach(function(symbol) {
+ const version = extractVersion(symbol);
+
- var version = extractVersion(symbol),
- key = String(version);
+ const key = String(version);
if ( !map[key] ) {
- map[key] = { version: version, symbols : [] };
+ map[key] = {version: version, symbols: []};
}
map[key].symbols.push(symbol);
-
});
- var groups = Object.keys(map).map(function(key) { return map[key]; });
+ const groups = Object.keys(map).map(function(key) {
+ return map[key];
+ });
- return groups.sort(function(a,b) {
+ return groups.sort(function(a, b) {
if ( !a.version && b.version ) {
return -1;
} else if ( a.version && !b.version ) {
@@ -1313,12 +1321,11 @@ function groupByVersion(symbols, extractVersion) {
}
function groupByModule(symbols) {
-
- var map = {};
+ const map = {};
function add(key, symbol) {
if ( !map[key] ) {
- map[key] = { name: key, symbols : [] };
+ map[key] = {name: key, symbols: []};
}
if ( map[key].symbols.indexOf(symbol) < 0 ) {
map[key].symbols.push(symbol);
@@ -1326,8 +1333,7 @@ function groupByModule(symbols) {
}
symbols.forEach(function(symbol) {
-
- var key = symbol.__ui5.module;
+ const key = symbol.__ui5.module;
if ( key ) {
add(key, symbol);
@@ -1339,16 +1345,17 @@ function groupByModule(symbols) {
});
}
}
-
});
- var groups = Object.keys(map).map(function(key) { return map[key]; });
+ const groups = Object.keys(map).map(function(key) {
+ return map[key];
+ });
return groups;
}
-var REGEXP_TAG = /<(\/?(?:[A-Z][A-Z0-9_-]*:)?[A-Z][A-Z0-9_-]*)(?:\s[^>]*)?>/gi;
+const REGEXP_TAG = /<(\/?(?:[A-Z][A-Z0-9_-]*:)?[A-Z][A-Z0-9_-]*)(?:\s[^>]*)?>/gi;
/**
* Removes unnecessary whitespace from an HTML document:
@@ -1357,13 +1364,18 @@ var REGEXP_TAG = /<(\/?(?:[A-Z][A-Z0-9_-]*:)?[A-Z][A-Z0-9_-]*)(?:\s[^>]*)?>/gi;
* - inside a tag, whitespace is preserved
*
* Whitespace inside an element tag is not touched (although it could be normalized as well)
+ *
* @param {string} content raw HTML file
* @returns {string} HTML file with normalized whitespace
*/
function normalizeWhitespace(content) {
- var compressed = '',
- preformatted = 0,
- p = 0, m, text;
+ let compressed = "";
+
+
+ let preformatted = 0;
+
+
+ let p = 0; let m; let text;
REGEXP_TAG.lastIndex = 0;
while ( m = REGEXP_TAG.exec(content) ) {
@@ -1373,7 +1385,7 @@ function normalizeWhitespace(content) {
compressed += text;
// console.log(' "' + text + '" (preformatted)');
} else {
- text = text.replace(/\s+/g,' ');
+ text = text.replace(/\s+/g, " ");
if ( text.trim() ) {
compressed += text;
}
@@ -1390,7 +1402,6 @@ function normalizeWhitespace(content) {
} else if ( /^\/pre$/i.test(m[1]) && preformatted ) {
preformatted--;
}
-
}
if ( content.length > p ) {
@@ -1399,7 +1410,7 @@ function normalizeWhitespace(content) {
compressed += text;
// console.log(' "' + text + '" (preformatted)');
} else {
- text = text.replace(/\s+/g,' ');
+ text = text.replace(/\s+/g, " ");
if ( text.trim() ) {
compressed += text;
}
@@ -1416,16 +1427,16 @@ function makeLinkToSymbolFile(longname) {
function simpleNameOf(longname) {
longname = String(longname);
- var p = longname.lastIndexOf('.');
+ const p = longname.lastIndexOf(".");
return p < 0 ? longname : longname.slice(p + 1);
}
-function bySimpleName(a,b) {
+function bySimpleName(a, b) {
if ( a === b ) {
return 0;
}
- var simpleA = simpleNameOf(a);
- var simpleB = simpleNameOf(b);
+ const simpleA = simpleNameOf(a);
+ const simpleB = simpleNameOf(b);
if ( simpleA === simpleB ) {
return a < b ? -1 : 1;
} else {
@@ -1433,41 +1444,43 @@ function bySimpleName(a,b) {
}
}
-/** Build output for displaying function parameters. */
+/* Build output for displaying function parameters. */
function makeSignature(params) {
- var r = ['('], desc;
+ const r = ["("]; let desc;
if ( params ) {
- for (var i = 0, p; p = params[i]; i++) {
+ for (let i = 0, p; p = params[i]; i++) {
// ignore @param tags for 'virtual' params that are used to document members of config-like params
// (e.g. like "@param param1.key ...")
- if (p.name && p.name.indexOf('.') == -1) {
- if (i > 0)
- r.push(', ');
+ if (p.name && p.name.indexOf(".") == -1) {
+ if (i > 0) {
+ r.push(", ");
+ }
- r.push('');
+ r.push(">");
r.push(p.name);
- r.push('');
- if ( p.optional )
- r.push('?');
+ r.push("
block -------] [----------------------- some flow content -----------------------] [---- an inline {@link ...} tag ----] [---------- an empty line ---------] */
-var rFormatText = /(
]*)?>)|(<\/pre>)|(<(?:h[\d+]|ul|ol|table)(?:\s[^>]*)?>)|(<\/(?:h[\d+]|ul|ol|table)>)|\{@link\s+([^}\s]+)(?:\s+([^\}]*))?\}|((?:\r\n|\r|\n)[ \t]*(?:\r\n|\r|\n))/gi;
+const rFormatText = /(
]*)?>)|(<\/pre>)|(<(?:h[\d+]|ul|ol|table)(?:\s[^>]*)?>)|(<\/(?:h[\d+]|ul|ol|table)>)|\{@link\s+([^}\s]+)(?:\s+([^\}]*))?\}|((?:\r\n|\r|\n)[ \t]*(?:\r\n|\r|\n))/gi;
function formatText(text) {
-
if ( !text ) {
- return '';
+ return "";
}
- var inpre = false,
- paragraphs = 0;
-
- text = String(text).replace(rFormatText, function(match, pre, endpre, flow, endflow, linkTarget, linkText, emptyline) {
- if ( pre ) {
- inpre = true;
- return pre.replace(/
/gi, "
").replace(/
/gi, "
");
- } else if ( endpre ) {
- inpre = false;
- } else if ( flow ) {
- if ( !inpre ) {
- paragraphs++;
- return '
'; - } - } else if ( emptyline ) { - if ( !inpre ) { - paragraphs++; - return '
'; - } - } else if ( linkTarget ) { - if ( !inpre ) { - // convert to a hyperlink - var link = new Link().toSymbol(linkTarget); - // if link tag contained a replacement text, use it - if ( linkText && linkText.trim()) { - link = link.withText(linkText.trim()); + let inpre = false; + + + let paragraphs = 0; + + text = String(text).replace(rFormatText, + function(match, pre, endpre, flow, endflow, linkTarget, linkText, emptyline) { + if ( pre ) { + inpre = true; + return pre.replace(/
/gi, "").replace(//gi, + ""); + } else if ( endpre ) { + inpre = false; + } else if ( flow ) { + if ( !inpre ) { + paragraphs++; + return "" + match; + } + } else if ( endflow ) { + if ( !inpre ) { + paragraphs++; + return match + ""; + } + } else if ( emptyline ) { + if ( !inpre ) { + paragraphs++; + return "
"; + } + } else if ( linkTarget ) { + if ( !inpre ) { + // convert to a hyperlink + let link = new Link().toSymbol(linkTarget); + // if link tag contained a replacement text, use it + if ( linkText && linkText.trim()) { + link = link.withText(linkText.trim()); + } + return link.toString(); } - return link.toString(); } - } - return match; - }); + return match; + }); if ( paragraphs > 0 ) { - text = '
' + text + '
'; + text = "" + text + "
"; } // remove empty paragraphs - text = text.replace(/\s*<\/p>/g, ''); + text = text.replace(/
\s*<\/p>/g, ""); return text; } -//console.log("#### samples"); -//console.log(formatText(summarize("This is a first\n\nparagraph with empty \n \n \nlines in it. This is the remainder."))); +// console.log("#### samples"); +// console.log(formatText( +// summarize("This is a first\n\nparagraph with empty \n \n \nlines in it. This is the remainder."))); function childrenOfKind(data, kind) { /* old version based on TaffyDB (slow) - var oChildren = symbolSet({kind: kind, memberof: data.longname === GLOBAL_LONGNAME ? {isUndefined: true} : data.longname}).filter(function() { return conf.filter(this); }); + var oChildren = symbolSet({ + kind: kind, + memberof: data.longname === GLOBAL_LONGNAME ? {isUndefined: true} : data.longname}).filter(function() { + return conf.filter(this); + }); return { own : oChildren.filter({inherited: {isUndefined:true}}).get().sort(makeSortby("!deprecated","static","name")), borrowed : groupByContributors(data, oChildren.filter({inherited: true}).get().sort(makeSortby("name"))) } */ - var oResult = { + const oResult = { own: [], borrowed: [] }; - //console.log("calculating kind " + kind + " from " + data.longname); - //console.log(data); - var fnFilter; + // console.log("calculating kind " + kind + " from " + data.longname); + // console.log(data); + let fnFilter; switch (kind) { - case 'property': + case "property": fnFilter = function($) { - return $.kind === 'constant' || ($.kind === 'member' && !$.isEnum); - } + return $.kind === "constant" || ($.kind === "member" && !$.isEnum); + }; break; - case 'event': + case "event": fnFilter = function($) { - return $.kind === 'event'; - } + return $.kind === "event"; + }; break; - case 'method': + case "method": fnFilter = function($) { - return $.kind === 'function'; - } + return $.kind === "function"; + }; break; default: // default: none - fnFilter = function($) { return false; }; + fnFilter = function($) { + return false; + }; break; } if ( data.__ui5.members ) { data.__ui5.members.forEach(function($) { if ( fnFilter($) && conf.filter($) ) { - oResult[$.inherited ? 'borrowed' : 'own'].push($); + oResult[$.inherited ? "borrowed" : "own"].push($); } }); } - oResult.own.sort(makeSortby("!deprecated","static","name")); + oResult.own.sort(makeSortby("!deprecated", "static", "name")); oResult.borrowed = groupByContributors(data, oResult.borrowed); return oResult; @@ -1600,21 +1623,26 @@ function childrenOfKind(data, kind) { * Any contributors that can not be found in the hierarchy are appended * to the set. * - * @param symbol of which these are the members - * @param borrowedMembers set of borrowed members to determine the contributors for - * @return sorted array of contributors + * @param {Any} symbol of which these are the members + * @param {Array} aBorrowedMembers set of borrowed members to determine the contributors for + * @returns {Array} sorted array of contributors */ function groupByContributors(symbol, aBorrowedMembers) { + const MAX_ORDER = 1000; + // a sufficiently large number + + const mContributors = {}; + + + const aSortedContributors = []; - var MAX_ORDER = 1000, // a sufficiently large number - mContributors = {}, - aSortedContributors = [], - i,order; + + let i; let order; aBorrowedMembers.forEach(function($) { $ = lookup($.inherits); if ($ && mContributors[$.memberof] == null) { - mContributors[$.memberof] = { order : MAX_ORDER, items : [$] }; + mContributors[$.memberof] = {order: MAX_ORDER, items: [$]}; } else { mContributors[$.memberof].items.push($); } @@ -1623,12 +1651,13 @@ function groupByContributors(symbol, aBorrowedMembers) { // order contributors according to their distance in the inheritance hierarchy order = 0; (function handleAugments(oSymbol) { - var i,oTarget,aParentsToVisit; + let i; let oTarget; let aParentsToVisit; if ( oSymbol.augments ) { aParentsToVisit = []; // first assign an order for (i = 0; i < oSymbol.augments.length; i++) { - if ( mContributors[oSymbol.augments[i]] != null && mContributors[oSymbol.augments[i]].order === MAX_ORDER ) { + if ( mContributors[oSymbol.augments[i]] != null && + mContributors[oSymbol.augments[i]].order === MAX_ORDER ) { mContributors[oSymbol.augments[i]].order = ++order; aParentsToVisit.push(oSymbol.augments[i]); } @@ -1645,169 +1674,185 @@ function groupByContributors(symbol, aBorrowedMembers) { // convert to an array and sort by order for (i in mContributors) { - aSortedContributors.push(mContributors[i]); + if (mContributors.hasOwnProperty(i)) { + aSortedContributors.push(mContributors[i]); + } } - aSortedContributors.sort(function (a,b) { return a.order - b.order; }); + aSortedContributors.sort(function(a, b) { + return a.order - b.order; + }); return aSortedContributors; - } function makeLinkList(aSymbols) { return aSymbols .sort(makeSortby("name")) - .map(function($) { return new Link().toSymbol($.longname).withText($.name); }) + .map(function($) { + return new Link().toSymbol($.longname).withText($.name); + }) .join(", "); } // ---- type parsing --------------------------------------------------------------------------------------------- function TypeParser(defaultBuilder) { - - /* TODO + /* TODO * - function(this:) // type of this * - function(new:) // constructor */ - var rLexer = /\s*(Array\.?<|Object\.?<|Set\.?<|Promise\.?<|function\(|\{|:|\(|\||\}|>|\)|,|\[\]|\*|\?|!|\.\.\.)|\s*(\w+(?:[.#~]\w+)*)|./g; + const rLexer = /\s*(Array\.?<|Object\.?<|Set\.?<|Promise\.?<|function\(|\{|:|\(|\||\}|>|\)|,|\[\]|\*|\?|!|\.\.\.)|\s*(\w+(?:[.#~]\w+)*)|./g; + + let input; + + + let builder; - var input, - builder, - token, - tokenStr; + + let token; + + + let tokenStr; function next(expected) { if ( expected !== undefined && token !== expected ) { - throw new SyntaxError("TypeParser: expected '" + expected + "', but found '" + tokenStr + "' (pos: " + rLexer.lastIndex + ", input='" + input + "')"); + throw new SyntaxError("TypeParser: expected '" + expected + "', but found '" + tokenStr + "' (pos: " + + rLexer.lastIndex + ", input='" + input + "')"); } - var match = rLexer.exec(input); + const match = rLexer.exec(input); if ( match ) { - tokenStr = match[1] || match[2]; - token = match[1] || (match[2] && 'symbol'); + tokenStr = match[1] || match[2]; + token = match[1] || (match[2] && "symbol"); if ( !token ) { - throw new SyntaxError("TypeParser: unexpected '" + tokenStr + "' (pos: " + match.index + ", input='" + input + "')"); + throw new SyntaxError("TypeParser: unexpected '" + tokenStr + "' (pos: " + match.index + ", input='" + + input + "')"); } } else { tokenStr = token = null; } } - + function parseType() { - var nullable = false; - var mandatory = false; - if ( token === '?' ) { + let nullable = false; + let mandatory = false; + if ( token === "?" ) { next(); nullable = true; - } else if ( token === '!' ) { + } else if ( token === "!" ) { next(); mandatory = true; } - var type; - - if ( token === 'Array.<' || token === 'Array<' ) { + let type; + + if ( token === "Array.<" || token === "Array<" ) { next(); - var componentType = parseType(); - next('>'); + const componentType = parseType(); + next(">"); type = builder.array(componentType); - } else if ( token === 'Object.<' || token === 'Object<' ) { + } else if ( token === "Object.<" || token === "Object<" ) { next(); - var keyType; - var valueType = parseType(); - if ( token === ',' ) { + let keyType; + let valueType = parseType(); + if ( token === "," ) { next(); keyType = valueType; valueType = parseType(); } else { - keyType = builder.synthetic(builder.simpleType('string')); + keyType = builder.synthetic(builder.simpleType("string")); } - next('>'); + next(">"); type = builder.object(keyType, valueType); - } else if ( token === 'Set.<' || token === 'Set<' ) { + } else if ( token === "Set.<" || token === "Set<" ) { next(); - var elementType = parseType(); - next('>'); + const elementType = parseType(); + next(">"); type = builder.set(elementType); - } else if ( token === 'Promise.<' || token === 'Promise<' ) { + } else if ( token === "Promise.<" || token === "Promise<" ) { next(); - var elementType = parseType(); - next('>'); + const elementType = parseType(); + next(">"); type = builder.promise(elementType); - } else if ( token === 'function(' ) { + } else if ( token === "function(" ) { next(); - var thisType, constructorType, paramTypes = [], returnType; - if ( tokenStr === 'this' ) { + let thisType; let constructorType; const paramTypes = []; let returnType; + if ( tokenStr === "this" ) { next(); - next(':'); + next(":"); thisType = parseType(); - if ( token === ',' ) { + if ( token === "," ) { next(); } - } else if ( tokenStr === 'new' ) { + } else if ( tokenStr === "new" ) { next(); - next(':'); + next(":"); constructorType = parseType(); - if ( token === ',' ) { + if ( token === "," ) { next(); } } - while ( token === 'symbol' || token === '...' ) { - var repeatable = token === '...'; + while ( token === "symbol" || token === "..." ) { + const repeatable = token === "..."; if ( repeatable) { - next(); + next(); } - var paramType = parseType(); + let paramType = parseType(); if ( repeatable ) { paramType = builder.repeatable(paramType); } paramTypes.push(paramType); - if ( token === ',' ) { + if ( token === "," ) { if ( repeatable ) { - throw new SyntaxError("TypeParser: only the last parameter of a function can be repeatable (pos: " + rLexer.lastIndex + ", input='" + input + "')"); + throw new SyntaxError( + "TypeParser: only the last parameter of a function can be repeatable (pos: " + + rLexer.lastIndex + ", input='" + input + "')"); } next(); } } - next(')'); - if ( token === ':' ) { - next(':'); + next(")"); + if ( token === ":" ) { + next(":"); returnType = parseType(); } type = builder.function(paramTypes, returnType, thisType, constructorType); - } else if ( token === '{' ) { - var structure = Object.create(null); - var propName,propType; + } else if ( token === "{" ) { + const structure = Object.create(null); + let propName; let propType; next(); do { propName = tokenStr; if ( !/^\w+$/.test(propName) ) { - throw new SyntaxError("TypeParser: structure field must have a simple name (pos: " + rLexer.lastIndex + ", input='" + input + "', field:'" + propName + "')"); + throw new SyntaxError( + "TypeParser: structure field must have a simple name (pos: " + rLexer.lastIndex + + ", input='" + input + "', field:'" + propName + "')"); } - next('symbol'); - if ( token === ':' ) { + next("symbol"); + if ( token === ":" ) { next(); propType = parseType(); } else { - propType = builder.synthetic(builder.simpleType('any')); + propType = builder.synthetic(builder.simpleType("any")); } structure[propName] = propType; - if ( token === '}' ) { + if ( token === "}" ) { break; } - next(','); + next(","); } while (token); - next('}'); + next("}"); type = builder.structure(structure); - } else if ( token === '(' ) { + } else if ( token === "(" ) { next(); type = parseTypes(); - next(')'); - } else if ( token === '*' ) { + next(")"); + } else if ( token === "*" ) { next(); - type = builder.simpleType('*'); + type = builder.simpleType("*"); } else { type = builder.simpleType(tokenStr); - next('symbol'); - while ( token === '[]' ) { + next("symbol"); + while ( token === "[]" ) { next(); type = builder.array(type); } @@ -1822,10 +1867,10 @@ function TypeParser(defaultBuilder) { } function parseTypes() { - var types = []; + const types = []; do { types.push(parseType()); - if ( token !== '|' ) { + if ( token !== "|" ) { break; } next(); @@ -1834,52 +1879,51 @@ function TypeParser(defaultBuilder) { } this.parse = function(typeStr, tempBuilder) { - builder = tempBuilder || defaultBuilder || TypeParser.ASTBuilder; + builder = tempBuilder || defaultBuilder || TypeParser.ASTBuilder; input = String(typeStr); rLexer.lastIndex = 0; next(); - var type = parseTypes(); + const type = parseTypes(); next(null); return type; - } - -} + }; +} TypeParser.ASTBuilder = { simpleType: function(type) { return { - type: 'simpleType', + type: "simpleType", name: type }; }, array: function(componentType) { return { - type: 'array', + type: "array", component: componentType }; }, object: function(keyType, valueType) { return { - type: 'object', + type: "object", key: keyType, value: valueType }; }, set: function(elementType) { return { - type: 'set', + type: "set", element: elementType }; }, promise: function(fulfillmentType) { return { - type: 'promise', + type: "promise", fulfill: fulfillmentType }; }, function: function(paramTypes, returnType, thisType, constructorType) { return { - type: 'function', + type: "function", params: paramTypes, return: returnType, this: thisType, @@ -1888,13 +1932,13 @@ TypeParser.ASTBuilder = { }, structure: function(structure) { return { - type: 'structure', + type: "structure", fields: structure }; }, union: function(types) { return { - type: 'union', + type: "union", types: types }; }, @@ -1926,13 +1970,13 @@ TypeParser.LinkBuilder.prototype = { return type.needsParenthesis ? "(" + type.str + ")" : type.str; }, simpleType: function(type) { - if ( this.linkStyle === 'text' ) { + if ( this.linkStyle === "text" ) { return { str: type }; } - var link = new Link().toSymbol(type); - if ( this.linkStyle === 'short' ) { + const link = new Link().toSymbol(type); + if ( this.linkStyle === "short" ) { link.withText(simpleNameOf(type)).withTooltip(type); } return { @@ -1961,22 +2005,24 @@ TypeParser.LinkBuilder.prototype = { }, set: function(elementType) { return { - str: 'Set.' + this.lt + elementType.str + this.gt + str: "Set." + this.lt + elementType.str + this.gt }; }, promise: function(fulfillmentType) { return { - str: 'Promise.' + this.lt + fulfillmentType.str + this.gt + str: "Promise." + this.lt + fulfillmentType.str + this.gt }; }, function: function(paramTypes, returnType) { return { - str: "function(" + paramTypes.map(function(type) { return type.str; }).join(',') + ")" + ( returnType ? " : " + this.safe(returnType) : "") + str: "function(" + paramTypes.map(function(type) { + return type.str; + }).join(",") + ")" + ( returnType ? " : " + this.safe(returnType) : "") }; }, structure: function(structure) { - var r = []; - for ( var fieldName in structure ) { + const r = []; + for ( const fieldName in structure ) { if ( structure[fieldName].synthetic ) { r.push(fieldName); } else { @@ -1990,7 +2036,7 @@ TypeParser.LinkBuilder.prototype = { union: function(types) { return { needsParenthesis: true, - str: types.map( this.safe.bind(this) ).join('|') + str: types.map( this.safe.bind(this) ).join("|") }; }, synthetic: function(type) { @@ -2011,11 +2057,11 @@ TypeParser.LinkBuilder.prototype = { } }; -var typeParser = new TypeParser(); -var _SHORT_BUILDER = new TypeParser.LinkBuilder('short', true); -var _LONG_BUILDER = new TypeParser.LinkBuilder('long', true); -var _TEXT_BUILDER = new TypeParser.LinkBuilder('text', false); -var _TEXT_BUILDER_ENCODED = new TypeParser.LinkBuilder('text', true); +const typeParser = new TypeParser(); +const _SHORT_BUILDER = new TypeParser.LinkBuilder("short", true); +const _LONG_BUILDER = new TypeParser.LinkBuilder("long", true); +const _TEXT_BUILDER = new TypeParser.LinkBuilder("text", false); +const _TEXT_BUILDER_ENCODED = new TypeParser.LinkBuilder("text", true); /* function testTypeParser(type) { @@ -2037,12 +2083,12 @@ testTypeParser("{a:int,b,c:float,d,e}"); function _processTypeString(type, builder) { if ( type && Array.isArray(type.names) ) { - type = type.names.join('|'); + type = type.names.join("|"); } if ( type ) { try { return typeParser.parse( type, builder ).str; - } catch (e) { + } catch (e) { error("failed to parse type string '" + type + "': " + e); return type; } @@ -2060,21 +2106,23 @@ function linkTypes(type, short) { /** * Reduces the given text to a summary and removes all tags links etc. and escapes double quotes. * The result therefore should be suitable as content for an HTML tag attribute (e.g. title). - * @param sText - * @return summarized, plain attribute + * + * @param {string} sText + * @returns {string} summarized, plain attribute */ function asPlainSummary(sText) { - return sText ? summarize(sText).replace(/<.*?>/g, '').replace(/\{\@link\s*(.*?)\}/g, '$1').replace(/"/g,""") : ''; + return sText ? summarize(sText).replace(/<.*?>/g, "").replace(/\{\@link\s*(.*?)\}/g, "$1") + .replace(/"/g, """) : ""; } function getNSClass(item) { - if (item.kind === 'interface') { + if (item.kind === "interface") { return " interface"; - } else if (item.kind === 'namespace') { + } else if (item.kind === "namespace") { return " namespace"; - } else if (item.kind === 'typedef' ) { + } else if (item.kind === "typedef" ) { return " typedef"; - } else if (item.kind === 'member' && item.isEnum ) { + } else if (item.kind === "member" && item.isEnum ) { return " enum"; } else { return ""; @@ -2091,14 +2139,14 @@ function getNSClass(item) { * group 4: an isolated line feed + surrounding whitespace * * [-------
block -------] [---- an empty line and surrounding whitespace ----] [---- new line or whitespaces ----] */ -var rNormalizeText = /(]*)?>)|(<\/pre>)|([ \t]*(?:\r\n|\r|\n)[ \t]*(?:\r\n|\r|\n)[ \t\r\n]*)|([ \t]*(?:\r\n|\r|\n)[ \t]*|[ \t]+)/gi; +const rNormalizeText = /(]*)?>)|(<\/pre>)|([ \t]*(?:\r\n|\r|\n)[ \t]*(?:\r\n|\r|\n)[ \t\r\n]*)|([ \t]*(?:\r\n|\r|\n)[ \t]*|[ \t]+)/gi; function normalizeWS(text) { if ( text == null ) { return text; } - var inpre = false; + let inpre = false; return String(text).replace(rNormalizeText, function(match, pre, endpre, emptyline, ws) { if ( pre ) { inpre = true; @@ -2107,25 +2155,23 @@ function normalizeWS(text) { inpre = false; return endpre; } else if ( emptyline ) { - return inpre ? emptyline : '\n\n'; + return inpre ? emptyline : "\n\n"; } else if ( ws ) { - return inpre ? ws : ' '; + return inpre ? ws : " "; } return match; }); - } -//---- add on: API JSON ----------------------------------------------------------------- +// ---- add on: API JSON ----------------------------------------------------------------- function createAPIJSON(symbols, filename) { - - var api = { + const api = { "$schema-ref": "http://schemas.sap.com/sapui5/designtime/api.json/1.0" - } + }; if ( templateConf.version ) { - api.version = templateConf.version.replace(/-SNAPSHOT$/,""); + api.version = templateConf.version.replace(/-SNAPSHOT$/, ""); } if ( templateConf.uilib ) { api.library = templateConf.uilib; @@ -2134,7 +2180,8 @@ function createAPIJSON(symbols, filename) { api.symbols = []; // sort only a copy(!) of the symbols, otherwise the SymbolSet lookup is broken symbols.slice(0).sort(sortByAlias).forEach(function(symbol) { - if ( isaClass(symbol) && !symbol.synthetic ) { // dump a symbol if it as a class symbol and if it is not a synthetic symbol + if ( isaClass(symbol) && !symbol.synthetic ) { + // dump a symbol if it as a class symbol and if it is not a synthetic symbol api.symbols.push(createAPIJSON4Symbol(symbol, false)); } }); @@ -2142,22 +2189,21 @@ function createAPIJSON(symbols, filename) { postProcessAPIJSON(api); fs.mkPath(path.dirname(filename)); - fs.writeFileSync(filename, JSON.stringify(api), 'utf8'); + fs.writeFileSync(filename, JSON.stringify(api), "utf8"); info(" apiJson saved as " + filename); } function createAPIJSON4Symbol(symbol, omitDefaults) { - - var obj = []; - var curr = obj; - var attribForKind = 'kind'; - var stack = []; + const obj = []; + let curr = obj; + let attribForKind = "kind"; + const stack = []; function isEmpty(obj) { if ( !obj ) { return true; } - for (var n in obj) { + for (const n in obj) { if ( obj.hasOwnProperty(n) ) { return false; } @@ -2166,14 +2212,13 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { } function tag(name, value, omitEmpty) { - if ( omitEmpty && !value ) { return; } if ( arguments.length === 1 ) { // opening tag stack.push(curr); stack.push(attribForKind); - var obj = {}; + const obj = {}; if ( Array.isArray(curr) ) { if ( attribForKind != null ) { obj[attribForKind] = name; @@ -2194,7 +2239,7 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { } function attrib(name, value, defaultValue, raw) { - var emptyTag = arguments.length === 1; + const emptyTag = arguments.length === 1; if ( omitDefaults && arguments.length >= 3 && value === defaultValue ) { return; } @@ -2203,7 +2248,7 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { function closeTag(name, noIndent) { attribForKind = stack.pop(); - curr = stack.pop(); + curr = stack.pop(); } function collection(name, attribForKind) { @@ -2216,16 +2261,15 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { function endCollection(name) { attribForKind = stack.pop(); - curr = stack.pop(); + curr = stack.pop(); } function tagWithSince(name, value) { - if ( !value ) { return; } - var info = extractSince(value); + const info = extractSince(value); tag(name); if ( info.since ) { @@ -2235,11 +2279,10 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { curr["text"] = normalizeWS(info.value); } closeTag(name, true); - } function examples(symbol) { - var j, example; + let j; let example; if ( symbol.examples && symbol.examples.length ) { collection("examples"); @@ -2263,11 +2306,11 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { } function visibility($) { - if ( $.access === 'protected' ) { + if ( $.access === "protected" ) { return "protected"; - } else if ( $.access === 'restricted' ) { + } else if ( $.access === "restricted" ) { return "restricted"; - } else if ( $.access === 'private' ) { + } else if ( $.access === "private" ) { return "private"; } else { return "public"; @@ -2275,18 +2318,20 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { } function exceptions(symbol) { - var array = symbol.exceptions, - j, exception; - + let array = symbol.exceptions; + + + let j; let exception; + if ( Array.isArray(array) ) { - array = array.filter( function (ex) { + array = array.filter( function(ex) { return (ex.type && listTypes(ex.type)) || (ex.description && ex.description.trim()); }); - } - if ( array == null || array.length === 0 ) { + } + if ( array == null || array.length === 0 ) { return; } - + collection("throws"); for (j = 0; j < array.length; j++) { exception = array[j]; @@ -2301,7 +2346,9 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { } function methodList(tagname, methods) { - methods = methods && Object.keys(methods).map(function(key) { return methods[key]; }); + methods = methods && Object.keys(methods).map(function(key) { + return methods[key]; + }); if ( methods != null && methods.length > 0 ) { curr[tagname] = methods; } @@ -2314,23 +2361,22 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { } function hasSettings($, visited) { - visited = visited || {}; if ( $.augments && $.augments.length > 0 ) { - var baseSymbol = $.augments[0]; + let baseSymbol = $.augments[0]; if ( visited.hasOwnProperty(baseSymbol) ) { error("detected cyclic inheritance when looking at " + $.longname + ": " + JSON.stringify(visited)); return false; } visited[baseSymbol] = true; - baseSymbol = lookup(baseSymbol) ; + baseSymbol = lookup(baseSymbol); if ( hasSettings(baseSymbol, visited) ) { return true; } } - var metadata = $.__ui5.metadata; + const metadata = $.__ui5.metadata; return metadata && ( !isEmpty(metadata.specialSettings) @@ -2343,22 +2389,21 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { } function writeMetadata($) { - - var metadata = $.__ui5.metadata; + const metadata = $.__ui5.metadata; if ( !metadata ) { return; } - var n; + let n; if ( metadata.specialSettings && Object.keys(metadata.specialSettings).length > 0 ) { collection("specialSettings"); for ( n in metadata.specialSettings ) { - var special = metadata.specialSettings[n]; + const special = metadata.specialSettings[n]; tag("specialSetting"); attrib("name", special.name); attrib("type", special.type); - attrib("visibility", special.visibility, 'public'); + attrib("visibility", special.visibility, "public"); if ( special.since ) { attrib("since", extractVersion(special.since)); } @@ -2374,13 +2419,13 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { if ( metadata.properties && Object.keys(metadata.properties).length > 0 ) { collection("properties"); for ( n in metadata.properties ) { - var prop = metadata.properties[n]; + const prop = metadata.properties[n]; tag("property"); attrib("name", prop.name); - attrib("type", prop.type, 'string'); + attrib("type", prop.type, "string"); attrib("defaultValue", prop.defaultValue, null, /* raw = */true); - attrib("group", prop.group, 'Misc'); - attrib("visibility", prop.visibility, 'public'); + attrib("group", prop.group, "Misc"); + attrib("visibility", prop.visibility, "public"); if ( prop.since ) { attrib("since", extractVersion(prop.since)); } @@ -2407,16 +2452,16 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { if ( metadata.aggregations && Object.keys(metadata.aggregations).length > 0 ) { collection("aggregations"); for ( n in metadata.aggregations ) { - var aggr = metadata.aggregations[n]; + const aggr = metadata.aggregations[n]; tag("aggregation"); attrib("name", aggr.name); attrib("singularName", aggr.singularName); // TODO omit default? - attrib("type", aggr.type, 'sap.ui.core.Control'); + attrib("type", aggr.type, "sap.ui.core.Control"); if ( aggr.altTypes ) { curr.altTypes = aggr.altTypes.slice(); } - attrib("cardinality", aggr.cardinality, '0..n'); - attrib("visibility", aggr.visibility, 'public'); + attrib("cardinality", aggr.cardinality, "0..n"); + attrib("visibility", aggr.visibility, "public"); if ( aggr.since ) { attrib("since", extractVersion(aggr.since)); } @@ -2442,13 +2487,13 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { if ( metadata.associations && Object.keys(metadata.associations).length > 0 ) { collection("associations"); for ( n in metadata.associations ) { - var assoc = metadata.associations[n]; + const assoc = metadata.associations[n]; tag("association"); attrib("name", assoc.name); attrib("singularName", assoc.singularName); // TODO omit default? - attrib("type", assoc.type, 'sap.ui.core.Control'); - attrib("cardinality", assoc.cardinality, '0..1'); - attrib("visibility", assoc.visibility, 'public'); + attrib("type", assoc.type, "sap.ui.core.Control"); + attrib("cardinality", assoc.cardinality, "0..1"); + attrib("visibility", assoc.visibility, "public"); if ( assoc.since ) { attrib("since", extractVersion(assoc.since)); } @@ -2464,10 +2509,10 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { if ( metadata.events && Object.keys(metadata.events).length > 0 ) { collection("events"); for ( n in metadata.events ) { - var event = metadata.events[n]; + const event = metadata.events[n]; tag("event"); attrib("name", event.name); - attrib("visibility", event.visibility, 'public'); + attrib("visibility", event.visibility, "public"); if ( event.since ) { attrib("since", extractVersion(event.since)); } @@ -2476,9 +2521,9 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { tagWithSince("deprecated", event.deprecation); if ( event.parameters && Object.keys(event.parameters).length > 0 ) { tag("parameters"); - for ( var pn in event.parameters ) { + for ( const pn in event.parameters ) { if ( event.parameters.hasOwnProperty(pn) ) { - var param = event.parameters[pn]; + const param = event.parameters[pn]; tag(pn); attrib("name", pn); attrib("type", param.type); @@ -2502,7 +2547,7 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { if ( metadata.annotations && Object.keys(metadata.annotations).length > 0 ) { collection("annotations"); for ( n in metadata.annotations ) { - var anno = metadata.annotations[n]; + const anno = metadata.annotations[n]; tag("annotation"); attrib("name", anno.name); attrib("namespace", anno.namespace); @@ -2523,26 +2568,28 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { } endCollection("annotations"); } - + if ( metadata.designtime ) { // don't write falsy values tag("designtime", metadata.designtime); } - } function writeParameterProperties(paramName, params) { - var prefix = paramName + '.', - count = 0, - i; + const prefix = paramName + "."; - for ( i = 0; i < params.length; i++ ) { - var name = params[i].name; + let count = 0; + + + let i; + + for ( i = 0; i < params.length; i++ ) { + let name = params[i].name; if ( name.lastIndexOf(prefix, 0) !== 0 ) { // startsWith continue; } name = name.slice(prefix.length); - if ( name.indexOf('.') >= 0 ) { + if ( name.indexOf(".") >= 0 ) { continue; } @@ -2609,7 +2656,7 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { } */ - var kind = (symbol.kind === 'member' && symbol.isEnum) ? "enum" : symbol.kind; // handle pseudo-kind 'enum' + const kind = (symbol.kind === "member" && symbol.isEnum) ? "enum" : symbol.kind; // handle pseudo-kind 'enum' tag(kind); @@ -2620,7 +2667,7 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { } if ( symbol.__ui5.module ) { attrib("module", symbol.__ui5.module); - attrib("export", undefined, '', true); + attrib("export", undefined, "", true); } if ( symbol.virtual ) { attrib("abstract", true, false, /* raw = */true); @@ -2628,10 +2675,10 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { if ( symbol.final_ ) { attrib("final", true, false, /* raw = */true); } - if ( symbol.scope === 'static' ) { + if ( symbol.scope === "static" ) { attrib("static", true, false, /* raw = */true); } - attrib("visibility", visibility(symbol), 'public'); + attrib("visibility", visibility(symbol), "public"); if ( symbol.since ) { attrib("since", extractVersion(symbol.since)); } @@ -2639,19 +2686,19 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { tag("extends", symbol.augments.sort().join(",")); // TODO what about multiple inheritance? } interfaceList("implements", symbol.implements); - tag("description", normalizeWS(symbol.classdesc || (symbol.kind === 'class' ? '' : symbol.description)), true); + tag("description", normalizeWS(symbol.classdesc || (symbol.kind === "class" ? "" : symbol.description)), true); tagWithSince("experimental", symbol.experimental); tagWithSince("deprecated", symbol.deprecated); - if ( symbol.tags && symbol.tags.some(function(tag) { return tag.title === 'ui5-metamodel'; }) ) { - attrib('ui5-metamodel', true, false, /* raw = */true); + if ( symbol.tags && symbol.tags.some(function(tag) { + return tag.title === "ui5-metamodel"; + }) ) { + attrib("ui5-metamodel", true, false, /* raw = */true); } - var i, j, member, param; - - if ( kind === 'class' ) { + let i; let j; let member; let param; + if ( kind === "class" ) { if ( symbol.__ui5.stereotype || hasSettings(symbol) ) { - tag("ui5-metadata"); if ( symbol.__ui5.stereotype ) { @@ -2666,14 +2713,13 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { // IF @hideconstructor tag is present we omit the whole constructor if ( !symbol.hideconstructor ) { - tag("constructor"); attrib("visibility", visibility(symbol)); if (symbol.params && symbol.params.length > 0) { collection("parameters"); for (j = 0; j < symbol.params.length; j++) { param = symbol.params[j]; - if (param.name.indexOf('.') >= 0) { + if (param.name.indexOf(".") >= 0) { continue; } tag("parameter"); @@ -2703,9 +2749,8 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { referencesList(symbol); // TODO here or for class? // secTags(symbol); // TODO repeat from class? closeTag("constructor"); - } - } else if ( kind === 'namespace' ) { + } else if ( kind === "namespace" ) { if ( symbol.__ui5.stereotype || symbol.__ui5.metadata ) { tag("ui5-metadata"); @@ -2729,7 +2774,7 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { } } - var ownProperties = childrenOfKind(symbol, "property").own.sort(sortByAlias); + const ownProperties = childrenOfKind(symbol, "property").own.sort(sortByAlias); if ( ownProperties.length > 0 ) { collection("properties"); for ( i = 0; i < ownProperties.length; i++ ) { @@ -2738,10 +2783,10 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { attrib("name", member.name); if ( member.__ui5.module && member.__ui5.module !== symbol.__ui5.module ) { attrib("module", member.__ui5.module); - attrib("export", undefined, '', true); + attrib("export", undefined, "", true); } - attrib("visibility", visibility(member), 'public'); - if ( member.scope === 'static' ) { + attrib("visibility", visibility(member), "public"); + if ( member.scope === "static" ) { attrib("static", true, false, /* raw = */true); } if ( member.since ) { @@ -2761,7 +2806,7 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { endCollection("properties"); } - var ownEvents = childrenOfKind(symbol, 'event').own.sort(sortByAlias); + const ownEvents = childrenOfKind(symbol, "event").own.sort(sortByAlias); if ( ownEvents.length > 0 ) { collection("events"); for (i = 0; i < ownEvents.length; i++ ) { @@ -2770,10 +2815,10 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { attrib("name", member.name); if ( member.__ui5.module && member.__ui5.module !== symbol.__ui5.module ) { attrib("module", member.__ui5.module); - attrib("export", undefined, '', true); + attrib("export", undefined, "", true); } - attrib("visibility", visibility(member), 'public'); - if ( member.scope === 'static' ) { + attrib("visibility", visibility(member), "public"); + if ( member.scope === "static" ) { attrib("static", true, false, /* raw = */true); } if ( member.since ) { @@ -2784,7 +2829,7 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { collection("parameters"); for (j = 0; j < member.params.length; j++) { param = member.params[j]; - if ( param.name.indexOf('.') >= 0 ) { + if ( param.name.indexOf(".") >= 0 ) { continue; } @@ -2807,7 +2852,7 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { tagWithSince("experimental", member.experimental); examples(member); referencesList(member); - //secTags(member); + // secTags(member); if ( member.__ui5.resource && member.__ui5.resource !== symbol.__ui5.resource ) { attrib("resource", member.__ui5.resource); } @@ -2816,7 +2861,7 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { endCollection("events"); } - var ownMethods = childrenOfKind(symbol, 'method').own.sort(sortByAlias); + const ownMethods = childrenOfKind(symbol, "method").own.sort(sortByAlias); if ( ownMethods.length > 0 ) { collection("methods"); for ( i = 0; i < ownMethods.length; i++ ) { @@ -2825,25 +2870,27 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { attrib("name", member.name); if ( member.__ui5.module && member.__ui5.module !== symbol.__ui5.module ) { attrib("module", member.__ui5.module); - attrib("export", undefined, '', true); + attrib("export", undefined, "", true); } - attrib("visibility", visibility(member), 'public'); - if ( member.scope === 'static' ) { + attrib("visibility", visibility(member), "public"); + if ( member.scope === "static" ) { attrib("static", true, false, /* raw = */true); } - if ( member.tags && member.tags.some(function(tag) { return tag.title === 'ui5-metamodel'; }) ) { - attrib('ui5-metamodel', true, false, /* raw = */true); + if ( member.tags && member.tags.some(function(tag) { + return tag.title === "ui5-metamodel"; + }) ) { + attrib("ui5-metamodel", true, false, /* raw = */true); } - var returns = member.returns && member.returns.length && member.returns[0]; - var type = member.type || (returns && returns.type); + const returns = member.returns && member.returns.length && member.returns[0]; + let type = member.type || (returns && returns.type); type = listTypes(type); - //if ( type && type !== 'void' ) { + // if ( type && type !== 'void' ) { // attrib("type", type, 'void'); - //} - if ( type && type !== 'void' || returns && returns.description ) { + // } + if ( type && type !== "void" || returns && returns.description ) { tag("returnValue"); - if ( type && type !== 'void' ) { + if ( type && type !== "void" ) { attrib("type", type); } if ( returns && returns.description ) { @@ -2859,7 +2906,7 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { collection("parameters"); for ( j = 0; j < member.params.length; j++) { param = member.params[j]; - if ( param.name.indexOf('.') >= 0 ) { + if ( param.name.indexOf(".") >= 0 ) { continue; } tag("parameter"); @@ -2886,7 +2933,7 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { tagWithSince("deprecated", member.deprecated); examples(member); referencesList(member); - //secTags(member); + // secTags(member); if ( member.__ui5.resource && member.__ui5.resource !== symbol.__ui5.resource ) { attrib("resource", member.__ui5.resource); } @@ -2895,11 +2942,11 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { endCollection("methods"); } -// if ( roots && symbol.__ui5.children && symbol.__ui5.children.length ) { -// collection("children", "kind"); -// symbol.__ui5.children.forEach(writeSymbol); -// endCollection("children"); -// } + // if ( roots && symbol.__ui5.children && symbol.__ui5.children.length ) { + // collection("children", "kind"); + // symbol.__ui5.children.forEach(writeSymbol); + // endCollection("children"); + // } closeTag(kind); @@ -2907,15 +2954,15 @@ function createAPIJSON4Symbol(symbol, omitDefaults) { } function postProcessAPIJSON(api) { - var modules = {}; - var symbols = api.symbols; - var i,j,n,symbol,defaultExport; - - // collect modules and the symbols that refer to them + const modules = {}; + let symbols = api.symbols; + let i; let j; let n; let symbol; let defaultExport; + + // collect modules and the symbols that refer to them for ( i = 0; i < symbols.length; i++) { symbol = symbols[i]; if ( symbol.module ) { - modules[symbol.module] = modules[symbol.module] || []; + modules[symbol.module] = modules[symbol.module] || []; modules[symbol.module].push({ name: symbol.name, symbol: symbol @@ -2924,7 +2971,7 @@ function postProcessAPIJSON(api) { if ( symbol.properties ) { for ( j = 0; j < symbol.properties.length; j++ ) { if ( symbol.properties[j].static && symbol.properties[j].module ) { - modules[symbol.properties[j].module] = modules[symbol.properties[j].module] || []; + modules[symbol.properties[j].module] = modules[symbol.properties[j].module] || []; modules[symbol.properties[j].module].push({ name: symbol.name + "." + symbol.properties[j].name, symbol: symbol.properties[j] @@ -2935,7 +2982,7 @@ function postProcessAPIJSON(api) { if ( symbol.methods ) { for ( j = 0; j < symbol.methods.length; j++ ) { if ( symbol.methods[j].static && symbol.methods[j].module ) { - modules[symbol.methods[j].module] = modules[symbol.methods[j].module] || []; + modules[symbol.methods[j].module] = modules[symbol.methods[j].module] || []; modules[symbol.methods[j].module].push({ name: symbol.name + "." + symbol.methods[j].name, symbol: symbol.methods[j] @@ -2944,44 +2991,45 @@ function postProcessAPIJSON(api) { } } } - + function guessExport(defaultExport, symbol) { if ( symbol.name === defaultExport ) { // default export equals the symbol name - symbol.symbol.export = ""; - //console.log(" (default):" + defaultExport); - } else if ( symbol.name.lastIndexOf(defaultExport + ".", 0) === 0 ) { + symbol.symbol.export = ""; + // console.log(" (default):" + defaultExport); + } else if ( symbol.name.lastIndexOf(defaultExport + ".", 0) === 0 ) { // default export is a prefix of the symbol name - symbol.symbol.export = symbol.name.slice(defaultExport.length + 1); - //console.log(" " + symbol.name.slice(defaultExport.length + 1) + ":" + symbol.name); + symbol.symbol.export = symbol.name.slice(defaultExport.length + 1); + // console.log(" " + symbol.name.slice(defaultExport.length + 1) + ":" + symbol.name); } else { - // default export is not a prefix of the symbol name -> no way to access it in AMD + // default export is not a prefix of the symbol name -> no way to access it in AMD symbol.symbol.export = undefined; console.log(" **** could not identify module export for API " + symbol.name); } } - + for ( n in modules ) { - - symbols = modules[n].sort(function(a,b) { + symbols = modules[n].sort(function(a, b) { if ( a.name === b.name ) { return 0; } return a.name < b.name ? -1 : 1; }); - + // console.log(' resolved exports of ' + n + ": " + symbols.map(function(symbol) { return symbol.name; } )); if ( /^jquery\.sap\./.test(n) ) { // the jquery.sap.* modules all export 'jQuery'. // any API from those modules is reachable via 'jQuery.*' - defaultExport = 'jQuery'; + defaultExport = "jQuery"; symbols.forEach( guessExport.bind(this, defaultExport) ); } else if ( /\/library$/.test(n) ) { // library.js modules export the library namespace defaultExport = n.replace(/\/library$/, "").replace(/\//g, "."); - if ( symbols.some(function(symbol) { return symbol.name === defaultExport; }) ) { + if ( symbols.some(function(symbol) { + return symbol.name === defaultExport; + }) ) { // if there is a symbol for the namespace, then all other symbols from the module should be sub-exports of that symbol symbols.forEach( guessExport.bind(this, defaultExport) @@ -2996,14 +3044,16 @@ function postProcessAPIJSON(api) { } else { // for all other modules, the assumed default export is identical to the name of the module (converted to a 'dot' name) defaultExport = n.replace(/\//g, "."); - if ( symbols.some(function(symbol) { return symbol.name === defaultExport; }) ) { + if ( symbols.some(function(symbol) { + return symbol.name === defaultExport; + }) ) { symbols.forEach( guessExport.bind(this, defaultExport) ); - //} else if ( symbols.length === 1 && (symbols[0].symbol.kind === 'class' || symbols[0].symbol.kind === 'namespace') ) { + // } else if ( symbols.length === 1 && (symbols[0].symbol.kind === 'class' || symbols[0].symbol.kind === 'namespace') ) { // if there is only one symbol and if that symbol is of type class or namespace, assume it is the default export // TODO is that assumption safe? Was only done because of IBarPageEnabler (which maybe better should be fixed in the JSDoc) - //symbols[0].symbol.export = ''; + // symbols[0].symbol.export = ''; } else { symbols.forEach(function(symbol) { symbol.symbol.export = undefined; @@ -3014,28 +3064,26 @@ function postProcessAPIJSON(api) { } } -//---- add on: API XML ----------------------------------------------------------------- +// ---- add on: API XML ----------------------------------------------------------------- function createAPIXML(symbols, filename, options) { - options = options || {}; - var roots = options.roots || null; - var legacyContent = !!options.legacyContent; - var omitDefaults = !!options.omitDefaults; - var addRedundancy = !!options.resolveInheritance; - - var indent = 0; - var output = []; - var sIndent = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; - var tags = []; - var ENUM = legacyContent ? "namespace" : "enum" ; - var BASETYPE = legacyContent ? "baseType" : "extends"; - var PROPERTY = legacyContent ? "parameter" : "property"; - var unclosedStartTag = false; + const roots = options.roots || null; + const legacyContent = !!options.legacyContent; + const omitDefaults = !!options.omitDefaults; + const addRedundancy = !!options.resolveInheritance; + + let indent = 0; + const output = []; + const sIndent = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; + let tags = []; + const ENUM = legacyContent ? "namespace" : "enum"; + const BASETYPE = legacyContent ? "baseType" : "extends"; + const PROPERTY = legacyContent ? "parameter" : "property"; + let unclosedStartTag = false; function getAPIJSON(name) { - - var symbol = lookup(name); + const symbol = lookup(name); if ( symbol && !symbol.synthetic ) { return createAPIJSON4Symbol(symbol, false); } @@ -3050,19 +3098,22 @@ function createAPIXML(symbols, filename, options) { return s ? s.replace(/&/g, "&").replace(/ 0 ) - output.push(sIndent.slice(0,indent)); - if ( arguments.length ) { - for (var i = 0; i < arguments.length; i++) - output.push(arguments[i]); + function writeln(...args) { + if ( indent > 0 ) { + output.push(sIndent.slice(0, indent)); + } + if ( args.length ) { + for (let i = 0; i < args.length; i++) { + output.push(args[i]); + } } output.push("\n"); } @@ -3082,17 +3133,16 @@ function createAPIXML(symbols, filename, options) { } function tag(name, value, omitEmpty) { - if ( omitEmpty && !value ) { return; } if ( unclosedStartTag ) { unclosedStartTag = false; - write('>\n'); + write(">\n"); } if ( arguments.length === 1 ) { // opening tag if ( indent > 0 ) { - output.push(sIndent.slice(0,indent)); + output.push(sIndent.slice(0, indent)); } write("<", name); unclosedStartTag = true; @@ -3112,7 +3162,7 @@ function createAPIXML(symbols, filename, options) { } function attrib(name, value, defaultValue) { - var emptyTag = arguments.length === 1; + const emptyTag = arguments.length === 1; if ( omitDefaults && arguments.length === 3 && value === defaultValue ) { return; } @@ -3131,9 +3181,8 @@ function createAPIXML(symbols, filename, options) { } function closeTag(name, noIndent) { - indent--; - var top = tags.pop(); + const top = tags.pop(); if ( top != name ) { // ERROR? } @@ -3151,7 +3200,7 @@ function createAPIXML(symbols, filename, options) { function textContent(text) { if ( unclosedStartTag ) { unclosedStartTag = false; - write('>'); + write(">"); } write(encode(text)); } @@ -3174,14 +3223,13 @@ function createAPIXML(symbols, filename, options) { } function writeMetadata(symbolAPI, inherited) { - - var ui5Metadata = symbolAPI["ui5-metadata"]; + const ui5Metadata = symbolAPI["ui5-metadata"]; if ( !ui5Metadata ) { return; } if ( addRedundancy && symbolAPI["extends"] ) { - var baseSymbolAPI = getAPIJSON(symbolAPI["extends"]); + const baseSymbolAPI = getAPIJSON(symbolAPI["extends"]); if ( baseSymbolAPI ) { writeMetadata(baseSymbolAPI, true); } @@ -3192,7 +3240,7 @@ function createAPIXML(symbols, filename, options) { tag("specialSetting"); attrib("name", special.name); attrib("type", special.type); - attrib("visibility", special.visibility, 'public'); + attrib("visibility", special.visibility, "public"); if ( special.since ) { attrib("since", special.since); } @@ -3211,11 +3259,11 @@ function createAPIXML(symbols, filename, options) { ui5Metadata.properties.forEach(function(prop) { tag("property"); attrib("name", prop.name); - attrib("type", prop.type, 'string'); + attrib("type", prop.type, "string"); if ( prop.defaultValue !== null ) { attrib("defaultValue", prop.defaultValue, null); } - attrib("visibility", prop.visibility, 'public'); + attrib("visibility", prop.visibility, "public"); if ( prop.since ) { attrib("since", prop.since); } @@ -3242,12 +3290,12 @@ function createAPIXML(symbols, filename, options) { tag("aggregation"); attrib("name", aggr.name); attrib("singularName", aggr.singularName); // TODO omit default? - attrib("type", aggr.type, 'sap.ui.core.Control'); + attrib("type", aggr.type, "sap.ui.core.Control"); if ( aggr.altTypes ) { attrib("altTypes", aggr.altTypes.join(",")); } - attrib("cardinality", aggr.cardinality, '0..n'); - attrib("visibility", aggr.visibility, 'public'); + attrib("cardinality", aggr.cardinality, "0..n"); + attrib("visibility", aggr.visibility, "public"); if ( aggr.since ) { attrib("since", aggr.since); } @@ -3274,9 +3322,9 @@ function createAPIXML(symbols, filename, options) { tag("association"); attrib("name", assoc.name); attrib("singularName", assoc.singularName); // TODO omit default? - attrib("type", assoc.type, 'sap.ui.core.Control'); - attrib("cardinality", assoc.cardinality, '0..1'); - attrib("visibility", assoc.visibility, 'public'); + attrib("type", assoc.type, "sap.ui.core.Control"); + attrib("cardinality", assoc.cardinality, "0..1"); + attrib("visibility", assoc.visibility, "public"); if ( assoc.since ) { attrib("since", assoc.since); } @@ -3295,7 +3343,7 @@ function createAPIXML(symbols, filename, options) { ui5Metadata.events.forEach(function(event) { tag("event"); attrib("name", event.name); - attrib("visibility", event.visibility, 'public'); + attrib("visibility", event.visibility, "public"); if ( event.since ) { attrib("since", event.since); } @@ -3307,9 +3355,9 @@ function createAPIXML(symbols, filename, options) { tagWithSince("deprecated", event.deprecated); if ( event.parameters ) { tag("parameters"); - for ( var pn in event.parameters ) { + for ( const pn in event.parameters ) { if ( event.parameters.hasOwnProperty(pn) ) { - var param = event.parameters[pn]; + const param = event.parameters[pn]; tag("parameter"); attrib("name", param.name); @@ -3346,24 +3394,22 @@ function createAPIXML(symbols, filename, options) { closeTag("annotation"); }); } - } function writeParameterPropertiesForMSettings(symbolAPI, inherited) { - - var ui5Metadata = symbolAPI["ui5-metadata"]; + const ui5Metadata = symbolAPI["ui5-metadata"]; if ( !ui5Metadata ) { return; } if ( symbolAPI["extends"] ) { - var baseSymbolAPI = getAPIJSON(symbolAPI["extends"]); + const baseSymbolAPI = getAPIJSON(symbolAPI["extends"]); writeParameterPropertiesForMSettings(baseSymbolAPI, true); } if ( ui5Metadata.specialSettings ) { ui5Metadata.specialSettings.forEach(function(special) { - if ( special.visibility !== 'hidden' ) { + if ( special.visibility !== "hidden" ) { tag("property"); attrib("name", special.name); attrib("type", special.type); @@ -3382,9 +3428,9 @@ function createAPIXML(symbols, filename, options) { tag("property"); attrib("name", prop.name); attrib("type", prop.type); - attrib("group", prop.group, 'Misc'); + attrib("group", prop.group, "Misc"); if ( prop.defaultValue !== null ) { - attrib("defaultValue", typeof prop.defaultValue === 'string' ? "\"" + prop.defaultValue + "\"" : prop.defaultValue); + attrib("defaultValue", typeof prop.defaultValue === "string" ? "\"" + prop.defaultValue + "\"" : prop.defaultValue); } attrib("optional"); if ( inherited ) { @@ -3400,7 +3446,7 @@ function createAPIXML(symbols, filename, options) { if ( aggr.visibility !== "hidden" ) { tag("property"); attrib("name", aggr.name); - attrib("type", aggr.type + (aggr.cardinality === '0..1' ? "" : "[]")); + attrib("type", aggr.type + (aggr.cardinality === "0..1" ? "" : "[]")); if ( aggr.altTypes ) { attrib("altTypes", aggr.altTypes.join(",")); } @@ -3419,7 +3465,7 @@ function createAPIXML(symbols, filename, options) { if ( assoc.visibility !== "hidden" ) { tag("property"); attrib("name", assoc.name); - attrib("type", "(" + assoc.type + "|" + "string)" + (assoc.cardinality === '0..1' ? "" : "[]")); + attrib("type", "(" + assoc.type + "|" + "string)" + (assoc.cardinality === "0..1" ? "" : "[]")); attrib("optional"); if ( inherited ) { attrib("origin", symbolAPI.name); @@ -3443,18 +3489,20 @@ function createAPIXML(symbols, filename, options) { closeTag("property"); }); } - } function writeParameterProperties(param, paramName) { - var props = param.parameterProperties, - prefix = paramName + '.', - count = 0; + const props = param.parameterProperties; + + + const prefix = paramName + "."; + + + let count = 0; if ( props ) { - for (var n in props ) { + for (const n in props ) { if ( props.hasOwnProperty(n) ) { - param = props[n]; if ( !legacyContent && count === 0 ) { @@ -3528,23 +3576,21 @@ function createAPIXML(symbols, filename, options) { */ function writeSymbol(symbol) { - - var kind; + let kind; if ( isaClass(symbol) && (roots || !symbol.synthetic) ) { // dump a symbol if it as a class symbol and if either hierarchies are dumped or if it is not a synthetic symbol - // for the hierarchy we use only the local information - var symbolAPI = createAPIJSON4Symbol(symbol); + const symbolAPI = createAPIJSON4Symbol(symbol); - kind = symbolAPI.kind === 'enum' ? ENUM : symbolAPI.kind; + kind = symbolAPI.kind === "enum" ? ENUM : symbolAPI.kind; tag(kind); attrib("name", symbolAPI.name); attrib("basename", symbolAPI.basename); -// if ( symbolAPI["resource"] ) { -// attrib("resource"); -// } + // if ( symbolAPI["resource"] ) { + // attrib("resource"); + // } if ( symbolAPI["module"] ) { attrib("module", symbolAPI["module"]); } @@ -3557,7 +3603,7 @@ function createAPIXML(symbols, filename, options) { if ( symbolAPI["static"] ) { attrib("static"); } - attrib("visibility", symbolAPI.visibility, 'public'); + attrib("visibility", symbolAPI.visibility, "public"); if ( symbolAPI.since ) { attrib("since", symbolAPI.since); } @@ -3568,12 +3614,10 @@ function createAPIXML(symbols, filename, options) { tagWithSince("experimental", symbolAPI.experimental); tagWithSince("deprecated", symbolAPI.deprecated); - if ( kind === 'class' ) { - - var hasSettings = symbolAPI["ui5-metadata"]; + if ( kind === "class" ) { + const hasSettings = symbolAPI["ui5-metadata"]; if ( !legacyContent && symbolAPI["ui5-metadata"] ) { - tag("ui5-metadata"); if ( symbolAPI["ui5-metadata"].stereotype ) { @@ -3583,17 +3627,15 @@ function createAPIXML(symbols, filename, options) { writeMetadata(symbolAPI); closeTag("ui5-metadata"); - } tag("constructor"); if ( legacyContent ) { attrib("name", symbolAPI.basename); } - attrib("visibility", symbolAPI.visibility, 'public'); + attrib("visibility", symbolAPI.visibility, "public"); if ( symbolAPI.constructor.parameters ) { symbolAPI.constructor.parameters.forEach(function(param, j) { - tag("parameter"); attrib("name", param.name); attrib("type", param.type); @@ -3650,7 +3692,7 @@ function createAPIXML(symbols, filename, options) { if ( member.module ) { attrib("module", member.module); } - attrib("visibility", member.visibility, 'public'); + attrib("visibility", member.visibility, "public"); if ( member["static"] ) { attrib("static"); } @@ -3672,7 +3714,7 @@ function createAPIXML(symbols, filename, options) { if ( member.module ) { attrib("module", member.module); } - attrib("visibility", member.visibility, 'public'); + attrib("visibility", member.visibility, "public"); if ( member["static"] ) { attrib("static"); } @@ -3682,7 +3724,6 @@ function createAPIXML(symbols, filename, options) { if ( member.parameters ) { member.parameters.forEach(function(param) { - tag("parameter"); attrib("name", param.name); attrib("type", param.type); @@ -3711,18 +3752,17 @@ function createAPIXML(symbols, filename, options) { if ( symbolAPI.methods ) { symbolAPI.methods.forEach(function(member) { - tag("method"); attrib("name", member.name); if ( member.module ) { attrib("module", member.module); } - attrib("visibility", member.visibility, 'public'); + attrib("visibility", member.visibility, "public"); if ( member["static"] ) { attrib("static"); } - if ( member.returnValue && member.returnValue.type ) { - attrib("type", member.returnValue.type, 'void'); + if ( member.returnValue && member.returnValue.type ) { + attrib("type", member.returnValue.type, "void"); } if ( member.since ) { attrib("since", member.since); @@ -3730,7 +3770,6 @@ function createAPIXML(symbols, filename, options) { if ( member.parameters ) { member.parameters.forEach(function(param) { - tag("parameter"); attrib("name", param.name); attrib("type", param.type); @@ -3760,7 +3799,6 @@ function createAPIXML(symbols, filename, options) { tagWithSince("deprecated", member.deprecated); // TODO secTags(member); closeTag("method"); - }); } @@ -3771,9 +3809,7 @@ function createAPIXML(symbols, filename, options) { } closeTag(kind); - } - } writeln(""); @@ -3782,7 +3818,7 @@ function createAPIXML(symbols, filename, options) { namespace("xmlns", "http://www.sap.com/sap.ui.library.api.xsd"); attrib("_version", "1.0.0"); if ( templateConf.version ) { - attrib("version", templateConf.version.replace(/-SNAPSHOT$/,"")); + attrib("version", templateConf.version.replace(/-SNAPSHOT$/, "")); } if ( templateConf.uilib ) { attrib("library", templateConf.uilib); @@ -3799,48 +3835,53 @@ function createAPIXML(symbols, filename, options) { closeRootTag("api"); fs.mkPath(path.dirname(filename)); - fs.writeFileSync(filename, getAsString(), 'utf8'); + fs.writeFileSync(filename, getAsString(), "utf8"); } -//---- add on: API JS ----------------------------------------------------------------- +// ---- add on: API JS ----------------------------------------------------------------- function createAPIJS(symbols, filename) { + const output = []; - var output = []; + const rkeywords = /^(?:abstract|as|boolean|break|byte|case|catch|char|class|continue|const|debugger|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|is|long|namespace|native|new|null|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|use|var|void|volatile|while|with)$/; - var rkeywords = /^(?:abstract|as|boolean|break|byte|case|catch|char|class|continue|const|debugger|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|is|long|namespace|native|new|null|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|use|var|void|volatile|while|with)$/; - - function isNoKeyword($) { return !rkeywords.test($.name); } + function isNoKeyword($) { + return !rkeywords.test($.name); + } - function isAPI($) { return $.access === 'public' || $.access === 'protected' || !$.access } + function isAPI($) { + return $.access === "public" || $.access === "protected" || !$.access; + } - function writeln(args) { - if ( arguments.length ) { - for (var i = 0; i < arguments.length; i++) - output.push(arguments[i]); + function writeln(...args) { + if ( args.length ) { + for (let i = 0; i < args.length; i++) { + output.push(args[i]); + } } output.push("\n"); } function unwrap(docletSrc) { - if (!docletSrc) { return ''; } + if (!docletSrc) { + return ""; + } // note: keep trailing whitespace for @examples // extra opening/closing stars are ignored // left margin is considered a star and a space // use the /m flag on regex to avoid having to guess what this platform's newline is docletSrc = - docletSrc.replace(/^\/\*\*+/, '') // remove opening slash+stars - .replace(/\**\*\/$/, "\\Z") // replace closing star slash with end-marker - .replace(/^\s*(\* ?|\\Z)/gm, '') // remove left margin like: spaces+star or spaces+end-marker - .replace(/\s*\\Z$/g, ''); // remove end-marker + docletSrc.replace(/^\/\*\*+/, "") // remove opening slash+stars + .replace(/\**\*\/$/, "\\Z") // replace closing star slash with end-marker + .replace(/^\s*(\* ?|\\Z)/gm, "") // remove left margin like: spaces+star or spaces+end-marker + .replace(/\s*\\Z$/g, ""); // remove end-marker return docletSrc; } function comment($, sMetaType) { - - var s = unwrap($.comment.toString()); + let s = unwrap($.comment.toString()); // remove the @desc tag s = s.replace(/(\r\n|\r|\n)/gm, "\n"); @@ -3866,41 +3907,44 @@ function createAPIJS(symbols, filename) { writeln(s.split(/\r\n|\r|\n/g).map(function($) { return " * " + $;}).join("\r\n")); writeln(" * /"); */ - } function signature($) { - var p = $.params, - r = [], - i; + const p = $.params; + + + const r = []; + + + let i; if ( p ) { for (i = 0; i < p.length; i++) { // ignore @param tags for 'virtual' params that are used to document members of config-like params // (e.g. like "@param param1.key ...") - if (p[i].name && p[i].name.indexOf('.') < 0) { + if (p[i].name && p[i].name.indexOf(".") < 0) { r.push(p[i].name); } } } - return r.join(','); + return r.join(","); } - function qname(member,parent) { - var r = member.memberof; - if ( member.scope !== 'static' ) { + function qname(member, parent) { + let r = member.memberof; + if ( member.scope !== "static" ) { r += ".prototype"; } return (r ? r + "." : "") + member.name; } - var mValues = { - "boolean" : "false", - "int" : "0", - "float" : "0.0", - "number" : "0.0", - "string" : "\"\"", - "object" : "new Object()", - "function" : "function() {}" + const mValues = { + "boolean": "false", + "int": "0", + "float": "0.0", + "number": "0.0", + "string": "\"\"", + "object": "new Object()", + "function": "function() {}" }; function valueForType(type) { @@ -3924,46 +3968,46 @@ function createAPIJS(symbols, filename) { } function retvalue(member) { - //console.log(member); - var r = valueForType(member.type || (member.returns && member.returns.length && member.returns[0] && member.returns[0].type && member.returns[0].type)); + // console.log(member); + const r = valueForType(member.type || (member.returns && member.returns.length && member.returns[0] && member.returns[0].type && member.returns[0].type)); if ( r ) { return "return " + r + ";"; } return ""; } - var sortedSymbols = symbols.slice(0).filter(function($) { return isaClass($) && isAPI($) && !$.synthetic; }).sort(sortByAlias); // sort only a copy(!) of the symbols, otherwise the SymbolSet lookup is broken + const sortedSymbols = symbols.slice(0).filter(function($) { + return isaClass($) && isAPI($) && !$.synthetic; + }).sort(sortByAlias); // sort only a copy(!) of the symbols, otherwise the SymbolSet lookup is broken sortedSymbols.forEach(function(symbol) { - - var sMetaType = (symbol.kind === 'member' && symbol.isEnum) ? 'enum' : symbol.kind; + const sMetaType = (symbol.kind === "member" && symbol.isEnum) ? "enum" : symbol.kind; if ( sMetaType ) { - writeln(""); writeln("// ---- " + symbol.longname + " --------------------------------------------------------------------------"); writeln(""); - var memberId, member; + let memberId; let member; - var ownProperties = childrenOfKind(symbol, 'property').own.filter(isNoKeyword).sort(sortByAlias); - if ( sMetaType === "class" ) { - comment(symbol, sMetaType); - writeln(symbol.longname + " = function(" + signature(symbol) + ") {};"); + const ownProperties = childrenOfKind(symbol, "property").own.filter(isNoKeyword).sort(sortByAlias); + if ( sMetaType === "class" ) { + comment(symbol, sMetaType); + writeln(symbol.longname + " = function(" + signature(symbol) + ") {};"); for ( memberId in ownProperties ) { member = ownProperties[memberId]; comment(member, sMetaType); writeln(qname(member, symbol) + " = " + value(member)); writeln(""); } - } else if ( sMetaType === 'namespace' || sMetaType === 'enum' ) { - //console.log("found namespace " + symbol.longname); - //console.log(ownProperties); - if ( ownProperties.length ) { - writeln("// dummy function to make Eclipse aware of namespace"); - writeln(symbol.longname + ".toString = function() { return \"\"; };"); - } + } else if ( sMetaType === "namespace" || sMetaType === "enum" ) { + // console.log("found namespace " + symbol.longname); + // console.log(ownProperties); + if ( ownProperties.length ) { + writeln("// dummy function to make Eclipse aware of namespace"); + writeln(symbol.longname + ".toString = function() { return \"\"; };"); } + } - var ownEvents = childrenOfKind(symbol, 'event').own.filter(isNoKeyword).sort(sortByAlias); + const ownEvents = childrenOfKind(symbol, "event").own.filter(isNoKeyword).sort(sortByAlias); if ( ownEvents.length ) { for ( memberId in ownEvents ) { member = ownEvents[memberId]; @@ -3973,7 +4017,7 @@ function createAPIJS(symbols, filename) { } } - var ownMethods = childrenOfKind(symbol, 'method').own.filter(isNoKeyword).sort(sortByAlias); + const ownMethods = childrenOfKind(symbol, "method").own.filter(isNoKeyword).sort(sortByAlias); if ( ownMethods.length ) { for ( memberId in ownMethods ) { member = ownMethods[memberId]; @@ -3982,47 +4026,43 @@ function createAPIJS(symbols, filename) { writeln(""); } } - } }); writeln("// ---- static fields of namespaces ---------------------------------------------------------------------"); sortedSymbols.forEach(function(symbol) { + const sMetaType = (symbol.kind === "member" && symbol.isEnum) ? "enum" : symbol.kind; - var sMetaType = (symbol.kind === 'member' && symbol.isEnum) ? 'enum' : symbol.kind; - - if ( sMetaType === 'namespace' || sMetaType === 'enum' ) { - - var ownProperties = childrenOfKind(symbol, 'property').own.filter(isNoKeyword).sort(sortByAlias); + if ( sMetaType === "namespace" || sMetaType === "enum" ) { + const ownProperties = childrenOfKind(symbol, "property").own.filter(isNoKeyword).sort(sortByAlias); if ( ownProperties.length ) { writeln(""); writeln("// ---- " + symbol.longname + " --------------------------------------------------------------------------"); writeln(""); - for (var memberId in ownProperties ) { - var member = ownProperties[memberId]; + for (const memberId in ownProperties ) { + const member = ownProperties[memberId]; comment(member, sMetaType); writeln(qname(member, symbol) + " = " + value(member) + ";"); writeln(""); } } } - }); fs.mkPath(path.dirname(filename)); - fs.writeFileSync(filename, output.join(""), 'utf8'); + fs.writeFileSync(filename, output.join(""), "utf8"); info(" saved as " + filename); } // Description + Settings function getConstructorDescription(symbol) { - var description = symbol.description; - var tags = symbol.tags; + let description = symbol.description; + const tags = symbol.tags; if ( tags ) { - for (var i = 0; i < tags.length; i++) { + for (let i = 0; i < tags.length; i++) { if ( tags[i].title === "ui5-settings" && tags[i].text) { description += "\n\n" + tags[i].text; break; @@ -4036,11 +4076,13 @@ function getConstructorDescription(symbol) { // Example function makeExample(example) { - var result = { - caption: null, - example: example - }, - match = /^\s*
([\s\S]+?)<\/caption>(?:[ \t]*[\n\r]*)([\s\S]+)$/i.exec(example); + const result = { + caption: null, + example: example + }; + + + const match = /^\s* ([\s\S]+?)<\/caption>(?:[ \t]*[\n\r]*)([\s\S]+)$/i.exec(example); if ( match ) { result.caption = match[1]; diff --git a/lib/tasks/generateJsdoc.js b/lib/tasks/generateJsdoc.js index 425d4027e..3d1a699e9 100644 --- a/lib/tasks/generateJsdoc.js +++ b/lib/tasks/generateJsdoc.js @@ -16,7 +16,8 @@ const {resourceFactory} = require("@ui5/fs"); * @param {string} parameters.options.pattern Pattern to locate the files to be processed * @param {string} parameters.options.projectName Project name * @param {string} parameters.options.version Project version - * @param {boolean} [parameters.options.sdkBuild=true] Whether additional SDK specific api.json resources shall be generated + * @param {boolean} [parameters.options.sdkBuild=true] Whether additional SDK specific api.json + * resources shall be generated * @returns {Promise } Promise resolving with undefined
once data has been written */ module.exports = async function({workspace, options}) { @@ -57,7 +58,6 @@ module.exports = async function({workspace, options}) { } }); - console.log(createdResources); await Promise.all(createdResources.map(async (resource) => { await workspace.write(resource); })); diff --git a/lib/types/library/LibraryBuilder.js b/lib/types/library/LibraryBuilder.js index b4d643518..f80cbb815 100644 --- a/lib/types/library/LibraryBuilder.js +++ b/lib/types/library/LibraryBuilder.js @@ -88,9 +88,6 @@ class LibraryBuilder extends AbstractBuilder { options: { projectName: project.metadata.name } - }).catch((err) => { - console.log("generateLibraryPreload failed:", err); - throw err; }); });