From 16452c8e0c644fa979270e99906eb9c34a13ca5f Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Fri, 2 Mar 2018 22:21:22 +0100 Subject: Make order of comment tags customizable Fix #55 --- src/Lang/Cpp/CppDocGen.ts | 74 ++++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 29 deletions(-) (limited to 'src/Lang/Cpp/CppDocGen.ts') diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts index 1a03430..56ce922 100644 --- a/src/Lang/Cpp/CppDocGen.ts +++ b/src/Lang/Cpp/CppDocGen.ts @@ -247,9 +247,6 @@ export class CppDocGen implements IDocGen { protected insertBrief(lines: string[]) { if (this.cfg.Generic.briefTemplate.trim().length !== 0) { this.generateBrief(lines); - if (this.cfg.Generic.newLineAfterBrief === true) { - lines.push(this.cfg.C.commentPrefix); - } } } @@ -270,6 +267,10 @@ export class CppDocGen implements IDocGen { this.insertBrief(lines); break; } + case "empty": { + lines.push(this.cfg.C.commentPrefix); + break; + } case "file": { this.generateFilenameFromTemplate(lines); break; @@ -298,33 +299,48 @@ export class CppDocGen implements IDocGen { this.insertFirstLine(lines); - this.insertBrief(lines); - - if (this.cfg.Cpp.tparamTemplate.trim().length !== 0 && this.templateParams.length > 0) { - this.generateFromTemplate( - lines, - this.cfg.paramTemplateReplace, - this.cfg.Cpp.tparamTemplate, - this.templateParams, - ); - if (this.cfg.Cpp.newLineAfterTParams === true) { - lines.push(this.cfg.C.commentPrefix); - } - } - - if (this.cfg.Generic.paramTemplate.trim().length !== 0 && this.params.length > 0) { - const paramNames: string[] = this.params.map((p) => p.name); - this.generateFromTemplate(lines, this.cfg.paramTemplateReplace, this.cfg.Generic.paramTemplate, paramNames); - if (this.cfg.Generic.newLineAfterParams === true) { - lines.push(this.cfg.C.commentPrefix); + this.cfg.Generic.order.forEach((element) => { + switch (element) { + case "brief": { + this.insertBrief(lines); + break; + } + case "empty": { + lines.push(this.cfg.C.commentPrefix); + break; + } + case "tparam": { + if (this.cfg.Cpp.tparamTemplate.trim().length !== 0 && this.templateParams.length > 0) { + this.generateFromTemplate( + lines, + this.cfg.paramTemplateReplace, + this.cfg.Cpp.tparamTemplate, + this.templateParams, + ); + } + break; + } + case "param": { + if (this.cfg.Generic.paramTemplate.trim().length !== 0 && this.params.length > 0) { + const paramNames: string[] = this.params.map((p) => p.name); + // tslint:disable-next-line:max-line-length + this.generateFromTemplate(lines, this.cfg.paramTemplateReplace, this.cfg.Generic.paramTemplate, paramNames); + } + break; + } + case "return": { + if (this.cfg.Generic.returnTemplate.trim().length !== 0 && this.func.type !== null) { + const returnParams = this.generateReturnParams(); + // tslint:disable-next-line:max-line-length + this.generateFromTemplate(lines, this.cfg.typeTemplateReplace, this.cfg.Generic.returnTemplate, returnParams); + } + break; + } + default: { + break; + } } - } - - if (this.cfg.Generic.returnTemplate.trim().length !== 0 && this.func.type !== null) { - const returnParams = this.generateReturnParams(); - // tslint:disable-next-line:max-line-length - this.generateFromTemplate(lines, this.cfg.typeTemplateReplace, this.cfg.Generic.returnTemplate, returnParams); - } + }); this.insertLastLine(lines); -- cgit v1.2.3