From c2bacb67bcbf6aebbf6739d736c2c89be29159ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=9B=B9=E5=AE=87?= Date: Sat, 6 Sep 2025 16:54:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E6=9B=BF=E6=8D=A2=E5=92=8C?= =?UTF-8?q?=E6=89=93=E5=8C=85=E5=B7=A5=E5=85=B7=E9=80=82=E9=85=8Ddynamicon?= =?UTF-8?q?ly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王曹宇 --- build-tools/handleApiFiles.js | 8 +++++--- build-tools/process_dynamic/process_dynamic.js | 14 ++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/build-tools/handleApiFiles.js b/build-tools/handleApiFiles.js index 10cd699309..f141c0b41a 100755 --- a/build-tools/handleApiFiles.js +++ b/build-tools/handleApiFiles.js @@ -363,11 +363,11 @@ function deleteArktsTag(fileContent) { fileContent = fileContent.replace(arktsTagRegx, (substring, p1) => { return ''; }); - const arktsSinceTagRegx = /\*\s*@since\s\S*\s(dynamic&static|dynamic|static)\s*(\r|\n)\s*/g; + const arktsSinceTagRegx = /\*\s*@since\s\S*\s(dynamic&static|dynamiconly|dynamic|static)\s*(\r|\n)\s*/g; // 处理@since xx dynamic&static格式标签文本 fileContent = fileContent.replace(arktsSinceTagRegx, (substring, p1) => { if (dirType === DirType.typeOne && substring.indexOf('dynamic') !== -1) { - substring = substring.replace(/\sdynamic(&static)?/g, ''); + substring = substring.replace(/\s(dynamiconly|dynamic(&static)?)/g, ''); } else if ((dirType === DirType.typeTwo || dirType === DirType.typeThree) && substring.indexOf('static') !== -1) { substring = substring.replace(/\s(dynamic&)?static/g, ''); } else { @@ -920,7 +920,9 @@ function judgeIsDeleteApi(node) { } if (dirType === DirType.typeTwo) { - return (/@deprecated/g.test(notesStr) && sinceVersion < 20) || /@arkts\s*1\.1(?!&1\.2)/g.test(notesStr) || (/@since\s\S*\sdynamic/g.test(notesStr) && !/@since\s\S*\s(dynamic&)?static/g.test(notesStr)); + return (/@deprecated/g.test(notesStr) && sinceVersion < 20) || + /@arkts\s*1\.1(?!&1\.2)/g.test(notesStr) || + (/@since\s\S*\s(dynamiconly|dynamic)/g.test(notesStr) && !/@since\s\S*\s(dynamic&)?static/g.test(notesStr)); } if (dirType === DirType.typeThree) { diff --git a/build-tools/process_dynamic/process_dynamic.js b/build-tools/process_dynamic/process_dynamic.js index 52451b6cc7..63bc4029bd 100644 --- a/build-tools/process_dynamic/process_dynamic.js +++ b/build-tools/process_dynamic/process_dynamic.js @@ -23,6 +23,7 @@ const DirType = { 1.2: 'static', static: 'static', '1.1&1.2': 'dynamic&static', + dynamiconly: 'dynamiconly', }; // P0级别KIT,需要将动态接口转换为dynamic const HIGH_LEVEL_KIT_SET = new Set([ @@ -205,9 +206,6 @@ function getNewCommont(substring, kitName, filePath) { !currentArkts) { // 若非P0接口,直接返回当前JSDoc信息 return substring; } - if (isStaticFile(filePath)) { - return substring; - } const sinceTagContent = parseSinceTagContent(sinceInfo); substring = substring.replace(/(.*@since\s+).*/g, sinceTagContent); if (sinceInfo.apiArkts) { @@ -227,7 +225,9 @@ function parseSinceTagContent(sinceInfo) { const arktsVersionObj = sinceInfo.arktsSince; let replaceVal = ``; if (sinceInfo.toDynamic) { // 转换为@since xx dynamic - replaceVal += `$1${sinceInfo.since || arktsVersionObj['1.1']} ${DirType['1.1']}`; + const sinceValue = sinceInfo.since || arktsVersionObj['1.1']; + const dynamicTag = sinceInfo.toDynamicOnly ? DirType.dynamiconly : DirType['1.1']; + replaceVal += `$1${sinceValue} ${dynamicTag}`; } if (sinceInfo.toDynamic && sinceInfo.toStatic) { replaceVal += '\n'; @@ -260,6 +260,8 @@ function parseSinceTagContent(sinceInfo) { * @property {object} arktsSince - arkts since object. * @property {boolean} toDynamic - to dynamic. * @property {boolean} toStatic - to static. + * @property {boolean} toDynamicOnly - to dynamic. + * @property {boolean} toStaticOnly - to static. * @property {number} dynamicSince - dynamic since ID. * @property {number} staticSince - static since ID. */ @@ -271,10 +273,14 @@ function parseSinceTagContent(sinceInfo) { * @return { sinceInfoObj } */ function getSinceInfo(jsDocStr, currentArkts) { + const hasDeprecatedTag = /\*\s+\@deprecated\s+/g.test(jsDocStr); + const hasUseinsteadTag = /\*\s+\@useinstead\s+/g.test(jsDocStr); /** @type {sinceInfoObj} */ let sinceInfo = { toDynamic: false, toStatic: false, + toDynamicOnly: hasDeprecatedTag && hasUseinsteadTag, + toStaticOnly: false, currentArkts: currentArkts, }; const sinceStr = jsDocStr.match(/\*\s+\@since\s+(.*)/)?.[1]; -- Gitee