Chore: improve documentation and error messages

This commit is contained in:
Pieter Vander Vennet 2025-04-08 02:48:58 +02:00
parent 5095bffc50
commit 06a9fb3711
7 changed files with 26 additions and 19 deletions

View file

@ -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