Skip to content

Commit

Permalink
fix: solve multiline deprecated description
Browse files Browse the repository at this point in the history
  • Loading branch information
飞澋 authored and PanPanZou committed May 21, 2024
1 parent e939fa5 commit 71a5597
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
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
10 changes: 9 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 Down
7 changes: 6 additions & 1 deletion 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 Down

0 comments on commit 71a5597

Please sign in to comment.