forked from MapComplete/MapComplete
Docs: more tweaks to the documentation script: fix missing dir error
This commit is contained in:
parent
558a899218
commit
4db64f7a6f
1 changed files with 12 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
|||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs"
|
||||
import { AllKnownLayouts } from "../src/Customizations/AllKnownLayouts"
|
||||
import { AllKnownLayouts, AllKnownLayoutsLazy } from "../src/Customizations/AllKnownLayouts"
|
||||
import QueryParameterDocumentation from "../src/UI/QueryParameterDocumentation"
|
||||
import ScriptUtils from "./ScriptUtils"
|
||||
import Translations from "../src/UI/i18n/Translations"
|
||||
|
@ -835,23 +835,22 @@ export class GenerateDocs extends Script {
|
|||
private generateNormalLayerOverview(type: "Layers" | "Themes", subdir = "") {
|
||||
|
||||
const layerinfo: [string, string, string][] = []
|
||||
const source: {
|
||||
get(id: string): { id: string, name?: Translation, title?: Translation, description?: Translation },
|
||||
keys(): Iterable<string>
|
||||
}
|
||||
const source: ReadonlyMap<string, LayerConfig> | AllKnownLayoutsLazy
|
||||
= type === "Layers" ? AllSharedLayers.sharedLayers : AllKnownLayouts.allKnownLayouts
|
||||
const keys = Array.from(source.keys())
|
||||
keys.sort()
|
||||
|
||||
for (const id of keys) {
|
||||
const layer = source.get(id)
|
||||
let name = layer.title
|
||||
let name: Translation
|
||||
if (type === "Layers") {
|
||||
const layer_ = (<LayerConfig><unknown>layer)
|
||||
const layer_ = (<LayerConfig>layer)
|
||||
if (!layer_.isNormal()) {
|
||||
continue
|
||||
}
|
||||
name = layer.name
|
||||
name = layer_.name
|
||||
} else {
|
||||
name = (<ThemeConfig>layer).title
|
||||
}
|
||||
layerinfo.push([`[${id}](./Layers/${id})`, name.textFor(subdir), (layer["shortDescription"] ?? layer.description)?.textFor(subdir)])
|
||||
}
|
||||
|
@ -878,7 +877,11 @@ export class GenerateDocs extends Script {
|
|||
["id", "name", "description"],
|
||||
layerinfo)
|
||||
]
|
||||
this.writeMarkdownFile(`./Docs/${subdir}/${type}/README.md`, doc.join("\n\n"), [`./assets/${type.toLowerCase()}/*.json`])
|
||||
const path = `./Docs/${subdir}/${type}`
|
||||
if (!existsSync(path)) {
|
||||
mkdirSync(path)
|
||||
}
|
||||
this.writeMarkdownFile(`${path}/README.md`, doc.join("\n\n"), [`./assets/${type.toLowerCase()}/*.json`])
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue