Chore: regenerate docs

This commit is contained in:
Pieter Vander Vennet 2024-07-16 19:31:00 +02:00
parent cbadd1e063
commit 3b7cc37b53
292 changed files with 34355 additions and 24710 deletions

View file

@ -1,42 +1,14 @@
import { Utils } from "../../Utils"
/** This code is autogenerated - do not edit. Edit ./assets/layers/usersettings/usersettings.json instead */
export class ThemeMetaTagging {
public static readonly themeName = "usersettings"
public static readonly themeName = "usersettings"
public metaTaggging_for_usersettings(feat: { properties: Record<string, string> }) {
Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_md", () =>
feat.properties._description
.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)
?.at(1)
)
Utils.AddLazyProperty(
feat.properties,
"_d",
() => feat.properties._description?.replace(/&lt;/g, "<")?.replace(/&gt;/g, ">") ?? ""
)
Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_a", () =>
((feat) => {
const e = document.createElement("div")
e.innerHTML = feat.properties._d
return Array.from(e.getElementsByTagName("a")).filter(
(a) => a.href.match(/mastodon|en.osm.town/) !== null
)[0]?.href
})(feat)
)
Utils.AddLazyProperty(feat.properties, "_mastodon_link", () =>
((feat) => {
const e = document.createElement("div")
e.innerHTML = feat.properties._d
return Array.from(e.getElementsByTagName("a")).filter(
(a) => a.getAttribute("rel")?.indexOf("me") >= 0
)[0]?.href
})(feat)
)
Utils.AddLazyProperty(
feat.properties,
"_mastodon_candidate",
() => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a
)
feat.properties["__current_backgroun"] = "initial_value"
}
}
public metaTaggging_for_usersettings(feat: {properties: Record<string, string>}) {
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_md', () => feat.properties._description.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)?.at(1) )
Utils.AddLazyProperty(feat.properties, '_d', () => feat.properties._description?.replace(/&lt;/g,'<')?.replace(/&gt;/g,'>') ?? '' )
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_a', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.href.match(/mastodon|en.osm.town/) !== null)[0]?.href }) (feat) )
Utils.AddLazyProperty(feat.properties, '_mastodon_link', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.getAttribute("rel")?.indexOf('me') >= 0)[0]?.href})(feat) )
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate', () => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a )
feat.properties['__current_backgroun'] = 'initial_value'
}
}

View file

