diff options
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | package.json | 10 | ||||
| -rw-r--r-- | src/Config.ts | 2 | ||||
| -rw-r--r-- | src/Lang/Cpp/CppDocGen.ts | 28 |
4 files changed, 35 insertions, 6 deletions
@@ -6,6 +6,7 @@ This VS Code Extensions provides Doxygen Documentation generation on the fly by [](https://ci.appveyor.com/project/christophschlosser/doxdocgen) [](https://codecov.io/gh/christophschlosser/doxdocgen) [](https://gitter.im/doxdocgen) +[](https://isitmaintained.com/project/christophschlosser/doxdocgen "Average time to resolve an issue") ## Table of Contents diff --git a/package.json b/package.json index 324b067..0e19d96 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,11 @@ "url": "https://codecov.io/gh/christophschlosser/doxdocgen/branch/master/graph/badge.svg", "href": "https://codecov.io/gh/christophschlosser/doxdocgen", "description": "Code coverage" + }, + { + "url": "https://isitmaintained.com/badge/resolution/christophschlosser/doxdocgen.svg", + "href": "https://isitmaintained.com/project/christophschlosser/doxdocgen", + "description": "Response time for issues" } ], "activationEvents": [ @@ -176,6 +181,11 @@ "type": "boolean", "default": true }, + "doxdocgen.generic.indentWidth": { + "description": "At how many spaces the documentation should be inserted. Only Valid for param and tparam.", + "type": "number", + "default": 0 + }, "doxdocgen.generic.order": { "description": "The order to use for the comment generation. Values can be used multiple times. Valid values are shown in default setting.", "type": ["array", "string"], diff --git a/src/Config.ts b/src/Config.ts index b33aff2..8c3e723 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -57,6 +57,7 @@ class Generic { public generateSmartText: boolean = true; public splitCasingSmartText: boolean = true; public order: string[] = ["brief", "empty", "tparam", "param", "return"]; + public indentWidth: number = 0; } export class Config { @@ -95,6 +96,7 @@ export class Config { values.Generic.generateSmartText = Generic.getConfiguration().get<boolean>("generateSmartText", values.Generic.generateSmartText); values.Generic.splitCasingSmartText = Generic.getConfiguration().get<boolean>("splitCasingSmartText", values.Generic.splitCasingSmartText); values.Generic.order = Generic.getConfiguration().get<string[]>("order", values.Generic.order); + values.Generic.indentWidth = Generic.getConfiguration().get<number>("indentWidth", values.Generic.indentWidth); return values; } diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts index bc5a355..51a975f 100644 --- a/src/Lang/Cpp/CppDocGen.ts +++ b/src/Lang/Cpp/CppDocGen.ts @@ -119,8 +119,14 @@ export class CppDocGen implements IDocGen { return this.activeEditor.document.lineAt(this.activeEditor.selection.start.line).text.match("^\\s*")[0]; } - protected getTemplatedString(replace: string, template: string, param: string): string { - return template.replace(replace, param); + protected getTemplatedString(replace: string, template: string, param: string, indent: boolean = false): string { + let indentWidth: string = ""; + if (indent === true) { + const numSpaces = Math.max(this.cfg.Generic.indentWidth - param.length, 0); + indentWidth = " ".repeat(numSpaces); + } + const indentedTemplate = template.replace(replace, replace + indentWidth); + return indentedTemplate.replace(replace, param); } protected getMultiTemplatedString(replace: string[], template: string, param: string[]): string { @@ -195,14 +201,18 @@ export class CppDocGen implements IDocGen { this.getSmartText())); } - protected generateFromTemplate(lines: string[], replace: string, template: string, templateWith: string[]) { + protected generateFromTemplate(lines: string[], + replace: string, + template: string, + templateWith: string[], + indent: boolean = false) { let line: string = ""; templateWith.forEach((element: string) => { // Ignore null values if (element !== null) { line = this.cfg.C.commentPrefix; - line += this.getTemplatedString(replace, template, element); + line += this.getTemplatedString(replace, template, element, indent); lines.push(line); } }); @@ -403,6 +413,7 @@ export class CppDocGen implements IDocGen { this.cfg.paramTemplateReplace, this.cfg.Cpp.tparamTemplate, this.templateParams, + true, ); } break; @@ -410,8 +421,13 @@ export class CppDocGen implements IDocGen { 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); + this.generateFromTemplate( + lines, + this.cfg.paramTemplateReplace, + this.cfg.Generic.paramTemplate, + paramNames, + true, + ); } break; } |