From 8fa0272c2658afbc26e13d71a3b3b7887749604e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=9B=B9=E5=AE=87?= Date: Mon, 25 Aug 2025 17:33:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E6=AE=B5jsdoc?= =?UTF-8?q?=E9=80=82=E9=85=8D/*=E5=8D=95=E8=A1=8C=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王曹宇 --- build-tools/handleApiFiles.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/build-tools/handleApiFiles.js b/build-tools/handleApiFiles.js index 33225dc30b..1301616b12 100755 --- a/build-tools/handleApiFiles.js +++ b/build-tools/handleApiFiles.js @@ -263,23 +263,15 @@ function handleArktsDefinition(type, fileContent) { * @returns */ function saveLatestJsDoc(fileContent) { - let regx = /(\/\*[\s\S]*?\*\*\/)/g; - - fileContent = fileContent.split('').reverse().join(''); - let preset = 0; - fileContent = fileContent.replace(regx, (substring, p1, offset, str) => { - if (!/ecnis@\s*\*/g.test(substring)) { - return substring; - } - const preStr = str.substring(preset, offset); - preset = offset + substring.length; - if (/\S/g.test(preStr)) { + // 获取包含@since的多段连续注释 + return fileContent.replace(/(\s*\/\*\*(?:(?!\/\*\*)[\s\S])*?@since[\s\S]*?\*\/\s*?)+/g, (substring, p1) => { + if (substring === p1) {// 只有一段 return substring; } - return ''; + // 多段时需要保留开头空行 + const blankSpace = substring.match(/^\s*/)[0]; + return blankSpace + p1; }); - fileContent = fileContent.split('').reverse().join(''); - return fileContent; } /** -- Gitee