chore: automated housekeeping...

This commit is contained in:
Pieter Vander Vennet 2024-07-21 10:52:51 +02:00
parent 14b2799f08
commit 4add2d1aff
151 changed files with 4561 additions and 3315 deletions

View file

@ -54,15 +54,15 @@ class ToSlideshowJson {
sections.push(currentSection)
currentSection = []
}
line = line.replace("src=\"../../public/", "src=\"./")
line = line.replace("src=\"../../", "src=\"./")
line = line.replace('src="../../public/', 'src="./')
line = line.replace('src="../../', 'src="./')
currentSection.push(line)
}
sections.push(currentSection)
writeFileSync(
this._target,
JSON.stringify({
sections: sections.map((s) => s.join("\n")).filter((s) => s.length > 0)
sections: sections.map((s) => s.join("\n")).filter((s) => s.length > 0),
})
)
}
@ -81,7 +81,7 @@ class WikiPageGenerator {
generate() {
let wikiPage =
"{|class=\"wikitable sortable\"\n" +
'{|class="wikitable sortable"\n' +
"! Name, link !! Genre !! Covered region !! Language !! Description !! Free materials !! Image\n" +
"|-"
@ -139,7 +139,7 @@ export class GenerateDocs extends Script {
}
this.WriteMarkdownFile("./Docs/Tags_format.md", TagUtils.generateDocs(), [
"src/Logic/Tags/TagUtils.ts"
"src/Logic/Tags/TagUtils.ts",
])
new ToSlideshowJson(
@ -165,24 +165,20 @@ export class GenerateDocs extends Script {
})
this.WriteMarkdownFile("./Docs/SpecialRenderings.md", SpecialVisualizations.HelpMessage(), [
"src/UI/SpecialVisualizations.ts"
"src/UI/SpecialVisualizations.ts",
])
this.WriteMarkdownFile(
"./Docs/CalculatedTags.md",
[
"# Metatags",
SimpleMetaTaggers.HelpText(),
ExtraFunctions.HelpText()
].join("\n"),
["# Metatags", SimpleMetaTaggers.HelpText(), ExtraFunctions.HelpText()].join("\n"),
["src/Logic/SimpleMetaTagger.ts", "src/Logic/ExtraFunctions.ts"]
)
this.WriteMarkdownFile("./Docs/SpecialInputElements.md", Validators.HelpText(), [
"src/UI/InputElement/Validators.ts"
"src/UI/InputElement/Validators.ts",
])
this.WriteMarkdownFile("./Docs/ChangesetMeta.md", Changes.getDocs(), [
"src/Logic/Osm/Changes.ts",
"src/Logic/Osm/ChangesetHandler.ts"
"src/Logic/Osm/ChangesetHandler.ts",
])
new WikiPageGenerator().generate()
@ -225,20 +221,21 @@ export class GenerateDocs extends Script {
const warnAutomated =
"[//]: # (WARNING: this file is automatically generated. Please find the sources at the bottom and edit those sources)\n\n"
const generatedFrom =
[
"This document is autogenerated from",
autogenSource.map(s => `[${s}](https://github.com/pietervdvn/MapComplete/blob/develop/${s})`).join(", ")
].join(" ")
const generatedFrom = [
"This document is autogenerated from",
autogenSource
.map((s) => `[${s}](https://github.com/pietervdvn/MapComplete/blob/develop/${s})`)
.join(", "),
].join(" ")
writeFileSync(filename, warnAutomated + md + "\n\n" + generatedFrom + "\n")
}
private generateHotkeyDocs() {
new ThemeViewState(new LayoutConfig(<any>bookcases), new Set())
this.WriteMarkdownFile("./Docs/Hotkeys.md", Hotkeys.generateDocumentation(), ["src/UI/Base/Hotkeys.ts"])
this.WriteMarkdownFile("./Docs/Hotkeys.md", Hotkeys.generateDocumentation(), [
"src/UI/Base/Hotkeys.ts",
])
}
private generateBuiltinUnits() {
@ -271,7 +268,7 @@ export class GenerateDocs extends Script {
}
this.WriteMarkdownFile("./Docs/builtin_units.md", ["# Units", ...els].join("\n\n"), [
`assets/layers/unit/unit.json`
`assets/layers/unit/unit.json`,
])
}
@ -438,39 +435,41 @@ export class GenerateDocs extends Script {
}
private generateForTheme(theme: LayoutConfig): void {
const allLayers = AllSharedLayers.getSharedLayersConfigs()
const layersToShow = theme.layers
.filter((l) => !l.id.startsWith("note_import_") && l.id !== "favourite" && Constants.added_by_default.indexOf(<any>l.id) < 0)
const layersToInline = layersToShow.filter(l => !allLayers.has(l.id))
const layersToShow = theme.layers.filter(
(l) =>
!l.id.startsWith("note_import_") &&
l.id !== "favourite" &&
Constants.added_by_default.indexOf(<any>l.id) < 0
)
const layersToInline = layersToShow.filter((l) => !allLayers.has(l.id))
const el = [
["##",
[
"##",
theme.title,
"(",
`[${theme.id}](https://mapcomplete.org/${theme.id})`,
")"
")",
].join(" "),
"_This document details some technical information about this MapComplete theme, mostly about the attributes used in the theme. Various links point toward more information about the attributes, e.g. to the OpenStreetMap-wiki, to TagInfo or tools creating statistics_",
"The theme introduction reads:\n",
"> "+parse_html(theme.description.textFor("en")).textContent.replace(/\n/g, " "),
"> " + parse_html(theme.description.textFor("en")).textContent.replace(/\n/g, " "),
"",
"This theme contains the following layers:",
MarkdownUtils.list(
layersToShow
.map((l) => {
if (allLayers.has(l.id)) {
return (`[${l.id}](../Layers/${l.id}.md)`)
}
return (`[${l.id} (defined in this theme)](#${l.id.trim().replace(/ /g, "-")})`)
})
layersToShow.map((l) => {
if (allLayers.has(l.id)) {
return `[${l.id}](../Layers/${l.id}.md)`
}
return `[${l.id} (defined in this theme)](#${l.id.trim().replace(/ /g, "-")})`
})
),
"Available languages:",
MarkdownUtils.list(theme.language.filter((ln) => ln !== "_context")),
"# Layers defined in this theme configuration file",
"These layers can not be reused in different themes.",
...layersToInline.map(l => l.GenerateDocumentation(null))
...layersToInline.map((l) => l.GenerateDocumentation(null)),
].join("\n")
this.WriteMarkdownFile(
"./Docs/Themes/" + theme.id + ".md",
@ -530,7 +529,9 @@ export class GenerateDocs extends Script {
"# Special and other useful layers",
"MapComplete has a few data layers available in the theme which have special properties through builtin-hooks. Furthermore, there are some normal layers (which are built from normal Theme-config files) but are so general that they get a mention here.",
"# Priviliged layers",
MarkdownUtils.list(Constants.priviliged_layers.map((id) => "[" + id + "](#" + id + ")")),
MarkdownUtils.list(
Constants.priviliged_layers.map((id) => "[" + id + "](#" + id + ")")
),
...Utils.NoNull(
Constants.priviliged_layers.map((id) => AllSharedLayers.sharedLayers.get(id))
).map((l) =>
@ -548,9 +549,11 @@ export class GenerateDocs extends Script {
Array.from(AllSharedLayers.sharedLayers.keys()).map(
(id) => `[${id}](./Layers/${id}.md)`
)
)
),
].join("\n\n")
this.WriteMarkdownFile("./Docs/BuiltinLayers.md", el, ["src/Customizations/AllKnownLayouts.ts"])
this.WriteMarkdownFile("./Docs/BuiltinLayers.md", el, [
"src/Customizations/AllKnownLayouts.ts",
])
}
}