forked from MapComplete/MapComplete
Refactoring: port doc generation to generate markdown directly without UIElements
This commit is contained in:
parent
7a7439b161
commit
8e9c03e258
17 changed files with 309 additions and 320 deletions
|
@ -7,28 +7,29 @@ import { QueryParameters } from "../Logic/Web/QueryParameters"
|
|||
import FeatureSwitchState from "../Logic/State/FeatureSwitchState"
|
||||
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig"
|
||||
import ThemeViewStateHashActor from "../Logic/Web/ThemeViewStateHashActor"
|
||||
import MarkdownUtils from "../Utils/MarkdownUtils"
|
||||
|
||||
export default class QueryParameterDocumentation {
|
||||
private static QueryParamDocsIntro = [
|
||||
new Title("URL-parameters and URL-hash", 1),
|
||||
private static QueryParamDocsIntro: string[] = [
|
||||
"# URL-parameters and URL-hash",
|
||||
"This document gives an overview of which URL-parameters can be used to influence MapComplete.",
|
||||
new Title("What is a URL parameter?", 2),
|
||||
"## What is a URL parameter?",
|
||||
'"URL-parameters are extra parts of the URL used to set the state.',
|
||||
"For example, if the url is `https://mapcomplete.org/cyclofix?lat=51.0&lon=4.3&z=5&test=true#node/1234`, " +
|
||||
"the URL-parameters are stated in the part between the `?` and the `#`. There are multiple, all separated by `&`, namely: ",
|
||||
new List(
|
||||
MarkdownUtils.list(
|
||||
[
|
||||
"The url-parameter `lat` is `51.0` in this instance",
|
||||
"The url-parameter `lon` is `4.3` in this instance",
|
||||
"The url-parameter `z` is `5` in this instance",
|
||||
"The url-parameter `test` is `true` in this instance",
|
||||
].map((s) => Translations.W(s))
|
||||
]
|
||||
),
|
||||
"Finally, the URL-hash is the part after the `#`. It is `node/1234` in this case.",
|
||||
]
|
||||
|
||||
public static UrlParamDocs(): Map<string, string> {
|
||||
const dummyLayout = new LayoutConfig({
|
||||
const dummyLayout = new LayoutConfig(<any>{
|
||||
id: ">theme<",
|
||||
title: { en: "<theme>" },
|
||||
description: "A theme to generate docs with",
|
||||
|
@ -59,26 +60,26 @@ export default class QueryParameterDocumentation {
|
|||
QueryParameters.GetQueryParameter(
|
||||
"layer-<layer-id>",
|
||||
"true",
|
||||
"Wether or not the layer with id <layer-id> is shown"
|
||||
"Whether the layer with id <layer-id> is shown"
|
||||
)
|
||||
return QueryParameters.documentation
|
||||
}
|
||||
|
||||
public static GenerateQueryParameterDocs(): BaseUIElement {
|
||||
const docs: (string | BaseUIElement)[] = [
|
||||
public static GenerateQueryParameterDocs(): string {
|
||||
const docs: string[] = [
|
||||
...QueryParameterDocumentation.QueryParamDocsIntro,
|
||||
...ThemeViewStateHashActor.documentation,
|
||||
]
|
||||
this.UrlParamDocs().forEach((value, key) => {
|
||||
const c = new Combine([
|
||||
new Title(key, 2),
|
||||
const c = [
|
||||
"## "+key,
|
||||
value,
|
||||
QueryParameters.defaults[key] === undefined
|
||||
? "No default value set"
|
||||
: `The default value is _${QueryParameters.defaults[key]}_`,
|
||||
])
|
||||
].join("\n\n")
|
||||
docs.push(c)
|
||||
})
|
||||
return new Combine(docs).SetClass("flex flex-col")
|
||||
return docs.join("\n\n")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue