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) --- CHANGELOG.md | 4 ++++ README.md | 6 +++++- package.json | 12 +++++++++++- src/Config.ts | 2 ++ src/Lang/Cpp/CppDocGen.ts | 12 ++++++++++-- src/test/CppTests/Config.test.ts | 8 ++++++++ 6 files changed, 40 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1c6992..552b4bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [UNRELEASED] +### Feature + +- Support for arbitrary tags (#169) + ### Fix - Incorrect parameter name of template (#170) diff --git a/README.md b/README.md index 24de003..fcb6f08 100644 --- a/README.md +++ b/README.md @@ -199,9 +199,13 @@ Each of them can be configured with its own custom text and you can decide if th "empty", "tparam", "param", - "return" + "return", + "custom" ], + // Custom tags to be added to the generic order. One tag per line will be added. You have to specify the prefix yourself. + "doxdocgen.generic.customTags": [], + // The template of the param Doxygen line(s) that are generated. If empty it won't get generated at all. "doxdocgen.generic.paramTemplate": "@param {param} ", diff --git a/package.json b/package.json index ec2301a..a596b10 100644 --- a/package.json +++ b/package.json @@ -214,7 +214,17 @@ "empty", "tparam", "param", - "return" + "return", + "custom" + ] + }, + "doxdocgen.generic.customTags": { + "description": "Custom tags to be added to the generic order. One tag per line will be added. You have to specify the prefix yourself.", + "type": [ + "array", + "string" + ], + "default": [ ] }, "doxdocgen.generic.filteredKeywords": { 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