Skip to content

Commit 0cb02ac

Browse files
authored
[FEATURE] Align JSDoc template & plugin with OpenUI5 1.87.0 (#572)
* [FEATURE] Align JSDoc template & plugin with OpenUI5 1.87.0 Includes the following changes - [INTERNAL] encode property default values as JS string literals UI5/openui5@a63d92235 - [INTERNAL] Update copyright year to 2021 UI5/openui5@bc6825e48 - [FIX] Corrected regular expression (SAPHosted) UI5/openui5@319798593 - [FEATURE] Improve documentation for restricted APIs UI5/openui5@cb855596b - generated "auto-doc" honors visibility of target class. If target class is restricted, generated documentation also has visibility restricted - for restricted APIs, export the list of allowed consumers to api.json (property name 'allowedFor') - fix split of allowed consumers in tag handler for '@ui5-restricted' (comma is the only valid separator) - [FEATURE] Added FAQ section in ApiRef UI5/openui5@8d2d85e69 An extra FAQ section will be displayed in ApiRef whenever FAQ content is specified. - [INTERNAL] Change to inclusive term "excluded"/"included" UI5/openui5@7b2ac1edb - [INTERNAL] Add missing props to event metadata UI5/openui5@ab7ab07ea The properties 'allowPreventDefault' and 'enableEventBubbling' had been missing in the API summary (api.json) for events. - [INTERNAL] Make interface validation more robust UI5/openui5@32f59b31c The validation of an implementation against an implemented interface should not crash when the implementation has no methods at all. - [INTERNAL] Minor improvements of template UI5/openui5@e766eeee5 - [INTERNAL] Handling of defaultValues, error logging UI5/openui5@3bd509b1f A default value of "" (empty string) was not handled properly when generating auto-doc comments and a default value of "undefined" was not represented in the final api.json. To avoid confusion in the log, errors that do not break the build are no longer reported as errors, but as 'future errors'. APIs that can only be addressed via their global name, not via an AMD dependency, can now be marked with @ui5-global-only. They are no longer reported as errors during the build (as they can't be fixed). - [INTERNAL] Export only valid 'since' values UI5/openui5@a58310b2d - [INTERNAL] Normalize notation for generic types UI5/openui5@6e4e0ea87 For generic types, JSDoc allows two different notations, one with a dot between the type's name and the type parameters (e.g. Array.<string>) and one without the dot. The documentation for the Google Closure Compiler (to which JSDoc refers) already rates the notation with the dot as 'deprecated' (see https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System , Type Application), JSDoc doesn't. However, as the notation without the dot is also common to TypeScript developers, all types in the api.json will now be normalized to that notation. - [INTERNAL] Add default value to JSDoc UI5/openui5@bb6001950 Adding default values of function parameters to JSDoc conform notation * [INTERNAL] Encode property default values as JS string literals
1 parent cba257d commit 0cb02ac

File tree

4 files changed

+362
-137
lines changed

4 files changed

+362
-137
lines changed

lib/processors/jsdoc/lib/createIndexFiles.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Node script to create cross-library API index files for use in the UI5 SDKs.
33
*
4-
* (c) Copyright 2009-2020 SAP SE or an SAP affiliate company.
4+
* (c) Copyright 2009-2021 SAP SE or an SAP affiliate company.
55
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
66
*/
77

@@ -247,7 +247,7 @@ function createIndexFiles(versionInfoFile, unpackedTestresourcesRoot, targetFile
247247
function convertListToTree(symbols) {
248248
let aTree = [];
249249

250-
// Filter out black list libraries
250+
// Filter out excluded libraries
251251
symbols = symbols.filter(({lib}) => ["sap.ui.documentation"].indexOf(lib) === -1);
252252

253253
// Create treeName and displayName

lib/processors/jsdoc/lib/transformApiJson.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Node script to preprocess api.json files for use in the UI5 SDKs.
33
*
4-
* (c) Copyright 2009-2020 SAP SE or an SAP affiliate company.
4+
* (c) Copyright 2009-2021 SAP SE or an SAP affiliate company.
55
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
66
*/
77

@@ -35,9 +35,10 @@ const log = (function() {
3535
* @param {string} sLibraryFile Path to the .library file of the library, used to extract further documentation information
3636
* @param {string|string[]} vDependencyAPIFiles Path of folder that contains api.json files of predecessor libs or
3737
* an array of paths of those files
38+
* @param {string} sFAQDir Path to the directory containing the sources for the FAQ section in APiRef
3839
* @returns {Promise} A Promise that resolves after the transformation has been completed
3940
*/
40-
function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles, options) {
41+
function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles, sFAQDir, options) {
4142
const fs = options && options.fs || require("fs");
4243
const returnOutputFiles = options && !!options.returnOutputFiles;
4344

@@ -46,6 +47,7 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
4647
log.info(" output file: " + sOutputFile);
4748
log.info(" library file: " + sLibraryFile);
4849
log.info(" dependency dir: " + vDependencyAPIFiles);
50+
log.info(" FAQ src dir: " + sFAQDir);
4951
if (options && options.fs) {
5052
log.info("Using custom fs.");
5153
}
@@ -785,6 +787,25 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
785787
})
786788
}
787789

790+
/**
791+
* Check for existence of FAQ data
792+
* (FAQ data must be defined as *.md files in the <code>sFAQDir</code>)
793+
* and add a boolean flag in case it exists
794+
*
795+
* @param oChainObject chain object
796+
*/
797+
function addFlagsForFAQData(oChainObject) {
798+
if (!sFAQDir) {
799+
return oChainObject;
800+
}
801+
oChainObject.fileData.symbols.forEach(function(symbol) {
802+
if (fs.existsSync(path.join(sFAQDir, symbol.basename + ".md"))) {
803+
symbol.hasFAQ = true;
804+
}
805+
});
806+
return oChainObject;
807+
}
808+
788809
/**
789810
* Create api.json from parsed data
790811
* @param oChainObject chain object
@@ -946,6 +967,7 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
946967
_sTopicId: "",
947968
_oTopicData: {},
948969
_baseTypes: [
970+
// TODO this list URGENTLY needs to be replaced by the Type parser and a much smaller list
949971
"sap.ui.core.any",
950972
"sap.ui.core.object",
951973
"sap.ui.core.function",
@@ -969,7 +991,9 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
969991
"object[]",
970992
"object|object[]",
971993
"[object Object][]",
994+
"Array<[object Object]>",
972995
"Array.<[object Object]>",
996+
"Object<string,string>",
973997
"Object.<string,string>",
974998
"function",
975999
"float",
@@ -1299,7 +1323,7 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
12991323

13001324
handleExternalUrl: function (sTarget, sText) {
13011325
// Check if the external domain is SAP hosted
1302-
let bSAPHosted = /^https?:\/\/(?:www.)?[\w.]*(?:sap|hana\.ondemand|sapfioritrial)\.com/.test(sTarget);
1326+
let bSAPHosted = /^https?:\/\/([\w.]*\.)?(?:sap|hana\.ondemand|sapfioritrial)\.com/.test(sTarget);
13031327

13041328
return `<a target="_blank" rel="noopener" href="${sTarget}">${sText}</a>
13051329
<img src="./resources/sap/ui/documentation/sdk/images/${bSAPHosted ? 'link-sap' : 'link-external'}.png"
@@ -2016,6 +2040,7 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
20162040
.then(getAPIJSONPromise)
20172041
.then(loadDependencyLibraryFiles)
20182042
.then(transformApiJson)
2043+
.then(addFlagsForFAQData)
20192044
.then(createApiRefApiJson);
20202045
return p;
20212046

0 commit comments

Comments
 (0)