mirror of
https://github.com/zrwusa/data-structure-typed.git
synced 2024-11-23 04:44:04 +00:00
chore: Implement unit tests as example code in the README.md and source code comments.
This commit is contained in:
parent
0ff5ddc410
commit
e09be8c3a6
|
@ -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 +
|
||||
|
|
Loading…
Reference in a new issue