summaryrefslogtreecommitdiffstats
path: root/src/Lang/Cpp/CppDocGen.ts
diff options
context:
space:
mode:
authorChristoph Schlosser <2466365+cschlosser@users.noreply.github.com>2020-10-04 13:38:20 +0200
committerGitHub <noreply@github.com>2020-10-04 13:38:20 +0200
commit175bd0d5bb123a99f7de91d6045a0a25f670dd65 (patch)
treeb9bdf29f7a9af9b9d1cfceb55d1ace265176bc9e /src/Lang/Cpp/CppDocGen.ts
parent6a541f4882e62bd37c37bb20962414d5e31d79a4 (diff)
downloaddoxdocgen-1.0.0.tar.gz
Release 1.0.0 (#180)1.0.0
* Reenable: Add env-var to replace env var in template strings (#175) * Release 1.0.0 * Add ls output to travis package step to see size of vsix
Diffstat (limited to 'src/Lang/Cpp/CppDocGen.ts')
-rw-r--r--src/Lang/Cpp/CppDocGen.ts36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts
index 1e73804..2795ec6 100644
--- a/src/Lang/Cpp/CppDocGen.ts
+++ b/src/Lang/Cpp/CppDocGen.ts
@@ -1,10 +1,10 @@
+import * as env from "env-var";
import * as moment from "moment";
-import { Position, Range, Selection, TextEditor, TextLine, WorkspaceEdit } from "vscode";
+import { Position, Range, Selection, TextEditor } from "vscode";
import { IDocGen } from "../../Common/IDocGen";
import { Config } from "../../Config";
import { CppArgument } from "./CppArgument";
import * as CppParser from "./CppParser";
-import { CppParseTree } from "./CppParseTree";
import { CppToken, CppTokenType } from "./CppToken";
export enum SpecialCase {
@@ -144,9 +144,31 @@ export class CppDocGen implements IDocGen {
return indentedString;
}
+ protected getEnvVars(replace: string): string {
+ let replacement = replace;
+ const regex = /\$\{env\:([\w|\d|_]+)\}/m;
+ let match: RegExpExecArray;
+
+ // tslint:disable-next-line:no-conditional-assignment
+ while ((match = regex.exec(replacement)) !== null) {
+ if (match.index === regex.lastIndex) {
+ regex.lastIndex++;
+ }
+
+ const m = match[1];
+
+ const envVar: string = env.get(m, m).asString();
+
+ replacement = replacement.replace("${env:" + m + "}", envVar);
+ }
+
+ return replacement;
+ }
+
protected getTemplatedString(replace: string, template: string, param: string): string {
const replacedTemplate = template.replace(replace, param);
- return this.getIndentedTemplate(replacedTemplate);
+ const replacedWithEnv = this.getEnvVars(replacedTemplate);
+ return this.getIndentedTemplate(replacedWithEnv);
}
protected getMultiTemplatedString(replace: string[], template: string, param: string[]): string {
@@ -156,7 +178,7 @@ export class CppDocGen implements IDocGen {
template = template.replace(replace[i], param[i]);
}
}
- return template;
+ return this.getEnvVars(template);
}
protected getSmartText(): string {
@@ -453,13 +475,15 @@ export class CppDocGen implements IDocGen {
lines,
this.cfg.typeTemplateReplace,
this.cfg.Generic.returnTemplate,
- returnParams
+ returnParams,
);
}
break;
}
case "custom": {
- lines.push(...this.cfg.Generic.customTags);
+ this.cfg.Generic.customTags.forEach((elem) => {
+ lines.push(this.getEnvVars(elem));
+ });
break;
}
default: {