Skip to content

Commit 175bd0d

Browse files
authored
Release 1.0.0 (#180)
* 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
1 parent 6a541f4 commit 175bd0d

File tree

7 files changed

+82
-13
lines changed

7 files changed

+82
-13
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ jobs:
4242
os: osx
4343
- stage: release
4444
script:
45-
- npm install vsce@1.31.0
46-
- vsce package
45+
- npm install vsce
46+
- vsce package --no-yarn
47+
- ls -alh
4748
os: linux
4849
deploy:
4950
- provider: releases
@@ -53,7 +54,7 @@ jobs:
5354
on:
5455
tags: true
5556
- provider: script
56-
script: vsce publish -p $VSMARKETPLACE_ACCESS_TOKEN
57+
script: vsce publish --no-yarn -p $VSMARKETPLACE_ACCESS_TOKEN
5758
skip_cleanup: true
5859
on:
5960
tags: true

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Change Log
22

3+
## [1.0.0]
4+
5+
### Revert
6+
7+
- Revert reverting Replace environment variables in templated strings. If no environment variable can be found the name of the variable will be inserted (#110)
8+
9+
### Other
10+
11+
- vsce packaging is forcing yarn even if no yarn config exists. Override this behavior now to use npm.
12+
313
## [0.8.2]
414

515
### Other

package-lock.json

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "doxdocgen",
33
"displayName": "Doxygen Documentation Generator",
44
"description": "Let me generate Doxygen documentation from your source code for you.",
5-
"version": "0.8.2",
5+
"version": "1.0.0",
66
"publisher": "cschlosser",
77
"engines": {
88
"vscode": "^1.37.0"
@@ -253,6 +253,7 @@
253253
"test": "npm run compile && node ./node_modules/vscode/bin/test"
254254
},
255255
"dependencies": {
256+
"env-var": "^4.1.0",
256257
"moment": "^2.20.1",
257258
"opn": "^5.2.0"
258259
},

src/Lang/Cpp/CppDocGen.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import * as env from "env-var";
12
import * as moment from "moment";
2-
import { Position, Range, Selection, TextEditor, TextLine, WorkspaceEdit } from "vscode";
3+
import { Position, Range, Selection, TextEditor } from "vscode";
34
import { IDocGen } from "../../Common/IDocGen";
45
import { Config } from "../../Config";
56
import { CppArgument } from "./CppArgument";
67
import * as CppParser from "./CppParser";
7-
import { CppParseTree } from "./CppParseTree";
88
import { CppToken, CppTokenType } from "./CppToken";
99

1010
export enum SpecialCase {
@@ -144,9 +144,31 @@ export class CppDocGen implements IDocGen {
144144
return indentedString;
145145
}
146146

147+
protected getEnvVars(replace: string): string {
148+
let replacement = replace;
149+
const regex = /\$\{env\:([\w|\d|_]+)\}/m;
150+
let match: RegExpExecArray;
151+
152+
// tslint:disable-next-line:no-conditional-assignment
153+
while ((match = regex.exec(replacement)) !== null) {
154+
if (match.index === regex.lastIndex) {
155+
regex.lastIndex++;
156+
}
157+
158+
const m = match[1];
159+
160+
const envVar: string = env.get(m, m).asString();
161+
162+
replacement = replacement.replace("${env:" + m + "}", envVar);
163+
}
164+
165+
return replacement;
166+
}
167+
147168
protected getTemplatedString(replace: string, template: string, param: string): string {
148169
const replacedTemplate = template.replace(replace, param);
149-
return this.getIndentedTemplate(replacedTemplate);
170+
const replacedWithEnv = this.getEnvVars(replacedTemplate);
171+
return this.getIndentedTemplate(replacedWithEnv);
150172
}
151173

152174
protected getMultiTemplatedString(replace: string[], template: string, param: string[]): string {
@@ -156,7 +178,7 @@ export class CppDocGen implements IDocGen {
156178
template = template.replace(replace[i], param[i]);
157179
}
158180
}
159-
return template;
181+
return this.getEnvVars(template);
160182
}
161183

162184
protected getSmartText(): string {
@@ -453,13 +475,15 @@ export class CppDocGen implements IDocGen {
453475
lines,
454476
this.cfg.typeTemplateReplace,
455477
this.cfg.Generic.returnTemplate,
456-
returnParams
478+
returnParams,
457479
);
458480
}
459481
break;
460482
}
461483
case "custom": {
462-
lines.push(...this.cfg.Generic.customTags);
484+
this.cfg.Generic.customTags.forEach((elem) => {
485+
lines.push(this.getEnvVars(elem));
486+
});
463487
break;
464488
}
465489
default: {

src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import * as vscode from "vscode";
55
import CodeParserController from "./CodeParserController";
66

77
enum Version {
8-
CURRENT = "0.8.2",
9-
PREVIOUS = "0.8.1",
8+
CURRENT = "1.0.0",
9+
PREVIOUS = "0.8.2",
1010
KEY = "doxdocgen_version",
1111
}
1212

src/test/CppTests/Config.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,24 @@ suite("C++ - Configuration Tests", () => {
227227
assert.equal("/**\n * @note\n */", result);
228228
});
229229

230+
test("Env variable", () => {
231+
testSetup.cfg = new Config();
232+
testSetup.cfg.Generic.order = ["custom"];
233+
if (process.platform === "win32") {
234+
testSetup.cfg.Generic.customTags = ["@author ${env:USERNAME}"];
235+
const res = testSetup.SetLine("void foo();").GetResult();
236+
// USERNAME env var is different for everybody
237+
assert.notEqual("/**\n * @author USERNAME\n */", res);
238+
} else {
239+
testSetup.cfg.Generic.customTags = ["@author ${env:USER}"];
240+
const res = testSetup.SetLine("void foo();").GetResult();
241+
// USER env var is different for everybody
242+
assert.notEqual("/**\n * @author USER\n */", res);
243+
}
244+
245+
testSetup.cfg.Generic.customTags = ["@author ${env:MY_VARIABLE}"];
246+
const result = testSetup.SetLine("void foo();").GetResult();
247+
assert.equal("/**\n * @author MY_VARIABLE\n */", result);
248+
});
249+
230250
});

0 commit comments

Comments
 (0)