Skip to content

Commit c015fd9

Browse files
committed
feat: Support for @template
Closes #860
1 parent 0e6ff69 commit c015fd9

File tree

5 files changed

+110
-46
lines changed

5 files changed

+110
-46
lines changed

src/lib/converter/factories/comment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export function parseComment(text: string, comment: Comment = new Comment()): Co
170170
line = tag[2].trim();
171171

172172
if (tagName === 'return') { tagName = 'returns'; }
173-
if (tagName === 'param' || tagName === 'typeparam') {
173+
if (tagName === 'param' || tagName === 'typeparam' || tagName === 'template') {
174174
line = consumeTypeData(line);
175175
const param = /[^\s]+/.exec(line);
176176
if (param) {

src/lib/converter/plugins/CommentPlugin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ export class CommentPlugin extends ConverterComponent {
162162
const comment = reflection.parent && reflection.parent.comment;
163163
if (comment) {
164164
let tag = comment.getTag('typeparam', reflection.name);
165+
if (!tag) {
166+
tag = comment.getTag('template', reflection.name);
167+
}
165168
if (!tag) {
166169
tag = comment.getTag('param', `<${reflection.name}>`);
167170
}

src/lib/converter/plugins/DeepCommentPlugin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export class DeepCommentPlugin extends ConverterComponent {
5353
let tag: CommentTag | undefined;
5454
if (reflection instanceof TypeParameterReflection) {
5555
tag = target.comment.getTag('typeparam', reflection.name);
56+
if (!tag) {
57+
tag = target.comment.getTag('template', reflection.name);
58+
}
5659
if (!tag) {
5760
tag = target.comment.getTag('param', '<' + reflection.name + '>');
5861
}

src/test/converter/function/generic-function.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,12 @@ function functionWithGenericArrayParameter<T>(param: T, params: T[]): T[] {
1919
return params;
2020
}
2121

22+
/**
23+
* @param param this describes param
24+
* @template T this describes T
25+
*/
26+
function functionWithTemplate<T>(param: T): T {
27+
return param;
28+
}
29+
2230
export {};

0 commit comments

Comments
 (0)