forked from MapComplete/MapComplete
Docs: create overview of online services (for F-Droid acceptance); inline ELI again
This commit is contained in:
parent
1a75823f17
commit
e9209f6b7c
26 changed files with 1099 additions and 298 deletions
|
@ -18,6 +18,7 @@ import {
|
|||
} from "./SpecialVisualisations/WebAndCommunicationSpecialVisualisations"
|
||||
import { DataVisualisations } from "./Popup/DataVisualisations"
|
||||
import { DataExportVisualisations } from "./Popup/DataExportVisualisations"
|
||||
import { Utils } from "../Utils"
|
||||
|
||||
export default class SpecialVisualizations {
|
||||
public static specialVisualizations: SpecialVisualization[] = SpecialVisualizations.initList()
|
||||
|
@ -30,7 +31,7 @@ export default class SpecialVisualizations {
|
|||
for (const specialVisualization of SpecialVisualizations.specialVisualizations) {
|
||||
SpecialVisualizations.specialVisualisationsDict.set(
|
||||
specialVisualization.funcName,
|
||||
specialVisualization
|
||||
specialVisualization,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +48,7 @@ export default class SpecialVisualizations {
|
|||
"`{" + viz.funcName + "(" + viz.args.map((arg) => arg.defaultValue).join(",") + ")}`"
|
||||
|
||||
let definitionPlace = ""
|
||||
if(viz.definedIn){
|
||||
if (viz.definedIn) {
|
||||
const path = viz.definedIn
|
||||
definitionPlace = `Defined in [${path.markdownLocation}](${path.markdownLocation})`
|
||||
}
|
||||
|
@ -56,15 +57,15 @@ export default class SpecialVisualizations {
|
|||
viz.docs,
|
||||
viz.args.length > 0
|
||||
? MarkdownUtils.table(
|
||||
["name", "default", "description"],
|
||||
viz.args.map((arg) => {
|
||||
let defaultArg = arg.defaultValue ?? "_undefined_"
|
||||
if (defaultArg == "") {
|
||||
defaultArg = "_empty string_"
|
||||
}
|
||||
return [arg.name, defaultArg, arg.doc]
|
||||
})
|
||||
)
|
||||
["name", "default", "description"],
|
||||
viz.args.map((arg) => {
|
||||
let defaultArg = arg.defaultValue ?? "_undefined_"
|
||||
if (defaultArg == "") {
|
||||
defaultArg = "_empty string_"
|
||||
}
|
||||
return [arg.name, defaultArg, arg.doc]
|
||||
}),
|
||||
)
|
||||
: undefined,
|
||||
definitionPlace,
|
||||
"#### Example usage of " + viz.funcName,
|
||||
|
@ -74,12 +75,12 @@ export default class SpecialVisualizations {
|
|||
|
||||
public static constructSpecification(
|
||||
template: string,
|
||||
extraMappings: SpecialVisualization[] = []
|
||||
extraMappings: SpecialVisualization[] = [],
|
||||
): RenderingSpecification[] {
|
||||
return SpecialVisualisationUtils.constructSpecification(
|
||||
template,
|
||||
SpecialVisualizations.specialVisualisationsDict,
|
||||
extraMappings
|
||||
extraMappings,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -112,7 +113,7 @@ export default class SpecialVisualizations {
|
|||
"Special visualisations which reuse other tagRenderings to show data, but with a twist.",
|
||||
web_and_communication:
|
||||
"Tools to show data from external websites, which link to external websites or which link to external profiles",
|
||||
ui: "Elements to support the user interface, e.g. 'title', 'translated'"
|
||||
ui: "Elements to support the user interface, e.g. 'title', 'translated'",
|
||||
}
|
||||
|
||||
const helpTexts: string[] = []
|
||||
|
@ -161,7 +162,7 @@ export default class SpecialVisualizations {
|
|||
},
|
||||
},
|
||||
null,
|
||||
" "
|
||||
" ",
|
||||
)
|
||||
|
||||
const firstPart = [
|
||||
|
@ -171,7 +172,7 @@ export default class SpecialVisualizations {
|
|||
"# Using expanded syntax",
|
||||
`Instead of using \`{"render": {"en": "{some_special_visualisation(some_arg, some other really long message, more args)} , "nl": "{some_special_visualisation(some_arg, een boodschap in een andere taal, more args)}}\`, one can also write`,
|
||||
"```\n" + example + "\n```\n",
|
||||
'In other words: use `{ "before": ..., "after": ..., "special": {"type": ..., "argname": ...argvalue...}`. The args are in the `special` block; an argvalue can be a string, a translation or another value. (Refer to class `RewriteSpecial` in case of problems)',
|
||||
"In other words: use `{ \"before\": ..., \"after\": ..., \"special\": {\"type\": ..., \"argname\": ...argvalue...}`. The args are in the `special` block; an argvalue can be a string, a translation or another value. (Refer to class `RewriteSpecial` in case of problems)",
|
||||
"# Overview of all special components",
|
||||
].join("\n\n")
|
||||
return firstPart + "\n\n" + helpTexts.join("\n\n")
|
||||
|
@ -196,28 +197,31 @@ export default class SpecialVisualizations {
|
|||
|
||||
specialVisualizations.push(new AutoApplyButtonVis(specialVisualizations))
|
||||
|
||||
const regex = /[a-zA-Z_]+/
|
||||
const invalid = specialVisualizations
|
||||
.map((sp, i) => ({ sp, i }))
|
||||
.filter((sp) => sp.sp.funcName === undefined || !sp.sp.funcName.match(regex))
|
||||
if (Utils.runningFromConsole) {
|
||||
// Some sanity checks
|
||||
const regex = /[a-zA-Z_]+/
|
||||
const invalid = specialVisualizations
|
||||
.map((sp, i) => ({ sp, i }))
|
||||
.filter((sp) => sp.sp.funcName === undefined || !sp.sp.funcName.match(regex))
|
||||
|
||||
if (invalid.length > 0) {
|
||||
throw (
|
||||
"Invalid special visualisation found: funcName is undefined or doesn't match " +
|
||||
regex +
|
||||
invalid.map((sp) => sp.i).join(", ") +
|
||||
'. Did you perhaps type \n funcName: "funcname" // type declaration uses COLON\ninstead of:\n funcName = "funcName" // value definition uses EQUAL'
|
||||
)
|
||||
}
|
||||
|
||||
const allNames = specialVisualizations.map((f) => f.funcName)
|
||||
const seen = new Set<string>()
|
||||
for (let name of allNames) {
|
||||
name = name.toLowerCase()
|
||||
if (seen.has(name)) {
|
||||
throw "Invalid special visualisations: detected a duplicate name: " + name
|
||||
if (invalid.length > 0) {
|
||||
throw (
|
||||
"Invalid special visualisation found: funcName is undefined or doesn't match " +
|
||||
regex +
|
||||
invalid.map((sp) => sp.i).join(", ") +
|
||||
". Did you perhaps type \n funcName: \"funcname\" // type declaration uses COLON\ninstead of:\n funcName = \"funcName\" // value definition uses EQUAL"
|
||||
)
|
||||
}
|
||||
|
||||
const allNames = specialVisualizations.map((f) => f.funcName)
|
||||
const seen = new Set<string>()
|
||||
for (let name of allNames) {
|
||||
name = name.toLowerCase()
|
||||
if (seen.has(name)) {
|
||||
throw "Invalid special visualisations: detected a duplicate name: " + name
|
||||
}
|
||||
seen.add(name)
|
||||
}
|
||||
seen.add(name)
|
||||
}
|
||||
|
||||
return specialVisualizations
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue