diff --git a/build-tools/api_check_plugin/src/check_jsdoc_value/check_rest_value.js b/build-tools/api_check_plugin/src/check_jsdoc_value/check_rest_value.js index 7e4e44dd6..731f71127 100644 --- a/build-tools/api_check_plugin/src/check_jsdoc_value/check_rest_value.js +++ b/build-tools/api_check_plugin/src/check_jsdoc_value/check_rest_value.js @@ -187,9 +187,9 @@ function isArkUIApiFile(fileName) { * xxx.xxx#event:xxx */ function checkModule(moduleValue) { - return /^[A-Za-z]+\b(\.[A-Za-z]+\b)*$/.test(moduleValue) || - /^[A-Za-z]+\b(\.[A-Za-z]+\b)*\#[A-Za-z]+\b$/.test(moduleValue) || - /^[A-Za-z]+\b(\.[A-Za-z]+\b)*\#event:[A-Za-z]+\b$/.test(moduleValue); + return /^[A-Za-z_]+\b(\.[A-Za-z_]+\b)*$/.test(moduleValue) || + /^[A-Za-z_]+\b(\.[A-Za-z_]+\b)*\#[A-Za-z_]+\b$/.test(moduleValue) || + /^[A-Za-z_]+\b(\.[A-Za-z_]+\b)*\#event:[A-Za-z_]+\b$/.test(moduleValue); } function splitUseinsteadValue(useinsteadValue) { @@ -212,14 +212,14 @@ function splitUseinsteadValue(useinsteadValue) { const fileNameArray = splitArray[0].split('.'); if (fileNameArray.length === 1) { // arkui - if (!/^[A-Za-z]+\b$/.test(fileNameArray[0]) || !checkModule(splitArray[1])) { + if (!/^[A-Za-z_]+\b$/.test(fileNameArray[0]) || !checkModule(splitArray[1])) { splitResult.checkResult = false; } } else { // é¯˛arkui let checkFileName = true; for (let i = 0; i < fileNameArray.length; i++) { - if (fileNameArray[0] !== 'ohos' || !/^[A-Za-z]+\b$/.test(fileNameArray[i])) { + if (fileNameArray[0] !== 'ohos' || !/^[A-Za-z_]+\b$/.test(fileNameArray[i])) { checkFileName = false; } } diff --git a/build-tools/api_check_plugin/src/check_legality.js b/build-tools/api_check_plugin/src/check_legality.js index 7f82be4cb..0ee748d4a 100644 --- a/build-tools/api_check_plugin/src/check_legality.js +++ b/build-tools/api_check_plugin/src/check_legality.js @@ -69,10 +69,10 @@ function checkJsDocLegality(node, sourcefile, checkInfoMap) { ); // 'param' legalityCheck(node, sourcefile, [ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature, - ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature], ['param'], true, checkInfoMap, + ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature, ts.SyntaxKind.Constructor], ['param'], true, checkInfoMap, (currentNode, checkResult) => { if (!new Set([ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature, - ts.SyntaxKind.MethodDeclaration]).has(currentNode.kind)) { + ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.Constructor]).has(currentNode.kind)) { return true; } return currentNode.parameters && currentNode.parameters.length > 0; @@ -155,6 +155,8 @@ function legalityCheck(node, sourcefile, legalKinds, tagsName, isRequire, checkI } else if (tag.tag === 'deprecated') { useinsteadResultObj.hasDeprecated = true; } + } else if ((tagName === 'interface' || tagName === 'typedef') && (tag.tag === 'interface' || tag.tag === 'typedef')) { + checkResult = true; } else if (tag.tag === tagName) { checkResult = true; } @@ -163,7 +165,7 @@ function legalityCheck(node, sourcefile, legalKinds, tagsName, isRequire, checkI } }); if (tagName === 'param' && (ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || - ts.isFunctionDeclaration(node) || ts.isCallSignatureDeclaration(node))) { + ts.isFunctionDeclaration(node) || ts.isCallSignatureDeclaration(node) || ts.isConstructorDeclaration(node))) { parameterNum = node.parameters.length; checkResult = parameterNum !== paramTagNum; } @@ -251,7 +253,8 @@ function checkJsDocOfCurrentNode(node, sourcefile, permissionConfigPath, fileNam const checker = JsDocValueChecker[tag.tag]; if (checker) { let valueCheckResult; - if (tag.tag === 'param') { + if (tag.tag === 'param' && [ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature, + ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature, ts.SyntaxKind.Constructor].indexOf(node.kind) >= 0) { valueCheckResult = checker(tag, node, sourcefile, fileName, paramIndex++); } else if (tag.tag === 'throws') { valueCheckResult = checker(tag, node, sourcefile, fileName, throwsIndex++); diff --git a/build-tools/jsdoc_format_plugin/src/core/modificationProcessor.ts b/build-tools/jsdoc_format_plugin/src/core/modificationProcessor.ts index f1f785592..e78ead11e 100644 --- a/build-tools/jsdoc_format_plugin/src/core/modificationProcessor.ts +++ b/build-tools/jsdoc_format_plugin/src/core/modificationProcessor.ts @@ -282,7 +282,8 @@ class JSDocModificationManager { static addParamTag(node: comment.CommentNode, commentInfo: comment.CommentInfo, tagName: string, context: Context | undefined): boolean { if (node.astNode && (ts.isMethodDeclaration(node.astNode) || ts.isMethodSignature(node.astNode) || - ts.isFunctionDeclaration(node.astNode) || ts.isCallSignatureDeclaration(node.astNode))) { + ts.isFunctionDeclaration(node.astNode) || ts.isCallSignatureDeclaration(node.astNode) || + ts.isConstructorDeclaration(node.astNode))) { let paramTagNum: number = 0; commentInfo.commentTags.forEach((tag: comment.CommentTag) => { if (tag.tag === 'param') {