Readd wiki page generation

This commit is contained in:
Pieter Vander Vennet 2022-10-27 22:03:41 +02:00
parent 9a4cdaf1ad
commit cb68a89495

View file

@ -1,6 +1,5 @@
import Combine from "../UI/Base/Combine"
import BaseUIElement from "../UI/BaseUIElement"
import Translations from "../UI/i18n/Translations"
import { existsSync, mkdirSync, writeFileSync } from "fs"
import { AllKnownLayouts } from "../Customizations/AllKnownLayouts"
import TableOfContents from "../UI/Base/TableOfContents"
@ -14,6 +13,9 @@ import QueryParameterDocumentation from "../UI/QueryParameterDocumentation"
import ScriptUtils from "./ScriptUtils"
import List from "../UI/Base/List"
import SharedTagRenderings from "../Customizations/SharedTagRenderings"
import {writeFile} from "fs";
import Translations from "../UI/i18n/Translations";
import * as themeOverview from "../assets/generated/theme_overview.json"
function WriteFile(
filename,
@ -58,6 +60,55 @@ function WriteFile(
writeFileSync(filename, md)
}
function generateWikipage(){
function generateWikiEntry(layout: { hideFromOverview: boolean, id: string, shortDescription: any }) {
if (layout.hideFromOverview) {
return "";
}
const languagesInDescr = []
for (const shortDescriptionKey in layout.shortDescription) {
languagesInDescr.push(shortDescriptionKey)
}
const languages = languagesInDescr.map(ln => `{{#language:${ln}|en}}`).join(", ")
let auth = "Yes";
return `{{service_item
|name= [https://mapcomplete.osm.be/${layout.id} ${layout.id}]
|region= Worldwide
|lang= ${languages}
|descr= A MapComplete theme: ${Translations.T(layout.shortDescription)
.textFor("en")
.replace("<a href='", "[[")
.replace(/'>.*<\/a>/, "]]")
}
|material= {{yes|[https://mapcomplete.osm.be/ ${auth}]}}
|image= MapComplete_Screenshot.png
|genre= POI, editor, ${layout.id}
}}`
}
let wikiPage = "{|class=\"wikitable sortable\"\n" +
"! Name, link !! Genre !! Covered region !! Language !! Description !! Free materials !! Image\n" +
"|-";
for (const layout of themeOverview) {
if (layout.hideFromOverview) {
continue;
}
wikiPage += "\n" + generateWikiEntry(layout);
}
wikiPage += "\n|}"
writeFile("Docs/wikiIndex.txt", wikiPage, (err) => {
if (err !== null) {
console.log("Could not save wikiindex", err);
}
});
}
console.log("Starting documentation generation...")
AllKnownLayouts.GenOverviewsForSingleLayer((layer, element, inlineSource) => {
console.log("Exporting ", layer.id)
@ -148,5 +199,5 @@ WriteFile("./Docs/URL_Parameters.md", QueryParameterDocumentation.GenerateQueryP
"Logic/Web/QueryParameters.ts",
"UI/QueryParameterDocumentation.ts",
])
generateWikipage()
console.log("Generated docs")