Skip to content

Commit

Permalink
Add test for shorter return statement and fix shorter return statemen…
Browse files Browse the repository at this point in the history
…t bug
  • Loading branch information
man-dwarf committed May 9, 2021
1 parent 240ac24 commit 6169ebc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ export class Doc
if (this.return && (this.return != 'void' || Config.instance.get('returnVoid'))) {
let appendSpace = '';
if (alignReturn) {
appendSpace = Array(1 + maxParamNameLength).fill(' ').join('');
appendSpace =
Array(1 + maxParamTypeLength - this.return.length).fill(' ').join('') +
Array(maxParamNameLength).fill(' ').join('');
}
returnString = "@return \${###:" +this.return + "}" + appendSpace;
}
Expand Down
31 changes: 31 additions & 0 deletions test/fixtures/doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -426,5 +426,36 @@
" * @return ${4:LongClassName} ",
" */"
]
},
{
"name": "Align params and shorter return statement",
"config": {
"gap": true,
"alignParams": true,
"alignReturn": true
},
"input": {
"message": "Undocumented function",
"params": [
{
"name": "$nameLong",
"type": "int"
},
{
"name": "$name",
"type": "string"
}
],
"return": "int"
},
"expected": [
"/**",
" * ${1:Undocumented function}",
" *",
" * @param ${2:int} \\$nameLong ",
" * @param ${3:string} \\$name ",
" * @return ${4:int} ",
" */"
]
}
]

0 comments on commit 6169ebc

Please sign in to comment.