This commit is contained in:
maji
2025-12-29 21:51:30 +07:00
parent b62187cce4
commit cc54e1a723
68 changed files with 309 additions and 39 deletions

View File

@@ -4,6 +4,7 @@ const { XMLParser } = require("fast-xml-parser");
const xmlAPIPath = path.join(__dirname, "../", "xml", "types")
const mdAPIPath = path.join(__dirname, "../", "docs/api", "types")
const iconDataPath = path.join(__dirname, "../", "docs/theme/.icons", "polytoria")
const xmlEnumPath = path.join(__dirname, "../", "xml", "enums")
const mdEnumPath = path.join(__dirname, "../", "docs/api", "enums")
@@ -29,16 +30,17 @@ const parser = new XMLParser();
const xmlFiles = fs.readdirSync(xmlAPIPath).filter(file => file.endsWith('.xml'));
for (const xmlFile of xmlFiles) {
const xmlPath = path.join(xmlAPIPath, xmlFile);
const xmlContent = fs.readFileSync(xmlPath, "utf-8");
const data = parser.parse(xmlContent);
const xmlPath = path.join(xmlAPIPath, xmlFile)
const xmlContent = fs.readFileSync(xmlPath, "utf-8")
const data = parser.parse(xmlContent)
if (!data.ClassDef) continue;
const c = data.ClassDef;
const className = path.basename(xmlFile, '.xml');
const className = path.basename(xmlFile, '.xml')
let mdPath = path.join(mdAPIPath, className + ".md")
let mk = ""
const iconPath = path.join(iconDataPath, c.Name + ".svg")
function appendLine(str) {
mk += str + "\n"
@@ -47,6 +49,11 @@ for (const xmlFile of xmlFiles) {
appendLine("---")
appendLine("title: " + c.Name)
appendLine("description:")
if (fs.existsSync(iconPath)) {
appendLine("icon: polytoria/" + c.Name)
} else {
appendLine("icon: polytoria/Unknown")
}
appendLine("---")
appendLine("")
appendLine("# " + c.Name)