diff --git a/src/UI/InputElement/Validators/OpeningHoursValidator.ts b/src/UI/InputElement/Validators/OpeningHoursValidator.ts index 2c264238f..ce10f27c6 100644 --- a/src/UI/InputElement/Validators/OpeningHoursValidator.ts +++ b/src/UI/InputElement/Validators/OpeningHoursValidator.ts @@ -1,42 +1,29 @@ -import Combine from "../../Base/Combine" -import Title from "../../Base/Title" -import Table from "../../Base/Table" import { Validator } from "../Validator" +import MarkdownUtils from "../../../Utils/MarkdownUtils" export default class OpeningHoursValidator extends Validator { constructor() { super( "opening_hours", - new Combine([ + [ "Has extra elements to easily input when a POI is opened.", - new Title("Helper arguments"), - new Table( - ["name", "doc"], + ("### 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"], [ [ - "options", - new Combine([ - "A JSON-object of type `{ prefix: string, postfix: string }`. ", - new Table( - ["subarg", "doc"], - [ - [ - "prefix", - "Piece of text that will always be added to the front of the generated opening hours. If the OSM-data does not start with this, it will fail to parse.", - ], - [ - "postfix", - "Piece of text that will always be added to the end of the generated opening hours", - ], - ] - ), - ]), + "prefix", + "Piece of text that will always be added to the front of the generated opening hours. If the OSM-data does not start with this, it will fail to parse." ], - ] - ), - new Title("Example usage"), + [ + "postfix", + "Piece of text that will always be added to the end of the generated opening hours" + ] + ]), + ("### Example usage"), "To add a conditional (based on time) access restriction:\n\n```\n" + - ` + ` "freeform": { "key": "access:conditional", "type": "opening_hours", @@ -47,8 +34,8 @@ export default class OpeningHoursValidator extends Validator { } ] }` + - "\n```\n\n*Don't forget to pass the prefix and postfix in the rendering as well*: `{opening_hours_table(opening_hours,yes @ &LPARENS, &RPARENS )`", - ]) + "\n```\n\n*Don't forget to pass the prefix and postfix in the rendering as well*: `{opening_hours_table(opening_hours,yes @ &LPARENS, &RPARENS )`" + ].join("\n") ) } } diff --git a/src/UI/InputElement/Validators/WikidataValidator.ts b/src/UI/InputElement/Validators/WikidataValidator.ts index cff54be2d..50e8d709a 100644 --- a/src/UI/InputElement/Validators/WikidataValidator.ts +++ b/src/UI/InputElement/Validators/WikidataValidator.ts @@ -10,49 +10,49 @@ import MarkdownUtils from "../../../Utils/MarkdownUtils" export default class WikidataValidator extends Validator { public static readonly _searchCache = new Map>() - public static docs = new Combine([ - new Title("Helper arguments"), - new Table( + public static docs = [ + "### Helper arguments", + MarkdownUtils.table( ["name", "doc"], [ [ "key", - "the value of this tag will initialize search (default: name). This can be a ';'-separated list in which case every key will be inspected. The non-null value will be used as search", + "the value of this tag will initialize search (default: name). This can be a ';'-separated list in which case every key will be inspected. The non-null value will be used as search" ], [ "options", - new Combine([ - "A JSON-object of type `{ removePrefixes: string[], removePostfixes: string[] }`.", - MarkdownUtils.table( - ["subarg", "doc"], - [ - [ - "removePrefixes", - "remove these snippets of text from the start of the passed string to search. This is either a list OR a hash of languages to a list. The individual strings are interpreted as case ignoring regexes", - ], - [ - "removePostfixes", - "remove these snippets of text from the end of the passed string to search. This is either a list OR a hash of languages to a list. The individual strings are interpreted as case ignoring regexes.", - ], - [ - "instanceOf", - "A list of Q-identifier which indicates that the search results _must_ be an entity of this type, e.g. [`Q5`](https://www.wikidata.org/wiki/Q5) for humans", - ], - [ - "notInstanceof", - "A list of Q-identifiers which indicates that the search results _must not_ be an entity of this type, e.g. [`Q79007`](https://www.wikidata.org/wiki/Q79007) to filter away all streets from the search results", - ], - [ - "multiple", - "If 'yes' or 'true', will allow to select multiple values at once", - ], - ] - ), - ]), - ], + "A JSON-object of type `{ removePrefixes: Record, removePostfixes: Record, ... }`. See the more detailed explanation below" + ] ] ), - new Title("Example usage"), + "#### Suboptions", + MarkdownUtils.table( + ["subarg", "doc"], + [ + [ + "removePrefixes", + "remove these snippets of text from the start of the passed string to search. This is either a list OR a hash of languages to a list. The individual strings are interpreted as case ignoring regexes" + ], + [ + "removePostfixes", + "remove these snippets of text from the end of the passed string to search. This is either a list OR a hash of languages to a list. The individual strings are interpreted as case ignoring regexes." + ], + [ + "instanceOf", + "A list of Q-identifier which indicates that the search results _must_ be an entity of this type, e.g. [`Q5`](https://www.wikidata.org/wiki/Q5) for humans" + ], + [ + "notInstanceof", + "A list of Q-identifiers which indicates that the search results _must not_ be an entity of this type, e.g. [`Q79007`](https://www.wikidata.org/wiki/Q79007) to filter away all streets from the search results" + ], + [ + "multiple", + "If 'yes' or 'true', will allow to select multiple values at once" + ] + ] + ) + ].join("\n\n") + private static readonly docsExampleUsage: string = "### 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 @@ -94,10 +94,11 @@ Another example is to search for species and trees: }] } \`\`\` -`, - ]) +` + + constructor() { - super("wikidata", new Combine(["A wikidata identifier, e.g. Q42.", WikidataValidator.docs])) + super("wikidata", "A wikidata identifier, e.g. Q42.\n\n" + WikidataValidator.docs + WikidataValidator.docsExampleUsage) } public isValid(str): boolean {