summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHO-COOH <42881734+HO-COOH@users.noreply.github.com>2021-05-29 18:20:50 +0800
committerGitHub <noreply@github.com>2021-05-29 12:20:50 +0200
commitaa21a82e8b7dca30e3650d164c6fcb3bb495b17e (patch)
tree8feec05acebe434c31fad0ae44ba718e197b18d7 /src
parent638cfe09c56b8e75cf3dfa77652f51312766bd36 (diff)
downloaddoxdocgen-aa21a82e8b7dca30e3650d164c6fcb3bb495b17e.tar.gz
fix indent not expanded in file comments (#236)
Diffstat (limited to 'src')
-rw-r--r--src/DoxygenCompletionItemProvider.ts2
-rw-r--r--src/Lang/Cpp/CppDocGen.ts2
-rw-r--r--src/templatedString.ts2
-rw-r--r--src/test/CppTests/Config.test.ts28
4 files changed, 30 insertions, 4 deletions
diff --git a/src/DoxygenCompletionItemProvider.ts b/src/DoxygenCompletionItemProvider.ts
index 660fa14..bc54c93 100644
--- a/src/DoxygenCompletionItemProvider.ts
+++ b/src/DoxygenCompletionItemProvider.ts
@@ -14,7 +14,7 @@ export default class DoxygenCompletionItemProvider implements vscode.CompletionI
["arg", "${1:item-description}", "Generate a simple, non-nested list of arguments"],
["b", "${1:word}", "Display `<word>` in bold"],
["c", "${1:word}", "Display `<word>` using a typewriter font"],
- ["code", "${1:language-id}\n${2:code}\n@endcode", "Starts a block of code"], // TODO: match end block symbol with trigger character
+ ["code", "{.${1:language-id}}\n${2:code}\n@endcode", "Starts a block of code"], // TODO: match end block symbol with trigger character
["copydoc", "${1:link-object}", "Copy a documentation block from the object specified by `<link-object>` and paste it at the location of the command. The link object can point to a member (of a class, file or group), a class, a namespace, a group, a page, or a file. If the member is overloaded, you should specify the argument types explicitly"],
["copybrief", "${1:link-object}", "Work in a similar way as `@copydoc` but will only copy the brief description, not the detailed documentation"],
["copydetails", "${1:link-object}", "Work in a similar way as `@copydoc` but will only copy the detailed documentation, not the brief description"],
diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts
index c0113ad..022b372 100644
--- a/src/Lang/Cpp/CppDocGen.ts
+++ b/src/Lang/Cpp/CppDocGen.ts
@@ -250,7 +250,7 @@ export class CppDocGen implements IDocGen {
protected generateVersionTag(lines: string[]) {
if (this.cfg.File.versionTag.trim().length !== 0) {
- lines.push(...this.cfg.File.versionTag.split("\n"));
+ lines.push(...templates.getIndentedTemplate(this.cfg.File.versionTag).split("\n"));
}
}
diff --git a/src/templatedString.ts b/src/templatedString.ts
index c397ad9..cdc40e0 100644
--- a/src/templatedString.ts
+++ b/src/templatedString.ts
@@ -80,5 +80,5 @@ export function getMultiTemplatedString(
for (const template of templates) {
original = original.replace(template.toReplace, template.with);
}
- return getEnvVars(original);
+ return getEnvVars(getIndentedTemplate(original));
}
diff --git a/src/test/CppTests/Config.test.ts b/src/test/CppTests/Config.test.ts
index f6ec573..5c92fa6 100644
--- a/src/test/CppTests/Config.test.ts
+++ b/src/test/CppTests/Config.test.ts
@@ -93,7 +93,7 @@ suite("C++ - Configuration Tests", () => {
+ " * @return true \n * @return false \n */");
});
- test("Indentation test", () => {
+ test("Function comment indentation test", () => {
testSetup.cfg = new Config();
let result = testSetup.SetLine("\ttemplate<typename T> bool foo(T a);").GetResult();
assert.strictEqual(result, "/**\n\t * @brief \n\t * \n\t * @tparam T \n\t * @param a \n\t * "
@@ -105,6 +105,32 @@ suite("C++ - Configuration Tests", () => {
+ "@return true \n * @return false \n */");
});
+ test("File comment indentation test", () => {
+ testSetup.cfg.File.fileOrder = [
+ "file",
+ "author",
+ "brief",
+ "version",
+ "date",
+ "copyright",
+ ];
+ testSetup.cfg.File.fileTemplate = "@file{indent:10}{name}";
+ testSetup.cfg.Generic.authorTag = "@author{indent:10}{author}";
+ testSetup.cfg.Generic.briefTemplate = "@brief{indent:10}Thing";
+ testSetup.cfg.File.versionTag = "@version{indent:10}0.1";
+ testSetup.cfg.Generic.dateTemplate = "@date{indent:10}date";
+ testSetup.cfg.File.copyrightTag = ["@copyright{indent:10}Copyright(c)"];
+ const result = testSetup.SetLine("").GetResult();
+ assert.strictEqual(result, `/**
+ * @file MockDocument.h
+ * @author your name
+ * @brief Thing
+ * @version 0.1
+ * @date date
+ * @copyrightCopyright(c)
+ */`);
+ });
+
test("Lines to get test", () => {
testSetup.cfg = new Config();
testSetup.cfg.Generic.linesToGet = 2;