From e09be8c3a6b0484b3c325c92c7bbc5e795b7ec6f Mon Sep 17 00:00:00 2001 From: Revone Date: Tue, 19 Nov 2024 23:21:40 +1300 Subject: [PATCH] chore: Implement unit tests as example code in the README.md and source code comments. --- testToExample.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testToExample.ts b/testToExample.ts index 3b3727e..63d0781 100644 --- a/testToExample.ts +++ b/testToExample.ts @@ -105,16 +105,16 @@ function addExamplesToSourceFile( const classEnd = classNode.getEnd(); const classText = classNode.getFullText(sourceFile); - // 提取注释内容 + // Extract annotation content const existingCommentMatch = classText.match(/\/\*\*([\s\S]*?)\*\//); if (!existingCommentMatch) { console.warn(`No existing comment found for class: ${className}`); return; } - const existingCommentInner = existingCommentMatch[1]; // 提取注释内容(不包括`/**`和`*/`) + const existingCommentInner = existingCommentMatch[1]; // Extract comment content (excluding `/**` and `*/`) - // 替换 @example 部分 + // Replace @example part const exampleSection = examples .map( example => @@ -133,7 +133,7 @@ function addExamplesToSourceFile( } - // 替换原始内容 + // Replace original content updatedContent = sourceContent.slice(0, classStart - existingCommentInner.length - 1) + newComment +