| 
									
										
										
										
											2021-03-24 02:01:04 +01:00
										 |  |  | import Combine from "../UI/Base/Combine"; | 
					
						
							| 
									
										
										
										
											2021-06-15 00:28:59 +02:00
										 |  |  | import BaseUIElement from "../UI/BaseUIElement"; | 
					
						
							|  |  |  | import Translations from "../UI/i18n/Translations"; | 
					
						
							|  |  |  | import {writeFileSync} from "fs"; | 
					
						
							| 
									
										
										
										
											2021-11-08 02:36:01 +01:00
										 |  |  | import {AllKnownLayouts} from "../Customizations/AllKnownLayouts"; | 
					
						
							| 
									
										
										
										
											2021-11-30 22:50:48 +01:00
										 |  |  | import TableOfContents from "../UI/Base/TableOfContents"; | 
					
						
							| 
									
										
										
										
											2022-01-14 19:34:00 +01:00
										 |  |  | import SimpleMetaTaggers, {SimpleMetaTagger} from "../Logic/SimpleMetaTagger"; | 
					
						
							|  |  |  | import ValidatedTextField from "../UI/Input/ValidatedTextField"; | 
					
						
							|  |  |  | import LayoutConfig from "../Models/ThemeConfig/LayoutConfig"; | 
					
						
							|  |  |  | import SpecialVisualizations from "../UI/SpecialVisualizations"; | 
					
						
							|  |  |  | import FeatureSwitchState from "../Logic/State/FeatureSwitchState"; | 
					
						
							|  |  |  | import {ExtraFunctions} from "../Logic/ExtraFunctions"; | 
					
						
							| 
									
										
										
										
											2021-11-30 22:50:48 +01:00
										 |  |  | import Title from "../UI/Base/Title"; | 
					
						
							| 
									
										
										
										
											2022-01-14 19:34:00 +01:00
										 |  |  | import Minimap from "../UI/Base/Minimap"; | 
					
						
							|  |  |  | import {QueryParameters} from "../Logic/Web/QueryParameters"; | 
					
						
							| 
									
										
										
										
											2021-11-30 22:50:48 +01:00
										 |  |  | import QueryParameterDocumentation from "../UI/QueryParameterDocumentation"; | 
					
						
							| 
									
										
										
										
											2022-01-29 02:45:59 +01:00
										 |  |  | import ScriptUtils from "./ScriptUtils"; | 
					
						
							|  |  |  | import List from "../UI/Base/List"; | 
					
						
							| 
									
										
										
										
											2021-03-24 01:25:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-30 22:50:48 +01:00
										 |  |  | function WriteFile(filename, html: BaseUIElement, autogenSource: string[]): void { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (html instanceof Combine) { | 
					
						
							|  |  |  |         const toc = new TableOfContents(html); | 
					
						
							|  |  |  |         const els = html.getElements(); | 
					
						
							|  |  |  |         html = new Combine( | 
					
						
							|  |  |  |             [els.shift(), | 
					
						
							|  |  |  |                 toc, | 
					
						
							|  |  |  |                 ...els | 
					
						
							|  |  |  |             ] | 
					
						
							| 
									
										
										
										
											2022-01-14 19:34:00 +01:00
										 |  |  |         ).SetClass("flex flex-col") | 
					
						
							| 
									
										
										
										
											2021-11-30 22:50:48 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-14 19:34:00 +01:00
										 |  |  |     let md = new Combine([Translations.W(html), | 
					
						
							| 
									
										
										
										
											2021-11-08 02:36:01 +01:00
										 |  |  |         "\n\nThis document is autogenerated from " + autogenSource.join(", ") | 
					
						
							| 
									
										
										
										
											2022-01-14 19:34:00 +01:00
										 |  |  |     ]).AsMarkdown() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     md.replace(/\n\n\n+/g, "\n\n"); | 
					
						
							| 
									
										
										
										
											2022-01-26 21:40:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-14 19:34:00 +01:00
										 |  |  |     writeFileSync(filename, md); | 
					
						
							| 
									
										
										
										
											2021-06-15 00:28:59 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-03-13 19:07:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-14 19:34:00 +01:00
										 |  |  | console.log("Starting documentation generation...") | 
					
						
							|  |  |  | AllKnownLayouts.GenOverviewsForSingleLayer((layer, element) => { | 
					
						
							|  |  |  |     console.log("Exporting ", layer.id) | 
					
						
							|  |  |  |     WriteFile("./Docs/Layers/" + layer.id + ".md", element, [`assets/layers/${layer.id}/${layer.id}.json`]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }) | 
					
						
							| 
									
										
										
										
											2021-10-29 18:16:51 +02:00
										 |  |  | WriteFile("./Docs/SpecialRenderings.md", SpecialVisualizations.HelpMessage(), ["UI/SpecialVisualisations.ts"]) | 
					
						
							| 
									
										
										
										
											2022-01-14 19:34:00 +01:00
										 |  |  | WriteFile("./Docs/CalculatedTags.md", new Combine([new Title("Metatags", 1), | 
					
						
							|  |  |  |         SimpleMetaTaggers.HelpText(), ExtraFunctions.HelpText()]).SetClass("flex-col"), | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  |     ["SimpleMetaTagger", "ExtraFunction"]) | 
					
						
							|  |  |  | WriteFile("./Docs/SpecialInputElements.md", ValidatedTextField.HelpText(), ["ValidatedTextField.ts"]); | 
					
						
							| 
									
										
										
										
											2021-11-08 02:36:01 +01:00
										 |  |  | WriteFile("./Docs/BuiltinLayers.md", AllKnownLayouts.GenLayerOverviewText(), ["AllKnownLayers.ts"]) | 
					
						
							| 
									
										
										
										
											2022-01-14 19:34:00 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-29 02:45:59 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-02-04 01:05:35 +01:00
										 |  |  |     // Generate the builtinIndex which shows interlayer dependencies
 | 
					
						
							| 
									
										
										
										
											2022-01-29 02:45:59 +01:00
										 |  |  |    var layers = ScriptUtils.getLayerFiles().map(f => f.parsed) | 
					
						
							|  |  |  |     var builtinsPerLayer= new Map<string, string[]>(); | 
					
						
							|  |  |  |     var layersUsingBuiltin = new Map<string /* Builtin */, string[]>(); | 
					
						
							|  |  |  |     for (const layer of layers) { | 
					
						
							|  |  |  |         if(layer.tagRenderings === undefined){ | 
					
						
							|  |  |  |             continue | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         const usedBuiltins : string[] = [] | 
					
						
							|  |  |  |         for (const tagRendering of layer.tagRenderings) { | 
					
						
							|  |  |  |             if(typeof tagRendering === "string"){ | 
					
						
							|  |  |  |                 usedBuiltins.push(tagRendering) | 
					
						
							|  |  |  |                 continue | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             if(tagRendering["builtin"] !== undefined){ | 
					
						
							|  |  |  |                 const builtins = tagRendering["builtin"] | 
					
						
							|  |  |  |                 if(typeof builtins === "string"){ | 
					
						
							|  |  |  |                     usedBuiltins.push(builtins) | 
					
						
							|  |  |  |                 }else{ | 
					
						
							|  |  |  |                     usedBuiltins.push(...builtins) | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         for (const usedBuiltin of usedBuiltins) { | 
					
						
							|  |  |  |             var using = layersUsingBuiltin.get(usedBuiltin) | 
					
						
							|  |  |  |             if(using === undefined){ | 
					
						
							|  |  |  |                 layersUsingBuiltin.set(usedBuiltin, [layer.id]) | 
					
						
							|  |  |  |             }else{ | 
					
						
							|  |  |  |                 using.push(layer.id) | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |          | 
					
						
							|  |  |  |         builtinsPerLayer.set(layer.id, usedBuiltins) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     const docs = new Combine([ | 
					
						
							|  |  |  |         new Title("Index of builtin TagRendering" ,1), | 
					
						
							|  |  |  |         new Title("Existing builtin tagrenderings", 2), | 
					
						
							|  |  |  |         ... Array.from(layersUsingBuiltin.entries()).map(([builtin, usedByLayers]) =>  | 
					
						
							|  |  |  |                 new Combine([ | 
					
						
							|  |  |  |                     new Title(builtin), | 
					
						
							|  |  |  |                     new List(usedByLayers) | 
					
						
							|  |  |  |                 ]).SetClass("flex flex-col") | 
					
						
							|  |  |  |             ) | 
					
						
							|  |  |  |     ]).SetClass("flex flex-col") | 
					
						
							|  |  |  |     WriteFile("./Docs/BuiltinIndex.md", docs, ["assets/layers/*.json"]) | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-01-14 19:34:00 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-28 03:21:17 +02:00
										 |  |  | Minimap.createMiniMap = _ => { | 
					
						
							|  |  |  |     console.log("Not creating a minimap, it is disabled"); | 
					
						
							|  |  |  |     return undefined | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-22 01:06:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-28 03:21:17 +02:00
										 |  |  | const dummyLayout = new LayoutConfig({ | 
					
						
							| 
									
										
										
										
											2021-12-09 18:01:11 +01:00
										 |  |  |     id: ">theme<", | 
					
						
							| 
									
										
										
										
											2021-06-15 00:28:59 +02:00
										 |  |  |     maintainer: "pietervdvn", | 
					
						
							|  |  |  |     version: "0", | 
					
						
							| 
									
										
										
										
											2022-01-29 02:45:59 +01:00
										 |  |  |     title: {en:"<theme>"}, | 
					
						
							| 
									
										
										
										
											2021-06-15 00:28:59 +02:00
										 |  |  |     description: "A theme to generate docs with", | 
					
						
							| 
									
										
										
										
											2022-01-29 02:45:59 +01:00
										 |  |  |     socialImage: "./assets/SocialImage.png", | 
					
						
							| 
									
										
										
										
											2021-06-15 00:28:59 +02:00
										 |  |  |     startLat: 0, | 
					
						
							|  |  |  |     startLon: 0, | 
					
						
							|  |  |  |     startZoom: 0, | 
					
						
							|  |  |  |     icon: undefined, | 
					
						
							|  |  |  |     layers: [ | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             name: "<layer>", | 
					
						
							| 
									
										
										
										
											2021-12-09 18:01:11 +01:00
										 |  |  |             id: "<layer>", | 
					
						
							| 
									
										
										
										
											2021-06-15 00:28:59 +02:00
										 |  |  |             source: { | 
					
						
							|  |  |  |                 osmTags: "id~*" | 
					
						
							| 
									
										
										
										
											2021-10-28 03:21:17 +02:00
										 |  |  |             }, | 
					
						
							| 
									
										
										
										
											2021-11-30 22:50:48 +01:00
										 |  |  |             mapRendering: null, | 
					
						
							| 
									
										
										
										
											2021-06-15 00:28:59 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-28 03:21:17 +02:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | new FeatureSwitchState(dummyLayout) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 18:01:11 +01:00
										 |  |  | QueryParameters.GetQueryParameter("layer-<layer-id>", "true", "Wether or not the layer with id <layer-id> is shown") | 
					
						
							| 
									
										
										
										
											2021-06-15 00:28:59 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-30 22:50:48 +01:00
										 |  |  | WriteFile("./Docs/URL_Parameters.md", QueryParameterDocumentation.GenerateQueryParameterDocs(), ["QueryParameters"]) | 
					
						
							| 
									
										
										
										
											2021-03-22 01:06:24 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | console.log("Generated docs") | 
					
						
							|  |  |  | 
 |