summaryrefslogtreecommitdiffstats
path: root/src/Lang/Cpp
diff options
context:
space:
mode:
authorto-s <tobias.weber@enisyst.de>2020-10-19 12:38:51 -0400
committerGitHub <noreply@github.com>2020-10-19 18:38:51 +0200
commit771d246a96cd476fa9fddf600c532a28b2efd93a (patch)
treebd03b4bdec9a6a5bb85baca7ca7d988cde64fe95 /src/Lang/Cpp
parentd629202dd9419569c109475ad9f10405d8ab0d22 (diff)
downloaddoxdocgen-771d246a96cd476fa9fddf600c532a28b2efd93a.tar.gz
Substitute author and email by git config (#186)
* Substitute author and email by git config * Upgraded version of typescript Due to https://github.com/cschlosser/doxdocgen/pull/186#discussion_r505813068 * Moved to CppDocGen.generateAuthorTag() Due to https://github.com/cschlosser/doxdocgen/pull/186#discussion_r505819542 * Update README.md Due to https://github.com/cschlosser/doxdocgen/pull/186#discussion_r505822908 * Update TestSetup.ts * Added tests * Changed return type to string Due to https://ci.appveyor.com/project/cschlosser/doxdocgen/builds/35818180#L566 Co-authored-by: Christoph Schlosser <2466365+cschlosser@users.noreply.github.com>
Diffstat (limited to 'src/Lang/Cpp')
-rw-r--r--src/Lang/Cpp/CppDocGen.ts21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts
index 2795ec6..bc9f09a 100644
--- a/src/Lang/Cpp/CppDocGen.ts
+++ b/src/Lang/Cpp/CppDocGen.ts
@@ -3,6 +3,7 @@ import * as moment from "moment";
import { Position, Range, Selection, TextEditor } from "vscode";
import { IDocGen } from "../../Common/IDocGen";
import { Config } from "../../Config";
+import GitConfig from "../../GitConfig";
import { CppArgument } from "./CppArgument";
import * as CppParser from "./CppParser";
import { CppToken, CppTokenType } from "./CppToken";
@@ -47,6 +48,8 @@ export class CppDocGen implements IDocGen {
protected vscodeAutoGeneratedComment: boolean;
+ private gitConfig;
+
/**
* @param {TextEditor} actEdit Active editor window
* @param {Position} cursorPosition Where the cursor of the user currently is
@@ -84,8 +87,9 @@ export class CppDocGen implements IDocGen {
/**
* @inheritdoc
*/
- public GenerateDoc(rangeToReplace: Range) {
+ public GenerateDoc(rangeToReplace: Range, gitConfig: GitConfig) {
let comment: string = "";
+ this.gitConfig = gitConfig;
if (this.commentType === CommentType.file) {
comment = this.generateFileDescription();
} else if (this.commentType === CommentType.method) {
@@ -291,13 +295,26 @@ export class CppDocGen implements IDocGen {
}
protected generateAuthorTag(lines: string[]) {
+ let authorName: string = this.cfg.Generic.authorName;
+ let authorEmail: string = this.cfg.Generic.authorEmail;
+
+ // Check if set to use the git username
+ if (this.cfg.Generic.useGitUserName === true) {
+ authorName = this.gitConfig.UserName;
+ }
+
+ // Check if set to use the git email
+ if (this.cfg.Generic.useGitUserEmail === true) {
+ authorEmail = this.gitConfig.UserEmail;
+ }
+
if (this.cfg.Generic.authorTag.trim().length !== 0) {
// Allow substitution of {author} and {email} only
lines.push(
...this.getMultiTemplatedString(
[this.cfg.authorTemplateReplace, this.cfg.emailTemplateReplace],
this.cfg.Generic.authorTag,
- [this.cfg.Generic.authorName, this.cfg.Generic.authorEmail],
+ [authorName, authorEmail],
).split("\n"),
);
}