summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--package.json17
-rw-r--r--src/Config.ts7
-rw-r--r--src/Lang/Cpp/CppDocGen.ts40
3 files changed, 63 insertions, 1 deletions
diff --git a/package.json b/package.json
index 8e6181a..a6112da 100644
--- a/package.json
+++ b/package.json
@@ -91,10 +91,25 @@
"type": "string",
"default": "@file {name}"
},
+ "doxdocgen.file.copyrightTag": {
+ "description": "File copyright documentation tag.",
+ "type": ["array", "string"],
+ "default": ["@copyright Copyright (c) {year}"]
+ },
+ "doxdocgen.file.versionTag": {
+ "description": "Version number for the file.",
+ "type": "string",
+ "default": "@version 0.1"
+ },
+ "doxdocgen.file.customTag": {
+ "description": "Additional file documentation.",
+ "type": ["array", "string"],
+ "default": []
+ },
"doxdocgen.file.fileOrder": {
"description": "The order to use for the file comment. Values can be used multiple times. Valid values are shown in default setting.",
"type": ["array", "string"],
- "default": ["brief", "empty", "file", "author", "date"]
+ "default": ["file", "author", "brief", "version", "date", "empty", "copyright", "empty", "custom"]
},
"doxdocgen.generic.includeTypeAtReturn": {
"description": "Whether include type information at return.",
diff --git a/src/Config.ts b/src/Config.ts
index a0bae83..54d227a 100644
--- a/src/Config.ts
+++ b/src/Config.ts
@@ -32,6 +32,9 @@ class File {
}
public fileTemplate: string = "@file {name}";
+ public copyrightTag: string[] = ["@copyright Copyright (c) {year}"];
+ public versionTag: string = "@version 0.1";
+ public customTag: string[] = [];
public fileOrder: string[] = ["brief", "empty", "file", "author", "date"];
}
@@ -71,6 +74,9 @@ export class Config {
values.Cpp.dtorText = Cpp.getConfiguration().get<string>("dtorText", values.Cpp.dtorText);
values.File.fileTemplate = File.getConfiguration().get<string>("fileTemplate", values.File.fileTemplate);
+ values.File.versionTag = File.getConfiguration().get<string>("versionTag", values.File.versionTag);
+ values.File.copyrightTag = File.getConfiguration().get<string[]>("copyrightTag", values.File.copyrightTag);
+ values.File.customTag = File.getConfiguration().get<string[]>("customTag", values.File.customTag);
values.File.fileOrder = File.getConfiguration().get<string[]>("fileOrder", values.File.fileOrder);
values.Generic.includeTypeAtReturn = Generic.getConfiguration().get<boolean>("includeTypeAtReturn", values.Generic.includeTypeAtReturn);
@@ -93,6 +99,7 @@ export class Config {
public readonly typeTemplateReplace: string = "{type}";
public readonly nameTemplateReplace: string = "{name}";
public readonly dateTemplateReplace: string = "{date}";
+ public readonly yearTemplateReplace: string = "{year}";
public readonly textTemplateReplace: string = "{text}";
public C: C;
diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts
index dd4818a..e71d39e 100644
--- a/src/Lang/Cpp/CppDocGen.ts
+++ b/src/Lang/Cpp/CppDocGen.ts
@@ -228,6 +228,34 @@ export class CppDocGen implements IDocGen {
}
}
+ protected generateVersionTag(lines: string[]) {
+ if (this.cfg.File.versionTag.trim().length !== 0) {
+ lines.push(this.cfg.C.commentPrefix + this.cfg.File.versionTag);
+ }
+ }
+
+ protected generateCopyrightTag(lines: string[]) {
+ this.cfg.File.copyrightTag.forEach((element) => {
+ this.generateFromTemplate(
+ lines,
+ this.cfg.yearTemplateReplace,
+ element,
+ [moment().format("YYYY")],
+ );
+ });
+ }
+
+ protected generateCustomTag(lines: string[]) {
+ this.cfg.File.customTag.forEach((element) => {
+ this.generateFromTemplate(
+ lines,
+ this.cfg.dateTemplateReplace,
+ element,
+ [moment().format(this.cfg.Generic.dateFormat)],
+ );
+ });
+ }
+
protected generateDateFromTemplate(lines: string[]) {
if (this.cfg.Generic.dateTemplate.trim().length !== 0 &&
this.cfg.Generic.dateFormat.trim().length !== 0) {
@@ -277,6 +305,10 @@ export class CppDocGen implements IDocGen {
this.generateFilenameFromTemplate(lines);
break;
}
+ case "version": {
+ this.generateVersionTag(lines);
+ break;
+ }
case "author": {
this.generateAuthorTag(lines);
break;
@@ -285,6 +317,14 @@ export class CppDocGen implements IDocGen {
this.generateDateFromTemplate(lines);
break;
}
+ case "copyright": {
+ this.generateCopyrightTag(lines);
+ break;
+ }
+ case "custom": {
+ this.generateCustomTag(lines);
+ break;
+ }
default: {
break;
}