Skip to content

Commit

Permalink
Release 1.0.0 (#180)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
cschlosser authored Oct 4, 2020
1 parent 6a541f4 commit 175bd0d
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 13 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ jobs:
os: osx
- stage: release
script:
- npm install vsce@1.31.0
- vsce package
- npm install vsce
- vsce package --no-yarn
- ls -alh
os: linux
deploy:
- provider: releases
Expand All @@ -53,7 +54,7 @@ jobs:
on:
tags: true
- provider: script
script: vsce publish -p $VSMARKETPLACE_ACCESS_TOKEN
script: vsce publish --no-yarn -p $VSMARKETPLACE_ACCESS_TOKEN
skip_cleanup: true
on:
tags: true
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## [1.0.0]

### Revert

- Revert reverting Replace environment variables in templated strings. If no environment variable can be found the name of the variable will be inserted (#110)

### Other

- vsce packaging is forcing yarn even if no yarn config exists. Override this behavior now to use npm.

## [0.8.2]

### Other
Expand Down
15 changes: 14 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "doxdocgen",
"displayName": "Doxygen Documentation Generator",
"description": "Let me generate Doxygen documentation from your source code for you.",
"version": "0.8.2",
"version": "1.0.0",
"publisher": "cschlosser",
"engines": {
"vscode": "^1.37.0"
Expand Down Expand Up @@ -253,6 +253,7 @@
"test": "npm run compile && node ./node_modules/vscode/bin/test"
},
"dependencies": {
"env-var": "^4.1.0",
"moment": "^2.20.1",
"opn": "^5.2.0"
},
Expand Down
36 changes: 30 additions & 6 deletions src/Lang/Cpp/CppDocGen.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import * as vscode from "vscode";
import CodeParserController from "./CodeParserController";

enum Version {
CURRENT = "0.8.2",
PREVIOUS = "0.8.1",
CURRENT = "1.0.0",
PREVIOUS = "0.8.2",
KEY = "doxdocgen_version",
}

Expand Down
20 changes: 20 additions & 0 deletions src/test/CppTests/Config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,24 @@ suite("C++ - Configuration Tests", () => {
assert.equal("/**\n * @note\n */", result);
});

test("Env variable", () => {
testSetup.cfg = new Config();
testSetup.cfg.Generic.order = ["custom"];
if (process.platform === "win32") {
testSetup.cfg.Generic.customTags = ["@author ${env:USERNAME}"];
const res = testSetup.SetLine("void foo();").GetResult();
// USERNAME env var is different for everybody
assert.notEqual("/**\n * @author USERNAME\n */", res);
} else {
testSetup.cfg.Generic.customTags = ["@author ${env:USER}"];
const res = testSetup.SetLine("void foo();").GetResult();
// USER env var is different for everybody
assert.notEqual("/**\n * @author USER\n */", res);
}

testSetup.cfg.Generic.customTags = ["@author ${env:MY_VARIABLE}"];
const result = testSetup.SetLine("void foo();").GetResult();
assert.equal("/**\n * @author MY_VARIABLE\n */", result);
});

});

0 comments on commit 175bd0d

Please sign in to comment.