From 15dcabb5903b68bbc8b490b1d0e220d13acf63b7 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser <2466365+cschlosser@users.noreply.github.com> Date: Sat, 3 Oct 2020 17:15:04 +0200 Subject: Add custom tags to generic order (#173) --- src/Config.ts | 2 ++ src/Lang/Cpp/CppDocGen.ts | 12 ++++++++++-- src/test/CppTests/Config.test.ts | 8 ++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Config.ts b/src/Config.ts index 1d942a1..51aebc3 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -57,6 +57,7 @@ class Generic { public generateSmartText: boolean = true; public splitCasingSmartText: boolean = true; public order: string[] = ["brief", "empty", "tparam", "param", "return"]; + public customTags: string[] = []; public filteredKeywords: string[] = []; } @@ -96,6 +97,7 @@ export class Config { values.Generic.generateSmartText = Generic.getConfiguration().get("generateSmartText", values.Generic.generateSmartText); values.Generic.splitCasingSmartText = Generic.getConfiguration().get("splitCasingSmartText", values.Generic.splitCasingSmartText); values.Generic.order = Generic.getConfiguration().get("order", values.Generic.order); + values.Generic.customTags = Generic.getConfiguration().get("customTags", values.Generic.customTags); values.Generic.filteredKeywords = Generic.getConfiguration().get("filteredKeywords", values.Generic.filteredKeywords); return values; diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts index 7be7da9..1e73804 100644 --- a/src/Lang/Cpp/CppDocGen.ts +++ b/src/Lang/Cpp/CppDocGen.ts @@ -449,11 +449,19 @@ export class CppDocGen implements IDocGen { case "return": { if (this.cfg.Generic.returnTemplate.trim().length !== 0 && this.func.type !== null) { const returnParams = this.generateReturnParams(); - // tslint:disable-next-line:max-line-length - this.generateFromTemplate(lines, this.cfg.typeTemplateReplace, this.cfg.Generic.returnTemplate, returnParams); + this.generateFromTemplate( + lines, + this.cfg.typeTemplateReplace, + this.cfg.Generic.returnTemplate, + returnParams + ); } break; } + case "custom": { + lines.push(...this.cfg.Generic.customTags); + break; + } default: { break; } diff --git a/src/test/CppTests/Config.test.ts b/src/test/CppTests/Config.test.ts index 1769414..3915f11 100644 --- a/src/test/CppTests/Config.test.ts +++ b/src/test/CppTests/Config.test.ts @@ -219,4 +219,12 @@ suite("C++ - Configuration Tests", () => { assert.equal("/**\n * @brief \n * \n * @param networkstatus \n */", result); }); + test("Custom tag", () => { + testSetup.cfg = new Config(); + testSetup.cfg.Generic.order = ["custom"]; + testSetup.cfg.Generic.customTags = ["@note"]; + const result = testSetup.SetLine("void foo();").GetResult(); + assert.equal("/**\n * @note\n */", result); + }); + }); -- cgit v1.2.3