@ -7,13 +7,10 @@ import {
FirstOf,
Fuse,
On,
SetDefault,
SetDefault
} from "./Conversion"
import { LayerConfigJson } from "../Json/LayerConfigJson"
import {
MinimalTagRenderingConfigJson,
TagRenderingConfigJson,
} from "../Json/TagRenderingConfigJson"
import { MinimalTagRenderingConfigJson, TagRenderingConfigJson } from "../Json/TagRenderingConfigJson"
import { Utils } from "../../../Utils"
import RewritableConfigJson from "../Json/RewritableConfigJson"
import SpecialVisualizations from "../../../UI/SpecialVisualizations"
@ -615,23 +612,11 @@ export class AddQuestionBox extends DesugaringStep<LayerConfigJson> {
}
export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
static addedElements: string[] = [
"minimap",
"just_created",
"split_button",
"move_button",
"delete_button",
"last_edit",
"favourite_state",
"all_tags",
"qr_code",
"nearby_images",
"linked_open_data",
]
private readonly _desugaring: DesugaringContext
private readonly _addedByDefaultAtTop: QuestionableTagRenderingConfigJson[]
private readonly _addedByDefault: QuestionableTagRenderingConfigJson[]
private readonly builtinQuestions: QuestionableTagRenderingConfigJson[]
constructor(desugaring: DesugaringContext) {
super(
"Add some editing elements, such as the delete button or the move button if they are configured. These used to be handled by the feature info box, but this has been replaced by special visualisation elements",
@ -639,20 +624,20 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
"AddEditingElements"
)
this._desugaring = desugaring
this.builtinQuestions = Array.from(this._desugaring.tagRenderings?.values() ?? [])
const builtinQuestions = Array.from(this._desugaring.tagRenderings?.values() ?? [])
function getAddedByDefaultIds(key: string): QuestionableTagRenderingConfigJson[] {
const addByDefault = builtinQuestions.filter((tr) => tr.labels?.indexOf(key) >= 0)
const ids = new Set(addByDefault.map((tr) => tr.id))
const idsInOrder = desugaring.tagRenderingOrder?.filter((id) => ids.has(id)) ?? []
return Utils.NoNull(idsInOrder.map((id) => desugaring.tagRenderings.get(id)))
}
this._addedByDefaultAtTop = getAddedByDefaultIds("added_by_default_top")
this._addedByDefault = getAddedByDefaultIds("added_by_default")
this._addedByDefaultAtTop = this.getAddedByDefaultIds("added_by_default_top")
this._addedByDefault = this.getAddedByDefaultIds("added_by_default")
}
public getAddedByDefaultIds(key: string): QuestionableTagRenderingConfigJson[] {
const addByDefault = this.builtinQuestions.filter((tr) => tr.labels?.indexOf(key) >= 0)
const ids = new Set(addByDefault.map((tr) => tr.id))
const idsInOrder = this._desugaring.tagRenderingOrder?.filter((id) => ids.has(id)) ?? []
return Utils.NoNull(idsInOrder.map((id) => this._desugaring.tagRenderings.get(id)))
}
convert(json: LayerConfigJson, _: ConversionContext): LayerConfigJson {
if (this._desugaring.tagRenderings === null) {
return json
@ -717,7 +702,7 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
const trc: QuestionableTagRenderingConfigJson = {
id: "all-tags",
render: { "*": "{all_tags()}" },
labels:["ignore_docs"],
metacondition: {
or: [
"__featureSwitchIsDebugging=true",

View file

@ -19,7 +19,6 @@ import { Utils } from "../../Utils"
import { TagsFilter } from "../../Logic/Tags/TagsFilter"
import FilterConfigJson from "./Json/FilterConfigJson"
import { Overpass } from "../../Logic/Osm/Overpass"
import { FixedUiElement } from "../../UI/Base/FixedUiElement"
import { ImmutableStore } from "../../Logic/UIEventSource"
import { OsmTags } from "../OsmFeature"
import Constants from "../Constants"
@ -66,11 +65,18 @@ export default class LayerConfig extends WithContextLoader {
public readonly popupInFloatover: boolean | string
public readonly enableMorePrivacy: boolean
/**
* If this layer is based on another layer, this might be indicated here
* @private
*/
private readonly _basedOn: string | undefined
constructor(json: LayerConfigJson, context?: string, official: boolean = true) {
context = context + "." + json.id
const translationContext = "layers:" + json.id
super(json, context)
this.id = json.id
this._basedOn = json["_basedOn"]
if (json.source === "special" || json.source === "special:library") {
this.source = null
@ -454,17 +460,20 @@ export default class LayerConfig extends WithContextLoader {
const tableRows: string[][] = Utils.NoNull(
this.tagRenderings
.map((tr) => tr.FreeformValues())
.filter(values => values !== undefined)
.filter(values => values.key !== "id")
.map((values) => {
if (values == undefined) {
return undefined
}
const embedded: (Link | string)[] = values.values?.map((v) =>
Link.OsmWiki(values.key, v, true).SetClass("mr-2")
const embedded: (string)[] = values.values?.map((v) =>
Link.OsmWiki(values.key, v, true).SetClass("mr-2").AsMarkdown()
) ?? ["_no preset options defined, or no values in them_"]
const statistics = `https://taghistory.raifer.tech/?#***/${encodeURIComponent(values.key)}/`
const tagInfo = `https://taginfo.openstreetmap.org/keys/${values.key}#values`
return [
[
`<a target="_blank" href='https://taginfo.openstreetmap.org/keys/${ values.key}#values'><img src='https://mapcomplete.org/assets/svg/statistics.svg' height='18px'></a>]`,
Link.OsmWiki(values.key)
`<a target="_blank" href='${tagInfo}'><img src='https://mapcomplete.org/assets/svg/search.svg' height='18px'></a>`,
`<a target="_blank" href='${statistics}'><img src='https://mapcomplete.org/assets/svg/statistics.svg' height='18px'></a>`,
Link.OsmWiki(values.key).AsMarkdown()
].join(" "),
values.type === undefined
? "Multiple choice"
@ -486,20 +495,6 @@ export default class LayerConfig extends WithContextLoader {
]
}
let iconImg: BaseUIElement = new FixedUiElement("")
if (!Utils.runningFromConsole) {
iconImg = this.mapRendering
.filter((mr) => mr.location.has("point"))
.map(
(mr) =>
mr.RenderIcon(new ImmutableStore<OsmTags>({ id: "node/-1" }), {
includeBadges: false
}).html
)
.find((i) => i !== undefined)
}
let overpassLink: string = undefined
if (this.source !== undefined) {
try {
@ -517,7 +512,7 @@ export default class LayerConfig extends WithContextLoader {
const filterDocs: (string)[] = []
if (this.filters.length > 0) {
filterDocs.push("#### Filters")
filterDocs.push("## Filters")
filterDocs.push(...this.filters.map((filter) => filter.GenerateDocs()))
}
@ -553,17 +548,19 @@ export default class LayerConfig extends WithContextLoader {
return [
[
"# " + this.id+"\n",
iconImg,
"# " + this.id + "\n",
this._basedOn ? `This layer is based on [${this._basedOn}](../Layers/${this._basedOn}.md)` : "",
this.description, "\n"].join("\n\n"),
MarkdownUtils.list(extraProps),
...usingLayer,
...tagsDescription,
"## Supported attributes",
quickOverview,
...this.tagRenderings.map((tr) => tr.GenerateDocumentation()),
...this.tagRenderings
.filter(tr => tr.labels.indexOf("ignore_docs") < 0)
.map((tr) => tr.GenerateDocumentation()),
...filterDocs
] .join("\n\n")
].join("\n\n")
}
public CustomCodeSnippets(): string[] {

View file

@ -228,7 +228,7 @@ export default class PointRenderingConfig extends WithContextLoader {
const css = this.cssDef?.GetRenderValue(tags.data)?.txt
const cssClasses = this.cssClasses?.GetRenderValue(tags.data)?.txt
let label = this.GetLabel(tags, icon === undefined)
const label = this.GetLabel(tags, icon === undefined)
let htmlEl: BaseUIElement
if (icon === undefined && label === undefined) {

View file

@ -8,7 +8,7 @@ import { Tag } from "../../Logic/Tags/Tag"
import Link from "../../UI/Base/Link"
import {
MappingConfigJson,
QuestionableTagRenderingConfigJson,
QuestionableTagRenderingConfigJson
} from "./Json/QuestionableTagRenderingConfigJson"
import Validators, { ValidatorType } from "../../UI/InputElement/Validators"
import { TagRenderingConfigJson } from "./Json/TagRenderingConfigJson"
@ -416,7 +416,7 @@ export default class TagRenderingConfig {
iconClass,
addExtraTags,
searchTerms: mapping.searchTerms,
priorityIf: prioritySearch,
priorityIf: prioritySearch
}
if (isQuestionable) {
if (hideInAnswer !== true && mp.if !== undefined && !mp.if.isUsableAsAnswer()) {
@ -517,7 +517,7 @@ export default class TagRenderingConfig {
then: new TypedTranslation<object>(
this.render.replace("{" + this.freeform.key + "}", leftover).translations,
this.render.context
),
)
})
}
}
@ -567,7 +567,7 @@ export default class TagRenderingConfig {
return {
then: this.render.PartialSubs({ [this.freeform.key]: v.trim() }),
icon: this.renderIcon,
iconClass: this.renderIconClass,
iconClass: this.renderIconClass
}
}
}
@ -622,7 +622,7 @@ export default class TagRenderingConfig {
key: commonKey,
values: Utils.NoNull(
values.map((arr) => arr.filter((item) => item.k === commonKey)[0]?.v)
),
)
}
}
@ -637,7 +637,7 @@ export default class TagRenderingConfig {
return {
key,
type: this.freeform.type,
values,
values
}
} catch (e) {
console.error("Could not create FreeformValues for tagrendering", this.id)
@ -743,7 +743,7 @@ export default class TagRenderingConfig {
// Either no mappings, or this is a radio-button selected freeform value
const tag = new And([
new Tag(this.freeform.key, freeformValue),
...(this.freeform.addExtraTags ?? []),
...(this.freeform.addExtraTags ?? [])
])
const newProperties = tag.applyOn(currentProperties)
if (this.invalidValues?.matchesProperties(newProperties)) {
@ -767,7 +767,7 @@ export default class TagRenderingConfig {
selectedMappings.push(
new And([
new Tag(this.freeform.key, freeformValue),
...(this.freeform.addExtraTags ?? []),
...(this.freeform.addExtraTags ?? [])
])
)
}
@ -795,12 +795,12 @@ export default class TagRenderingConfig {
if (useFreeform) {
return new And([
new Tag(this.freeform.key, freeformValue),
...(this.freeform.addExtraTags ?? []),
...(this.freeform.addExtraTags ?? [])
])
} else if (singleSelectedMapping !== undefined) {
return new And([
this.mappings[singleSelectedMapping].if,
...(this.mappings[singleSelectedMapping].addExtraTags ?? []),
...(this.mappings[singleSelectedMapping].addExtraTags ?? [])
])
} else {
console.error("TagRenderingConfig.ConstructSpecification has a weird fallback for", {
@ -808,27 +808,27 @@ export default class TagRenderingConfig {
singleSelectedMapping,
multiSelectedMapping,
currentProperties,
useFreeform,
useFreeform
})
return undefined
}
}
GenerateDocumentation(): string {
let withRender: string[] = []
if (this.freeform?.key !== undefined) {
withRender = [
`This rendering asks information about the property `,
Link.OsmWiki(this.freeform.key).AsMarkdown(),
"This is rendered with `" + this.render.txt + "`",
]
GenerateDocumentation(lang: string = "en"): string {
let freeform: string = undefined
if (this.render) {
freeform = "*" + this.render.textFor(lang) + "*"
if (this.freeform?.key) {
freeform += " is shown if `" + this.freeform.key + "` is set"
}
}
let mappings: string = undefined
if (this.mappings !== undefined) {
mappings = MarkdownUtils.list(
this.mappings.flatMap((m) => {
this.mappings.map((m) => {
let icon = ""
if (m.icon?.indexOf(";") < 0) {
icon =
@ -838,11 +838,11 @@ export default class TagRenderingConfig {
}
const msgs: string[] = [
icon +
" " +
"*" +
m.then.txt +
"* corresponds with " +
m.if.asHumanString(true, false, {}),
" " +
"*" +
m.then.textFor(lang) +
"* is shown if with " +
m.if.asHumanString(true, false, {})
]
if (m.hideInAnswer === true) {
@ -851,10 +851,10 @@ export default class TagRenderingConfig {
if (m.ifnot !== undefined) {
msgs.push(
"Unselecting this answer will add " +
m.ifnot.asHumanString(true, false, {})
m.ifnot.asHumanString(true, false, {})
)
}
return msgs
return msgs.join(". ")
})
)
}
@ -875,7 +875,7 @@ export default class TagRenderingConfig {
if (this.labels?.length > 0) {
labels = [
"This tagrendering has labels ",
...this.labels.map((label) => "`" + label + "`"),
...this.labels.map((label) => "`" + label + "`")
].join("\n")
}
@ -885,14 +885,18 @@ export default class TagRenderingConfig {
this.question !== undefined
? "The question is `" + this.question.txt + "`"
: "_This tagrendering has no question and is thus read-only_",
withRender.join("\n"),
freeform,
mappings,
condition,
labels,
labels
].join("\n")
}
public usedTags(): TagsFilter[] {
public
usedTags()
:
TagsFilter[] {
const tags: TagsFilter[] = []
tags.push(
this.metacondition,
@ -918,9 +922,13 @@ export default class TagRenderingConfig {
* The keys that should be erased if one has to revert to 'unknown'.
* Might give undefined
*/
public settableKeys(): string[] | undefined {
public
settableKeys()
:
string[] | undefined {
const toDelete = new Set<string>()
if(this.freeform){
if (this.freeform) {
toDelete.add(this.freeform.key)
}
for (const mapping of this.mappings) {
@ -967,7 +975,7 @@ export class TagRenderingConfigUtils {
const oldMappingsCloned =
clone.mappings?.map((m) => ({
...m,
priorityIf: m.priorityIf ?? TagUtils.Tag("id~*"),
priorityIf: m.priorityIf ?? TagUtils.Tag("id~*")
})) ?? []
clone.mappings = [...oldMappingsCloned, ...extraMappings]
return clone

View file

@ -98,7 +98,7 @@ export default class TableOfContents {
const intro = md.substring(0, firstTitleIndex)
const splitPoint = intro.lastIndexOf("\n")
return md.substring(0, splitPoint) +"\n" toc + md.substring(splitPoint)
return md.substring(0, splitPoint) +"\n" + toc + md.substring(splitPoint)
}
public static generateStructure(

View file

@ -17,7 +17,7 @@
const t = Translations.t.general.wikipedia
export let searchValue = new UIEventSource("Tom boonen")
export let searchValue = new UIEventSource(undefined)
export let placeholder = t.searchWikidata
export let allowMultiple = false
@ -37,7 +37,6 @@
}
$:{
console.log(selectedMany)
const v = []
for (const id in selectedMany) {
if (selectedMany[id]) {
@ -72,7 +71,6 @@
let selectedWithoutSearch: Store<WikidataResponse[]> = searchResult.map(sr => {
for (const wikidataItem of sr?.success ?? []) {
console.log("Saving", wikidataItem.id)
previouslySeen.set(wikidataItem.id, wikidataItem)
}
let knownIds: Set<string> = new Set(sr?.success?.map(item => item.id))

View file

@ -26,7 +26,6 @@ let searchFor: string =
.find((foundValue) => !!foundValue) ?? ""
const options: any = args[1]
console.log(">>>", args)
let searchForValue: UIEventSource<string> = new UIEventSource(searchFor)

View file

@ -15,6 +15,9 @@ export default class MarkdownUtils {
}
static list(strings: string[]): string {
return strings.map((item) => " - " + item).join("\n")
if(strings.length === 0){
return ""
}
return "\n\n"+strings.map((item) => " - " + item).join("\n")+"\n\n"
}
}