From 1746f21bc3720585d2fe877db8d69aae301ff02c Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Sun, 31 Dec 2017 02:03:08 +0100 Subject: -- Added many unit tests for the C parser. Almost complete now -- Refactored project structure to allow for more overview once we add more languages. -- Renamed a lot of types in the CParser to be more explicit. -- Made configuration injectable into the classes that need them. This allows to unit test configuration variables. -- Added 2 new config params that allows to customize what gets returned for a bool return type. -- Small changes to the logic to make it more concise. --- src/Config.ts | 57 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 16 deletions(-) (limited to 'src/Config.ts') diff --git a/src/Config.ts b/src/Config.ts index 3cc78fb..6297a66 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -1,18 +1,43 @@ -export enum ConfigType { - generic = "doxdocgen.generic", -} +import { workspace } from "vscode"; + +export class Config { + public static ImportFromSettings(): Config { + const values: Config = new Config(); + + const cfg = workspace.getConfiguration("doxdocgen.generic"); + + values.firstLine = cfg.get("firstLine", values.firstLine); + values.commentPrefix = cfg.get("commentPrefix", values.commentPrefix); + values.lastLine = cfg.get("lastLine", values.lastLine); + values.newLineAfterBrief = cfg.get("newLineAfterBrief", values.newLineAfterBrief); + values.newLineAfterParams = cfg.get("newLineAfterParams", values.newLineAfterParams); + values.newLineAfterTParams = cfg.get("newLineAfterTParams", values.newLineAfterTParams); + values.includeTypeAtReturn = cfg.get("includeTypeAtReturn", values.includeTypeAtReturn); + values.boolReturnsTrueFalse = cfg.get("boolReturnsTrueFalse", values.boolReturnsTrueFalse); + values.boolPointerReturnsNull = cfg.get("boolPointerReturnsNull", values.boolPointerReturnsNull); + values.briefTemplate = cfg.get("briefTemplate", values.briefTemplate); + values.paramTemplate = cfg.get("paramTemplate", values.paramTemplate); + values.tparamTemplate = cfg.get("tparamTemplate", values.tparamTemplate); + values.returnTemplate = cfg.get("returnTemplate", values.returnTemplate); + + return values; + } + + public readonly paramTemplateReplace: string = "{param}"; + public readonly typeTemplateReplace: string = "{type}"; -export enum Config { - triggerSequence = "triggerSequence", - firstLine = "firstLine", - commentPrefix = "commentPrefix", - lastLine = "lastLine", - newLineAfterBrief = "newLineAfterBrief", - newLineAfterParams = "newLineAfterParams", - newLineAfterTParams = "newLineAfterTParams", - includeTypeAtReturn = "includeTypeAtReturn", - briefTemplate = "briefTemplate", - paramTemplate = "paramTemplate", - tparamTemplate = "tparamTemplate", - returnTemplate = "returnTemplate", + public triggerSequence: string = "/**"; + public firstLine: string = "/**"; + public commentPrefix: string = " * "; + public lastLine: string = " */"; + public newLineAfterBrief: boolean = true; + public newLineAfterParams: boolean = false; + public newLineAfterTParams: boolean = false; + public includeTypeAtReturn: boolean = true; + public boolReturnsTrueFalse: boolean = true; + public boolPointerReturnsNull: boolean = true; + public briefTemplate: string = "@brief "; + public paramTemplate: string = "@param {param} "; + public tparamTemplate: string = "@tparam {param} "; + public returnTemplate: string = "@return {type} "; } -- cgit v1.2.3