From d78b9876918ce8d65876968ee120b2144178af32 Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Sun, 15 Oct 2017 13:23:50 +0200 Subject: -- Fixed various issues that came out of the pull request review. --- package.json | 8 ++++---- src/Config.ts | 2 +- src/DocGen/CGen.ts | 38 ++++++++++++++++++++------------------ 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 5d97618..01e9ad7 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "type": "string", "default": "/**" }, - "doxdocgen.generic.commentPrefix": { + "doxdocgen.generic.prefix": { "description": "The pre fix that is used for each comment line.", "type": "string", "default": " * " @@ -36,7 +36,7 @@ "doxdocgen.generic.lastLine": { "description": "The last line of the comment that gets generated. If empty it won't get generated at all.", "type": "string", - "default": "**/" + "default": " */" }, "doxdocgen.generic.newLineAfterBrief": { "description": "Whether to insert a newline after a brief.", @@ -56,7 +56,7 @@ "doxdocgen.generic.includeTypeAtReturn": { "description": "Whether include type information at return.", "type": "boolean", - "default": false + "default": true }, "doxdocgen.generic.briefTemplate": { "description": "The template of the brief DoxyGen line that is generated. If empty it won't get generated at all.", @@ -76,7 +76,7 @@ "doxdocgen.generic.returnTemplate": { "description": "The template of the return DoxyGen line that is generated. If empty it won't get generated at all.", "type": "string", - "default": "@return {param} " + "default": "@return {type} " } } } diff --git a/src/Config.ts b/src/Config.ts index 3cc78fb..0b9e593 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -5,7 +5,7 @@ export enum ConfigType { export enum Config { triggerSequence = "triggerSequence", firstLine = "firstLine", - commentPrefix = "commentPrefix", + prefix = "prefix", lastLine = "lastLine", newLineAfterBrief = "newLineAfterBrief", newLineAfterParams = "newLineAfterParams", diff --git a/src/DocGen/CGen.ts b/src/DocGen/CGen.ts index edeb152..26d5754 100644 --- a/src/DocGen/CGen.ts +++ b/src/DocGen/CGen.ts @@ -4,7 +4,7 @@ import { IDocGen } from "./DocGen"; export default class CGen implements IDocGen { protected firstLine: string; - protected commentPrefix: string; + protected prefix: string; protected lastLine: string; protected newLineAfterBrief: boolean; protected newLineAfterParams: boolean; @@ -15,7 +15,8 @@ export default class CGen implements IDocGen { protected tparamTemplate: string; protected returnTemplate: string; - protected templateReplaceString: string; + protected templateParamReplace: string; + protected templateTypeReplace: string; protected activeEditor: TextEditor; @@ -38,7 +39,8 @@ export default class CGen implements IDocGen { returnVals: string[], ) { this.activeEditor = actEdit; - this.templateReplaceString = "{param}"; + this.templateParamReplace = "{param}"; + this.templateTypeReplace = "{type}"; this.params = param; this.tparams = tparam; this.retVals = returnVals; @@ -67,8 +69,8 @@ export default class CGen implements IDocGen { const getCfg = workspace.getConfiguration; this.firstLine = getCfg(ConfigType.generic).get(Config.firstLine, "/**"); - this.commentPrefix = getCfg(ConfigType.generic).get(Config.commentPrefix, " * "); - this.lastLine = getCfg(ConfigType.generic).get(Config.lastLine, "**/"); + this.prefix = getCfg(ConfigType.generic).get(Config.prefix, " * "); + this.lastLine = getCfg(ConfigType.generic).get(Config.lastLine, " */"); this.newLineAfterBrief = getCfg(ConfigType.generic).get(Config.newLineAfterBrief, true); this.newLineAfterParams = getCfg(ConfigType.generic).get(Config.newLineAfterParams, false); this.newLineAfterTParams = getCfg(ConfigType.generic).get(Config.newLineAfterTParams, false); @@ -76,7 +78,7 @@ export default class CGen implements IDocGen { this.briefTemplate = getCfg(ConfigType.generic).get(Config.briefTemplate, "@brief "); this.paramTemplate = getCfg(ConfigType.generic).get(Config.paramTemplate, "@param {param} "); this.tparamTemplate = getCfg(ConfigType.generic).get(Config.tparamTemplate, "@tparam {param} "); - this.returnTemplate = getCfg(ConfigType.generic).get(Config.returnTemplate, "@return {param} "); + this.returnTemplate = getCfg(ConfigType.generic).get(Config.returnTemplate, "@return {type} "); } protected getIndentation(): string { @@ -94,20 +96,20 @@ export default class CGen implements IDocGen { return stringToIndent; } - protected getTemplatedString(template: string, param: string): string { - return template.replace(this.templateReplaceString, param); + protected getTemplatedString(replace: string, template: string, param: string): string { + return template.replace(replace, param); } protected generateBrief(lines: string[]) { - lines.push(this.commentPrefix + this.briefTemplate); + lines.push(this.prefix + this.briefTemplate); } - protected generateFromTemplate(lines: string[], template: string, templateWith: string[]) { + protected generateFromTemplate(lines: string[], replace: string, template: string, templateWith: string[]) { let line: string = ""; templateWith.forEach((element: string) => { - line = this.commentPrefix; - line += this.getTemplatedString(template, element); + line = this.prefix; + line += this.getTemplatedString(replace, template, element); lines.push(line); }); } @@ -122,21 +124,21 @@ export default class CGen implements IDocGen { if (this.briefTemplate.trim().length !== 0) { this.generateBrief(lines); if (this.newLineAfterBrief === true) { - lines.push(this.commentPrefix); + lines.push(this.prefix); } } if (this.tparamTemplate.trim().length !== 0 && this.tparams.length > 0) { - this.generateFromTemplate(lines, this.tparamTemplate, this.tparams); + this.generateFromTemplate(lines, this.templateParamReplace, this.tparamTemplate, this.tparams); if (this.newLineAfterTParams === true) { - lines.push(this.commentPrefix); + lines.push(this.prefix); } } if (this.paramTemplate.trim().length !== 0 && this.params.length > 0) { - this.generateFromTemplate(lines, this.paramTemplate, this.params); + this.generateFromTemplate(lines, this.templateParamReplace, this.paramTemplate, this.params); if (this.newLineAfterParams === true) { - lines.push(this.commentPrefix); + lines.push(this.prefix); } } @@ -145,7 +147,7 @@ export default class CGen implements IDocGen { this.retVals = this.retVals.map((t) => t === "true" || t === "false" ? t : ""); } - this.generateFromTemplate(lines, this.returnTemplate, this.retVals); + this.generateFromTemplate(lines, this.templateTypeReplace, this.returnTemplate, this.retVals); } if (this.lastLine.trim().length !== 0) { -- cgit v1.2.3