summaryrefslogtreecommitdiffstats
path: root/src/DocGen
diff options
context:
space:
mode:
authorRowan Goemans <RB.Goemans@student.han.nl>2017-10-15 02:26:22 +0200
committerRowan Goemans <RB.Goemans@student.han.nl>2017-10-15 02:26:22 +0200
commitcc0d69edcd362c1abde9d0005c70d8e3692395bc (patch)
tree2d991729ec43b411dcbde82a4dd0424cdd0b9771 /src/DocGen
parent0ebfa5bd12e529d8febe73c85d3bf48c4d4997e8 (diff)
downloaddoxdocgen-cc0d69edcd362c1abde9d0005c70d8e3692395bc.tar.gz
-- Fixed tslint issues.
-- Added config parameter to add type information to return DoxyGen parameter.
Diffstat (limited to 'src/DocGen')
-rw-r--r--src/DocGen/CGen.ts49
-rw-r--r--src/DocGen/DocGen.ts1
2 files changed, 32 insertions, 18 deletions
diff --git a/src/DocGen/CGen.ts b/src/DocGen/CGen.ts
index 97ba12e..d4a1966 100644
--- a/src/DocGen/CGen.ts
+++ b/src/DocGen/CGen.ts
@@ -9,6 +9,7 @@ export default class CGen implements IDocGen {
protected newLineAfterBrief: boolean;
protected newLineAfterParams: boolean;
protected newLineAfterTParams: boolean;
+ protected includeTypeAtReturn: boolean;
protected briefTemplate: string;
protected paramTemplate: string;
protected tparamTemplate: string;
@@ -29,7 +30,14 @@ export default class CGen implements IDocGen {
* @param {string[]} tparam The template parameter names of the method extracted by the parser.
* @param {string[]} returnVals The return values extracted by the parser
*/
- public constructor(actEdit: TextEditor, cursorPosition: Position, param: string[], tparam: string[], returnVals: string[]) {
+ public constructor(
+ actEdit: TextEditor,
+ cursorPosition:
+ Position,
+ param: string[],
+ tparam: string[],
+ returnVals: string[]
+ ) {
this.activeEditor = actEdit;
this.position = cursorPosition;
this.templateReplaceString = "{param}";
@@ -57,17 +65,20 @@ export default class CGen implements IDocGen {
Implementation
***************************************************************************/
- protected readConfig() {
- this.firstLine = workspace.getConfiguration(ConfigType.generic).get<string>(Config.firstLine, "");
- this.commentPrefix = workspace.getConfiguration(ConfigType.generic).get<string>(Config.commentPrefix, "");
- this.lastLine = workspace.getConfiguration(ConfigType.generic).get<string>(Config.lastLine, "");
- this.newLineAfterBrief = workspace.getConfiguration(ConfigType.generic).get<boolean>(Config.newLineAfterBrief, true);
- this.newLineAfterParams = workspace.getConfiguration(ConfigType.generic).get<boolean>(Config.newLineAfterParams, false);
- this.newLineAfterTParams = workspace.getConfiguration(ConfigType.generic).get<boolean>(Config.newLineAfterTParams, false);
- this.briefTemplate = workspace.getConfiguration(ConfigType.generic).get<string>(Config.briefTemplate, "");
- this.paramTemplate = workspace.getConfiguration(ConfigType.generic).get<string>(Config.paramTemplate, "");
- this.tparamTemplate = workspace.getConfiguration(ConfigType.generic).get<string>(Config.tparamTemplate, "");
- this.returnTemplate = workspace.getConfiguration(ConfigType.generic).get<string>(Config.returnTemplate, "");
+ protected readConfig() {
+ const getCfg = workspace.getConfiguration;
+
+ this.firstLine = getCfg(ConfigType.generic).get<string>(Config.firstLine, "");
+ this.commentPrefix = getCfg(ConfigType.generic).get<string>(Config.commentPrefix, "");
+ this.lastLine = getCfg(ConfigType.generic).get<string>(Config.lastLine, "");
+ this.newLineAfterBrief = getCfg(ConfigType.generic).get<boolean>(Config.newLineAfterBrief, true);
+ this.newLineAfterParams = getCfg(ConfigType.generic).get<boolean>(Config.newLineAfterParams, false);
+ this.newLineAfterTParams = getCfg(ConfigType.generic).get<boolean>(Config.newLineAfterTParams, false);
+ this.includeTypeAtReturn = getCfg(ConfigType.generic).get<boolean>(Config.includeTypeAtReturn, false);
+ this.briefTemplate = getCfg(ConfigType.generic).get<string>(Config.briefTemplate, "");
+ this.paramTemplate = getCfg(ConfigType.generic).get<string>(Config.paramTemplate, "");
+ this.tparamTemplate = getCfg(ConfigType.generic).get<string>(Config.tparamTemplate, "");
+ this.returnTemplate = getCfg(ConfigType.generic).get<string>(Config.returnTemplate, "");
}
protected getIndentation(): string {
@@ -105,11 +116,11 @@ export default class CGen implements IDocGen {
protected generateComment(): string {
let lines: string[] = [];
-
+
if (this.firstLine.trim().length !== 0) {
lines.push(this.firstLine);
}
-
+
if (this.briefTemplate.trim().length !== 0) {
this.generateBrief(lines);
if (this.newLineAfterBrief === true) {
@@ -132,11 +143,15 @@ export default class CGen implements IDocGen {
}
if (this.returnTemplate.trim().length !== 0 && this.retVals.length > 0) {
+ if (this.includeTypeAtReturn === false) {
+ this.retVals = this.retVals.map(t => t === "true" || t === "false" ? t : "");
+ }
+
this.generateFromTemplate(lines, this.returnTemplate, this.retVals);
}
if (this.lastLine.trim().length !== 0) {
- lines.push(this.lastLine);
+ lines.push(this.lastLine);
}
const comment: string = lines.join("\n" + this.getIndentation());
@@ -148,9 +163,9 @@ export default class CGen implements IDocGen {
if (this.firstLine.trim().length !== 0) {
line++;
}
-
+
character += this.commentPrefix.length + this.briefTemplate.length;
-
+
const move: Selection = new Selection(line, character, line, character);
this.activeEditor.selection = move;
}
diff --git a/src/DocGen/DocGen.ts b/src/DocGen/DocGen.ts
index 40ea205..1b5b1e1 100644
--- a/src/DocGen/DocGen.ts
+++ b/src/DocGen/DocGen.ts
@@ -1,6 +1,5 @@
import { Range } from "vscode";
-
export interface IDocGen {
/**
* @brief Generate documentation string and write it to the active editor