mapcomplete/scripts/generateDocs.ts

67 lines
2.2 KiB
TypeScript
Raw Normal View History

import {Utils} from "../Utils";
import SpecialVisualizations from "../UI/SpecialVisualizations";
import SimpleMetaTagger from "../Logic/SimpleMetaTagger";
2021-03-24 02:01:04 +01:00
import Combine from "../UI/Base/Combine";
import {ExtraFunction} from "../Logic/ExtraFunction";
import ValidatedTextField from "../UI/Input/ValidatedTextField";
import BaseUIElement from "../UI/BaseUIElement";
import Translations from "../UI/i18n/Translations";
import {writeFileSync} from "fs";
import {QueryParameters} from "../Logic/Web/QueryParameters";
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
2021-10-28 03:21:17 +02:00
import Minimap from "../UI/Base/Minimap";
import FeatureSwitchState from "../Logic/State/FeatureSwitchState";
2021-11-07 16:34:51 +01:00
Utils.runningFromConsole = true;
2021-06-16 21:23:03 +02:00
function WriteFile(filename, html: string | BaseUIElement, autogenSource: string[]): void {
2021-06-16 17:09:32 +02:00
writeFileSync(filename, new Combine([Translations.W(html),
"Generated from " + autogenSource.join(", ")
2021-06-16 17:09:32 +02:00
]).AsMarkdown());
}
WriteFile("./Docs/SpecialRenderings.md", SpecialVisualizations.HelpMessage(), ["UI/SpecialVisualisations.ts"])
2021-06-16 17:09:32 +02:00
WriteFile("./Docs/CalculatedTags.md", new Combine([SimpleMetaTagger.HelpText(), ExtraFunction.HelpText()]).SetClass("flex-col"),
["SimpleMetaTagger", "ExtraFunction"])
WriteFile("./Docs/SpecialInputElements.md", ValidatedTextField.HelpText(), ["ValidatedTextField.ts"]);
2021-10-28 03:21:17 +02:00
Minimap.createMiniMap = _ => {
console.log("Not creating a minimap, it is disabled");
return undefined
}
2021-03-22 01:06:24 +01:00
2021-10-28 03:21:17 +02:00
const dummyLayout = new LayoutConfig({
language: ["en"],
id: "<theme>",
maintainer: "pietervdvn",
version: "0",
title: "<theme>",
description: "A theme to generate docs with",
startLat: 0,
startLon: 0,
startZoom: 0,
icon: undefined,
layers: [
{
name: "<layer>",
id: "<layer>",
source: {
osmTags: "id~*"
2021-10-28 03:21:17 +02:00
},
mapRendering: []
}
]
2021-10-28 03:21:17 +02:00
})
new FeatureSwitchState(dummyLayout)
QueryParameters.GetQueryParameter("layer-<layer-id>", "true", "Wether or not the layer with id <layer-id> is shown")
2021-06-16 21:23:03 +02:00
WriteFile("./Docs/URL_Parameters.md", QueryParameters.GenerateQueryParameterDocs(), ["QueryParameters"])
2021-03-22 01:06:24 +01:00
console.log("Generated docs")