Set up documentation generation

This commit is contained in:
dcodeIO
2018-03-19 01:12:18 +01:00
parent c0973433d6
commit 0fef69e445
47 changed files with 523 additions and 119 deletions

View File

@ -3,7 +3,10 @@ var fs = require("fs");
var messages = require(__dirname + "/../src/diagnosticMessages.json");
var sb = [
"// code below is generated from diagnosticsMessages.json by scripts/build-diagnostics\n",
"/**\n",
" * Generated from diagnosticsMessages.json. Do not edit.\n",
" * @module diagnostics\n",
" *//***/\n\n",
"/* tslint:disable:max-line-length */\n\n"
];
@ -11,6 +14,7 @@ function makeKey(text) {
return text.replace(/[^\w]+/g, "_").replace(/_+$/, "");
}
sb.push("/** Enum of available diagnostic codes. */\n");
sb.push("export enum DiagnosticCode {\n");
var first = true;
@ -24,7 +28,9 @@ Object.keys(messages).forEach(text => {
sb.push(" " + key + " = " + messages[text]);
});
sb.push("\n}\n\nexport function diagnosticCodeToString(code: DiagnosticCode): string {\n switch (code) {\n");
sb.push("\n}\n\n");
sb.push("/** Translates a diagnostic code to its respective string. */\n");
sb.push("export function diagnosticCodeToString(code: DiagnosticCode): string {\n switch (code) {\n");
Object.keys(messages).forEach(text => {
sb.push(" case " + messages[text] + ": return " + JSON.stringify(text) + ";\n");