Skip to content

Commit de047d7

Browse files
committed
[INTERNAL] lib/processors/jsdoc: Enable sap/base enums to be used as sap/ui/base/DataTypes
The JSDoc template now detects when a managed property uses a global type name but the type itself has a `module:*` name. In that case, the `module:*` name is used for the generated API documentation. Cherry-picked from UI5/openui5@e4d070423.
1 parent 11f0182 commit de047d7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lib/processors/jsdoc/lib/ui5/template/publish.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,6 +2525,37 @@ function postProcessAPIJSON(api) {
25252525
`doesn't match containing library '${api.library}'. Library must be explicitly defined in class metadata!`);
25262526
}
25272527
}
2528+
if (Array.isArray(symbol["ui5-metadata"].properties)) {
2529+
for (const prop of symbol["ui5-metadata"].properties) {
2530+
let moduleType;
2531+
// cut off array brackets for symbol lookup
2532+
const arrType = isArrayType(prop.type);
2533+
let lookupType = prop.type;
2534+
if (arrType) {
2535+
lookupType = lookupType.replace("[]", "");
2536+
}
2537+
if (prop.dataType === undefined
2538+
&& findSymbol(lookupType) == null
2539+
&& !lookupType?.startsWith("module:")
2540+
&& findSymbol(moduleType = `module:${lookupType.replace(/\./g, "/")}`) != null) {
2541+
// note: the dataType must be the original, including array brackets if present
2542+
prop.dataType = prop.type;
2543+
// the moduleType also needs to include the array brackets if present in the original dataType
2544+
prop.type = moduleType + (arrType ? "[]" : "");
2545+
for (const methodName of prop.methods) {
2546+
const method = symbol.methods?.find((m) => m.name === methodName);
2547+
if (methodName.startsWith("get")
2548+
&& method?.returnValue?.type === prop.dataType) {
2549+
method.returnValue.type = prop.type;
2550+
} else if (methodName.startsWith("set")
2551+
&& method?.parameters?.[0]?.type === prop.dataType) {
2552+
method.parameters[0].type = prop.type;
2553+
}
2554+
}
2555+
info(`${symbol.name}: adapted type of ${prop.name} and its accessors from '${prop.dataType}' to '${prop.type}'`);
2556+
}
2557+
}
2558+
}
25282559
});
25292560

25302561
}

0 commit comments

Comments
 (0)