chore: automated housekeeping...

This commit is contained in:
Pieter Vander Vennet 2025-04-15 18:18:44 +02:00
parent 79b6927b56
commit 42ded4c1b1
328 changed files with 4062 additions and 1284 deletions

View file

@ -12,33 +12,33 @@ import { Utils } from "../src/Utils"
interface TagInfoEntry {
key: string
description: string
value?: string,
icon_url?: string,
value?: string
icon_url?: string
doc_url?: string
}
interface TagInfoProjectFile {
// data format version, currently always 1, will get updated if there are incompatible changes to the format (required)
data_format: 1,
data_format: 1
// timestamp when project file was updated is not given as it pollutes the github history
project: {
name: string, // name of the project (required)
description: string, // short description of the project (required)
project_url: string, // home page of the project with general information (required)
name: string // name of the project (required)
description: string // short description of the project (required)
project_url: string // home page of the project with general information (required)
doc_url: string // documentation of the project and especially the tags used (optional)
icon_url: string, // project logo, should work in 16x16 pixels on white and light gray backgrounds (optional)
contact_name: string, // contact name, needed for taginfo maintainer (required)
icon_url: string // project logo, should work in 16x16 pixels on white and light gray backgrounds (optional)
contact_name: string // contact name, needed for taginfo maintainer (required)
contact_email: string // contact email, needed for taginfo maintainer (required)
},
}
tags: TagInfoEntry[]
}
interface TagInfoPrototype {
key: string,
value?: string,
shownText: string,
layerName: string,
layer: LayerConfig,
key: string
value?: string
shownText: string
layerName: string
layer: LayerConfig
icon?: string
emoji?: string
trid?: string
@ -56,9 +56,11 @@ function generateLayerUsage(layer: LayerConfig): TagInfoPrototype[] {
const layerName = layer.name.txt
for (const kv of usedTags) {
result.push({
key: kv.k, value: kv.v, layerName,
key: kv.k,
value: kv.v,
layerName,
shownText: "Features with this tag are displayed",
layer
layer,
})
}
@ -81,7 +83,12 @@ function generateLayerUsage(layer: LayerConfig): TagInfoPrototype[] {
const keys = ["image", "panoramax", "mapillary", "wikidata", "wikipedia"]
for (const key of keys) {
result.push({
key, shownText, layerName, layer, emoji: "📷", trid: "images"
key,
shownText,
layerName,
layer,
emoji: "📷",
trid: "images",
})
}
}
@ -90,17 +97,19 @@ function generateLayerUsage(layer: LayerConfig): TagInfoPrototype[] {
const q = tr.question?.txt
const key = tr.freeform?.key
if (key != undefined) {
let descr = "Values of `" + key + "` are shown with \"" + tr.render.txt + "\""
let descr = "Values of `" + key + '` are shown with "' + tr.render.txt + '"'
if (q != undefined) {
descr += " and can be updated. The question is \"" + q + "\""
descr += ' and can be updated. The question is "' + q + '"'
}
result.push(({
key, layerName, shownText: descr,
result.push({
key,
layerName,
shownText: descr,
layer,
icon: !Utils.isEmoji(tr.renderIcon) ? tr.renderIcon : undefined,
emoji: Utils.isEmoji(tr.renderIcon) ? tr.renderIcon : undefined,
trid: tr.id
}))
trid: tr.id,
})
}
for (const mapping of tr.mappings ?? []) {
@ -110,10 +119,12 @@ function generateLayerUsage(layer: LayerConfig): TagInfoPrototype[] {
value: kv.v,
layerName,
layer,
shownText: `${mapping.if.asHumanString()} is displayed as "${mapping.then.txt}"`,
shownText: `${mapping.if.asHumanString()} is displayed as "${
mapping.then.txt
}"`,
icon: !Utils.isEmoji(mapping.icon) ? mapping.icon : undefined,
emoji: Utils.isEmoji(mapping.icon) ? mapping.icon : undefined,
trid: tr.id
trid: tr.id,
})
}
}
@ -147,7 +158,6 @@ function generateTagInfoEntry(layout: ThemeConfig): string {
icon = icon.substring(2)
}
const merged: Map<string, TagInfoPrototype[]> = new Map<string, TagInfoPrototype[]>()
for (const entry of usedTags) {
const key = entry.key + ";" + (entry.value ?? "") + ";" + entry.shownText
@ -166,7 +176,7 @@ function generateTagInfoEntry(layout: ThemeConfig): string {
Array.from(merged.values()).forEach((prototypes: TagInfoPrototype[]) => {
// We use a prototype without condition, as this has a higher chance of being the "root"-layer
const p = prototypes[0]
const layers = prototypes.map(p => p.layerName)
const layers = prototypes.map((p) => p.layerName)
let layerDescr = `layers ${layers.join(", ")}`
if (layers.length === 1) {
@ -178,7 +188,9 @@ function generateTagInfoEntry(layout: ThemeConfig): string {
}
let defaultIcon = undefined
if (p.layer.hasDefaultIcon()) {
defaultIcon = p.layer.mapRendering.map(pr => pr.marker?.at(-1)?.icon?.render?.txt).find(x => x !== undefined)
defaultIcon = p.layer.mapRendering
.map((pr) => pr.marker?.at(-1)?.icon?.render?.txt)
.find((x) => x !== undefined)
}
let value = p.value
if (value === "") {
@ -189,7 +201,7 @@ function generateTagInfoEntry(layout: ThemeConfig): string {
value,
description: p.shownText + " by " + layerDescr,
doc_url,
icon_url: p.icon ?? defaultIcon
icon_url: p.icon ?? defaultIcon,
})
})
@ -201,13 +213,12 @@ function generateTagInfoEntry(layout: ThemeConfig): string {
name: "MapComplete " + layout.title.txt, // name of the project (required)
description: layout.shortDescription.txt, // short description of the project (required)
project_url: "https://mapcomplete.org/" + layout.id, // home page of the project with general information (required)
doc_url:
repo + "src/branch/develop/Docs/Themes", // documentation of the project and especially the tags used (optional)
doc_url: repo + "src/branch/develop/Docs/Themes", // documentation of the project and especially the tags used (optional)
icon_url: "https://mapcomplete.org/" + icon, // project logo, should work in 16x16 pixels on white and light gray backgrounds (optional)
contact_name: "Pieter Vander Vennet", // contact name, needed for taginfo maintainer (required)
contact_email: "info@mapcomplete.org" // contact email, needed for taginfo maintainer (required)
contact_email: "info@mapcomplete.org", // contact email, needed for taginfo maintainer (required)
},
tags: entries
tags: entries,
}
const filename = "mapcomplete_" + layout.id