Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: solve multiline deprecated description #104

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,21 @@ class Visitor {
var summaryText = summary ? _escape(summary.text.text.trimEnd()) : '';
var returnText = _return ? _return.text.text.trimEnd() : '';
let hasNextSection = false;

if (deprecated) {
if (deprecated.text.text.trimEnd() === '') {
this.emit(`// Deprecated\n`, level);
} else {
this.emit(`// Deprecated: ${deprecated.text.text.trimEnd()}\n`, level);
}
let deprecatedText = deprecated.text.text.trimEnd();
deprecatedText.split('\n').forEach((line, index, array) => {
if(index === 0) {
this.emit(`// Deprecated: ${line}\n`, level);
if (array.length > 1) {
this.emit(`//\n`, level);
}
} else {
this.emit(`// ${line}\n`, level);
if (index < array.length - 1){
this.emit(`//\n`, level);
}
}
});
hasNextSection = true;
}
if (summaryText !== '') {
Expand Down
25 changes: 24 additions & 1 deletion test/fixtures/annotation/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,19 @@ func TestFuncWithAnnotation1 (test *string, _test *string) (_err error) {
return _err
}

// Deprecated: test is deprecated, use xxx instead.
//
// deprecated description1
//
// deprecated description2
//
// Summary:
//
// annotation test summary
//
// summary for annotation
// summary description1
//
// summary description2
//
// @param test - string param1
//
Expand All @@ -134,3 +142,18 @@ func TestFuncWithAnnotation2 (test *string, _test *string) (_err error) {
return _err
}

// Deprecated: deprecated test for line break.
//
// @param test - string param1
//
// @param _test - string param2
//
// @return void
//
// @throws InternalError Server error. 500 服务器端出现未知异常。
func TestFuncWithAnnotation3 (test *string, _test *string) (_err error) {
// empty comment1
// empty comment2
return _err
}

24 changes: 22 additions & 2 deletions test/fixtures/annotation/main.dara
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ static async function testFuncWithAnnotation1(test: string, _test: string): void

/**
* @summary annotation test summary
* summary for annotation
* summary description1
* summary description2
*
* @deprecated test is deprecated, use xxx instead.
* deprecated description1
* deprecated description2
*
* @param test string param1
* @param _test string param2
Expand All @@ -64,4 +69,19 @@ static async function testFuncWithAnnotation1(test: string, _test: string): void
static async function testFuncWithAnnotation2(test: string, _test: string): void {
// empty comment1
// empty comment2
}
}


/**
* @deprecated
* deprecated test for line break.
*
* @param test string param1
* @param _test string param2
* @return void
* @throws InternalError Server error. 500 服务器端出现未知异常。
*/
static async function testFuncWithAnnotation3(test: string, _test: string): void {
// empty comment1
// empty comment2
}
Loading