diff --git a/build-tools/handleApiFiles.js b/build-tools/handleApiFiles.js index 10cd699309bd8f279e2680e3da1a4f797d895223..f141c0b41a94edf9c67b9aa5bfb8ff413ff2cb20 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 52451b6cc74aa38431885c8d056e16987300da4b..63bc4029bd3a0d3b84479f6534f61e590aa03d19 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];