summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHO-COOH <42881734+HO-COOH@users.noreply.github.com>2021-04-30 18:43:47 +0800
committerGitHub <noreply@github.com>2021-04-30 12:43:47 +0200
commit9f4f9cd3b6c8f78493d3c1c7c475a7098aebe58c (patch)
treeab9c62a2c06239ea67d221a114e2f5f56adaecb7
parentdbcf5dc87d83ee59fc23e4eaa225a15655d17d2d (diff)
downloaddoxdocgen-9f4f9cd3b6c8f78493d3c1c7c475a7098aebe58c.tar.gz
Fix unexpected return tag on non-functions (#214)
-rw-r--r--.gitignore1
-rw-r--r--src/Lang/Cpp/CppDocGen.ts10
-rw-r--r--src/test/CppTests/Config.test.ts10
3 files changed, 17 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 4b4ec59..8b6ecab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ coverage/
.DS_Store
/npm-debug.log
/.nyc_output/
+package-lock.json \ No newline at end of file
diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts
index bc9f09a..ace05c2 100644
--- a/src/Lang/Cpp/CppDocGen.ts
+++ b/src/Lang/Cpp/CppDocGen.ts
@@ -264,9 +264,6 @@ export class CppDocGen implements IDocGen {
}
protected generateReturnParams(): string[] {
- if (this.cfg.Generic.includeTypeAtReturn === false) {
- return [""];
- }
const params: string[] = [];
@@ -289,6 +286,13 @@ export class CppDocGen implements IDocGen {
params.push(this.cfg.Generic.includeTypeAtReturn === true ? this.func.type.Yield() : "");
} else if (voidReturnIndex === -1 && this.func.type.nodes.length > 0) {
params.push(this.cfg.Generic.includeTypeAtReturn === true ? this.func.type.Yield() : "");
+ } else {
+ if (this.cfg.Generic.includeTypeAtReturn === false) {
+ return [];
+ }
+ }
+ if (this.cfg.Generic.includeTypeAtReturn === false) {
+ return [""];
}
return params;
diff --git a/src/test/CppTests/Config.test.ts b/src/test/CppTests/Config.test.ts
index f39b7d3..ec52c61 100644
--- a/src/test/CppTests/Config.test.ts
+++ b/src/test/CppTests/Config.test.ts
@@ -65,7 +65,7 @@ suite("C++ - Configuration Tests", () => {
+ " * @return bool \n */", result);
});
- test("Disable including return type.", () => {
+ test("Disable including return type on function", () => {
testSetup.cfg = new Config();
testSetup.cfg.Generic.includeTypeAtReturn = false;
@@ -74,6 +74,14 @@ suite("C++ - Configuration Tests", () => {
+ " * @return \n */", result);
});
+ test("Disable including return type on non-function", () => {
+ testSetup.cfg = new Config();
+ testSetup.cfg.Generic.includeTypeAtReturn = false;
+
+ const result = testSetup.SetLine("bool b;").GetResult();
+ assert.strictEqual("/**\n * @brief \n * \n */", result);
+ });
+
test("Newlines after params and tparams but not after brief", () => {
testSetup.cfg = new Config();
testSetup.cfg.Generic.order = ["brief", "tparam", "empty", "param", "empty", "return"];