From 4939806ae705953cfc1ca8cf54f20d98e9be9d03 Mon Sep 17 00:00:00 2001 From: Dean Anderson Date: Thu, 27 Sep 2018 16:51:01 -0400 Subject: customTag will supply ISO date format if user configured format empty Added separate templates for author name {author} and email {email} Added method to make multiple template substitutions in a string customTag will now replace {author}, {email}, {date} and {year} templates --- src/Lang/Cpp/CppDocGen.ts | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'src/Lang/Cpp/CppDocGen.ts') diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts index e71d39e..705b72c 100644 --- a/src/Lang/Cpp/CppDocGen.ts +++ b/src/Lang/Cpp/CppDocGen.ts @@ -105,6 +105,18 @@ export class CppDocGen implements IDocGen { return template.replace(replace, param); } + protected getMultiTemplatedString(replace: string[], template: string, param: string[]): string { + // FIXME I find this argument order a bit strange. I would probably have template first + // For each replace entry, attempt to replace it with the corresponding param in the template + for(var i=0;i { this.generateFromTemplate( lines, @@ -246,12 +267,21 @@ export class CppDocGen implements IDocGen { } protected generateCustomTag(lines: string[]) { + let dateFormat: string = "YYYY-MM-DD"; // Default to ISO standard if not defined + if ( this.cfg.Generic.dateFormat.trim().length != 0) { + dateFormat = this.cfg.Generic.dateFormat; // Overwrite with user format + } + // For each line of the customTag this.cfg.File.customTag.forEach((element) => { - this.generateFromTemplate( - lines, - this.cfg.dateTemplateReplace, - element, - [moment().format(this.cfg.Generic.dateFormat)], + // Allow any of date, year, author, email to be replaced + lines.push(this.cfg.C.commentPrefix + + this.getMultiTemplatedString( + [this.cfg.authorTemplateReplace, this.cfg.emailTemplateReplace, + this.cfg.dateTemplateReplace, this.cfg.yearTemplateReplace], + element, + [this.cfg.Generic.authorName, this.cfg.Generic.authorEmail, + moment().format(dateFormat), moment().format("YYYY")] + ) ); }); } -- cgit v1.2.3