Skip to content

Commit

Permalink
feat: Support for @template
Browse files Browse the repository at this point in the history
Closes #860
  • Loading branch information
Gerrit0 committed Mar 15, 2020
1 parent 0e6ff69 commit c015fd9
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/lib/converter/factories/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export function parseComment(text: string, comment: Comment = new Comment()): Co
line = tag[2].trim();

if (tagName === 'return') { tagName = 'returns'; }
if (tagName === 'param' || tagName === 'typeparam') {
if (tagName === 'param' || tagName === 'typeparam' || tagName === 'template') {
line = consumeTypeData(line);
const param = /[^\s]+/.exec(line);
if (param) {
Expand Down
3 changes: 3 additions & 0 deletions src/lib/converter/plugins/CommentPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ export class CommentPlugin extends ConverterComponent {
const comment = reflection.parent && reflection.parent.comment;
if (comment) {
let tag = comment.getTag('typeparam', reflection.name);
if (!tag) {
tag = comment.getTag('template', reflection.name);
}
if (!tag) {
tag = comment.getTag('param', `<${reflection.name}>`);
}
Expand Down
3 changes: 3 additions & 0 deletions src/lib/converter/plugins/DeepCommentPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export class DeepCommentPlugin extends ConverterComponent {
let tag: CommentTag | undefined;
if (reflection instanceof TypeParameterReflection) {
tag = target.comment.getTag('typeparam', reflection.name);
if (!tag) {
tag = target.comment.getTag('template', reflection.name);
}
if (!tag) {
tag = target.comment.getTag('param', '<' + reflection.name + '>');
}
Expand Down
8 changes: 8 additions & 0 deletions src/test/converter/function/generic-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ function functionWithGenericArrayParameter<T>(param: T, params: T[]): T[] {
return params;
}

/**
* @param param this describes param
* @template T this describes T
*/
function functionWithTemplate<T>(param: T): T {
return param;
}

export {};
Loading

0 comments on commit c015fd9

Please sign in to comment.