forked from MapComplete/MapComplete
Chore: improve documentation and error messages
This commit is contained in:
parent
5095bffc50
commit
06a9fb3711
7 changed files with 26 additions and 19 deletions
|
@ -151,7 +151,11 @@ export class Each<X, Y> extends Conversion<X[], Y[]> {
|
|||
values[i]?.["id"] !== undefined ? values[i]?.["id"] : ""
|
||||
)
|
||||
}
|
||||
const r = step.convert(values[i], c.enter(i))
|
||||
let id = ""
|
||||
if (values[i]?.["id"]) {
|
||||
id = `(${values[i]?.["id"]})`
|
||||
}
|
||||
const r = step.convert(values[i], c.enter(i + id))
|
||||
result.push(r)
|
||||
}
|
||||
return result
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* In some cases, a value is represented in a certain unit (such as meters for heigt/distance/..., km/h for speed, ...)
|
||||
* In some cases, a value is represented in a certain unit (such as meters for height/distance/..., km/h for speed, ...)
|
||||
*
|
||||
* Sometimes, multiple denominations are possible (e.g. km/h vs mile/h; megawatt vs kilowatt vs gigawatt for power generators, ...)
|
||||
*
|
||||
|
@ -14,9 +14,9 @@
|
|||
*
|
||||
* # Usage
|
||||
*
|
||||
* First of all, you define which keys have units applied, for example:
|
||||
* First of all, you define which keys have units applied. This can be done centrally in the layer:
|
||||
*
|
||||
* ```
|
||||
* ```json
|
||||
* units: [
|
||||
* appliesTo: ["maxspeed", "maxspeed:hgv", "maxspeed:bus"]
|
||||
* applicableUnits: [
|
||||
|
|
|
@ -197,7 +197,7 @@ export default class TagRenderingConfig {
|
|||
json.freeform.key,
|
||||
<any>Validators.availableTypes,
|
||||
(s) => <any>s
|
||||
)}`
|
||||
)}. See https://source.mapcomplete.org/MapComplete/MapComplete/src/branch/develop/Docs/SpecialInputElements.md for more information`
|
||||
}
|
||||
const type: ValidatorType = <any>json.freeform.type ?? "string"
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ export default class OpeningHoursValidator extends Validator {
|
|||
"opening_hours",
|
||||
[
|
||||
"Has extra elements to easily input when a POI is opened.",
|
||||
"### Helper arguments",
|
||||
"#### Helper arguments",
|
||||
"Only one helper argument named `options` can be provided. It is a JSON-object of type `{ prefix: string, postfix: string }`:",
|
||||
MarkdownUtils.table(
|
||||
["subarg", "doc"],
|
||||
|
@ -22,7 +22,7 @@ export default class OpeningHoursValidator extends Validator {
|
|||
],
|
||||
]
|
||||
),
|
||||
"### Example usage",
|
||||
"#### Example usage",
|
||||
"To add a conditional (based on time) access restriction:\n\n```\n" +
|
||||
`
|
||||
"freeform": {
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
import Combine from "../../Base/Combine"
|
||||
import Wikidata, { WikidataResponse } from "../../../Logic/Web/Wikidata"
|
||||
import { Validator } from "../Validator"
|
||||
import { Translation } from "../../i18n/Translation"
|
||||
import Translations from "../../i18n/Translations"
|
||||
import Title from "../../Base/Title"
|
||||
import Table from "../../Base/Table"
|
||||
import MarkdownUtils from "../../../Utils/MarkdownUtils"
|
||||
|
||||
export default class WikidataValidator extends Validator {
|
||||
public static readonly _searchCache = new Map<string, Promise<WikidataResponse[]>>()
|
||||
|
||||
public static docs = [
|
||||
"### Helper arguments",
|
||||
private static docs = [
|
||||
"#### Helper arguments",
|
||||
MarkdownUtils.table(
|
||||
["name", "doc"],
|
||||
[
|
||||
|
@ -25,7 +22,7 @@ export default class WikidataValidator extends Validator {
|
|||
],
|
||||
]
|
||||
),
|
||||
"#### Suboptions",
|
||||
"##### Suboptions",
|
||||
MarkdownUtils.table(
|
||||
["subarg", "doc"],
|
||||
[
|
||||
|
@ -50,7 +47,7 @@ export default class WikidataValidator extends Validator {
|
|||
),
|
||||
].join("\n\n")
|
||||
private static readonly docsExampleUsage: string =
|
||||
"### Example usage\n\n" +
|
||||
"#### Example usage\n\n" +
|
||||
`The following is the 'freeform'-part of a layer config which will trigger a search for the wikidata item corresponding with the name of the selected feature. It will also remove '-street', '-square', ... if found at the end of the name
|
||||
|
||||
\`\`\`json
|
||||
|
@ -113,7 +110,7 @@ Another example is to search for species and trees:
|
|||
return !str.split(";").some((str) => Wikidata.ExtractKey(str) === undefined)
|
||||
}
|
||||
|
||||
getFeedback(s: string, _?: () => string): Translation | undefined {
|
||||
getFeedback(s: string): Translation | undefined {
|
||||
const t = Translations.t.validation.wikidata
|
||||
if (s === "") {
|
||||
return t.empty
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue