Fixes to taginfo generation

This commit is contained in:
pietervdvn 2022-03-12 16:35:27 +01:00
parent 5b1555cb54
commit d3194b7491

View file

@ -5,6 +5,7 @@ import {readFileSync, writeFileSync} from "fs";
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig"; import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
import LayerConfig from "../Models/ThemeConfig/LayerConfig"; import LayerConfig from "../Models/ThemeConfig/LayerConfig";
import Constants from "../Models/Constants"; import Constants from "../Models/Constants";
import {Utils} from "../Utils";
/** /**
* Generates all the files in "Docs/TagInfo". These are picked up by the taginfo project, showing a link to the mapcomplete theme if the key is used * Generates all the files in "Docs/TagInfo". These are picked up by the taginfo project, showing a link to the mapcomplete theme if the key is used
@ -119,6 +120,10 @@ function generateTagInfoEntry(layout: LayoutConfig): any {
usedTags.push(...generateLayerUsage(layer, layout)) usedTags.push(...generateLayerUsage(layer, layout))
} }
if(usedTags.length == 0){
return undefined
}
let icon = layout.icon; let icon = layout.icon;
if (icon.startsWith("./")) { if (icon.startsWith("./")) {
@ -148,7 +153,7 @@ function generateTagInfoEntry(layout: LayoutConfig): any {
} }
// Write the URLS to the taginfo repository. Might fail if the repository is not checked ou // Write the URLS to the taginfo repository. Might fail if the repository is not checked ou
function generateProjectsOverview() { function generateProjectsOverview(files: string[]) {
try { try {
const tagInfoList = "../taginfo-projects/project_list.txt" const tagInfoList = "../taginfo-projects/project_list.txt"
let projectList = readFileSync(tagInfoList, "UTF8") let projectList = readFileSync(tagInfoList, "UTF8")
@ -169,17 +174,23 @@ function generateProjectsOverview() {
} }
function main(){
console.log("Creating taginfo project files") console.log("Creating taginfo project files")
Locale.language.setData("en") Locale.language.setData("en")
Translation.forcedLanguage = "en" Translation.forcedLanguage = "en"
const files = [] const files = []
for (const layout of AllKnownLayouts.layoutsList) { for (const layout of AllKnownLayouts.layoutsList) {
if (layout.hideFromOverview) { if (layout.hideFromOverview) {
continue; continue;
}
files.push(generateTagInfoEntry(layout));
} }
files.push(generateTagInfoEntry(layout)); generateProjectsOverview(Utils.NoNull(files));
} }
generateProjectsOverview();
main()