UX+Docs: improve documentation of background layer switch, export ELI-docs, load background layer based on category

This commit is contained in:
Pieter Vander Vennet 2024-08-25 01:43:08 +02:00
parent 33e9a94199
commit 0c4d81916f
7 changed files with 1034 additions and 69 deletions

View file

@ -29,6 +29,7 @@ import { Changes } from "../src/Logic/Osm/Changes"
import TableOfContents from "../src/UI/Base/TableOfContents"
import MarkdownUtils from "../src/Utils/MarkdownUtils"
import { parse as parse_html } from "node-html-parser"
import { AvailableRasterLayers } from "../src/Models/RasterLayers"
/**
* Converts a markdown-file into a .json file, which a walkthrough/slideshow element can use
@ -54,15 +55,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 +82,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 +140,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,7 +166,7 @@ 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",
@ -173,13 +174,31 @@ export class GenerateDocs extends Script {
["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"
])
const eli = await AvailableRasterLayers.editorLayerIndex()
this.WriteMarkdownFile("./Docs/ELI-overview.md",
[
"# Layers in the Editor Layer Index",
"This table gives a summary of ids, names and other metainformation. [See the online, interactive map here](https://osmlab.github.io/editor-layer-index/) or [visit the repository](https://github.com/osmlab/editor-layer-index)",
MarkdownUtils.table(
["id", "name", "category", "Best", "attribution"],
eli.map(f => [f.properties.id, f.properties.name, f.properties.category, f.properties.best ? "⭐" : "",
f.properties.attribution?.html ?? f.properties.attribution?.text
])
)
].join("\n\n"), [
"./public/assets/data/editor-layer-index.json"
]
)
new WikiPageGenerator().generate()
console.log("Generated docs")
@ -225,7 +244,7 @@ export class GenerateDocs extends Script {
"This document is autogenerated from",
autogenSource
.map((s) => `[${s}](https://github.com/pietervdvn/MapComplete/blob/develop/${s})`)
.join(", "),
.join(", ")
].join(" ")
writeFileSync(filename, warnAutomated + md + "\n\n" + generatedFrom + "\n")
@ -234,7 +253,7 @@ export class GenerateDocs extends Script {
private generateHotkeyDocs() {
new ThemeViewState(new LayoutConfig(<any>bookcases), new Set())
this.WriteMarkdownFile("./Docs/Hotkeys.md", Hotkeys.generateDocumentation(), [
"src/UI/Base/Hotkeys.ts",
"src/UI/Base/Hotkeys.ts"
])
}
@ -268,7 +287,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`
])
}
@ -449,7 +468,7 @@ export class GenerateDocs extends Script {
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_",
@ -469,7 +488,7 @@ export class GenerateDocs extends Script {
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",
@ -549,10 +568,10 @@ 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",
"src/Customizations/AllKnownLayouts.ts"
])
}
}