Improve documentation

This commit is contained in:
Pieter Vander Vennet 2022-04-06 16:12:01 +02:00
parent d80cc64f77
commit db2b14cd95
124 changed files with 4450 additions and 4088 deletions

View file

@ -1,7 +1,7 @@
import Combine from "../UI/Base/Combine";
import BaseUIElement from "../UI/BaseUIElement";
import Translations from "../UI/i18n/Translations";
import {existsSync, writeFileSync} from "fs";
import {existsSync, mkdir, mkdirSync, writeFileSync} from "fs";
import {AllKnownLayouts} from "../Customizations/AllKnownLayouts";
import TableOfContents from "../UI/Base/TableOfContents";
import SimpleMetaTaggers, {SimpleMetaTagger} from "../Logic/SimpleMetaTagger";
@ -18,7 +18,9 @@ import ScriptUtils from "./ScriptUtils";
import List from "../UI/Base/List";
import SharedTagRenderings from "../Customizations/SharedTagRenderings";
function WriteFile(filename, html: BaseUIElement, autogenSource: string[]): void {
function WriteFile(filename, html: BaseUIElement, autogenSource: string[], options?: {
noTableOfContents: boolean
}): void {
for (const source of autogenSource) {
@ -30,7 +32,7 @@ function WriteFile(filename, html: BaseUIElement, autogenSource: string[]): void
}
}
if (html instanceof Combine) {
if (html instanceof Combine && !(options?.noTableOfContents)) {
const toc = new TableOfContents(html);
const els = html.getElements();
html = new Combine(
@ -51,9 +53,16 @@ function WriteFile(filename, html: BaseUIElement, autogenSource: string[]): void
}
console.log("Starting documentation generation...")
AllKnownLayouts.GenOverviewsForSingleLayer((layer, element) => {
AllKnownLayouts.GenOverviewsForSingleLayer((layer, element, inlineSource) => {
console.log("Exporting ", layer.id)
WriteFile("./Docs/Layers/" + layer.id + ".md", element, [`assets/layers/${layer.id}/${layer.id}.json`])
if(!existsSync("./Docs/Layers")){
mkdirSync("./Docs/Layers")
}
let source: string = `assets/layers/${layer.id}/${layer.id}.json`
if(inlineSource !== undefined){
source = `assets/themes/${inlineSource}/${inlineSource}.json`
}
WriteFile("./Docs/Layers/" + layer.id + ".md", element, [source], {noTableOfContents: true})
})
WriteFile("./Docs/SpecialRenderings.md", SpecialVisualizations.HelpMessage(), ["UI/SpecialVisualizations.ts"])