From aeb67cd13dcf5e5b69898dff6c05c605a81827f4 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Fri, 2 Mar 2018 23:24:50 +0100 Subject: Add brief template --- package.json | 2 +- src/Config.ts | 3 ++- src/Lang/Cpp/CppDocGen.ts | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 1b89a55..3b4410a 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ "doxdocgen.generic.briefTemplate": { "description": "The template of the brief DoxyGen line that is generated. If empty it won't get generated at all.", "type": "string", - "default": "@brief " + "default": "@brief {text}" }, "doxdocgen.generic.paramTemplate": { "description": "The template of the param DoxyGen line(s) that are generated. If empty it won't get generated at all.", diff --git a/src/Config.ts b/src/Config.ts index 0fcd5a2..a0bae83 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -42,7 +42,7 @@ class Generic { public includeTypeAtReturn: boolean = true; public boolReturnsTrueFalse: boolean = true; - public briefTemplate: string = "@brief "; + public briefTemplate: string = "@brief {text}"; public paramTemplate: string = "@param {param} "; public returnTemplate: string = "@return {type} "; public linesToGet: number = 20; @@ -93,6 +93,7 @@ export class Config { public readonly typeTemplateReplace: string = "{type}"; public readonly nameTemplateReplace: string = "{name}"; public readonly dateTemplateReplace: string = "{date}"; + public readonly textTemplateReplace: string = "{text}"; public C: C; public Cpp: Cpp; diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts index 56ce922..dd4818a 100644 --- a/src/Lang/Cpp/CppDocGen.ts +++ b/src/Lang/Cpp/CppDocGen.ts @@ -162,7 +162,9 @@ export class CppDocGen implements IDocGen { } protected generateBrief(lines: string[]) { - lines.push(this.cfg.C.commentPrefix + this.cfg.Generic.briefTemplate + this.getSmartText()); + lines.push(this.getTemplatedString(this.cfg.textTemplateReplace, + this.cfg.C.commentPrefix + this.cfg.Generic.briefTemplate, + this.getSmartText())); } protected generateFromTemplate(lines: string[], replace: string, template: string, templateWith: string[]) { @@ -365,10 +367,8 @@ export class CppDocGen implements IDocGen { line = baseLine; character = baseCharacter; } - const start = character - this.smartTextLength - 1; - const from: Position = new Position(line, (start > 0 ? start : 0)); const to: Position = new Position(line, character); - this.activeEditor.selection = new Selection(from, to); + this.activeEditor.selection = new Selection(to, to); } protected splitCasing(text: string): string { -- cgit v1.2.3