Skip to content

Commit

Permalink
update(generator): SDK Class Separation
Browse files Browse the repository at this point in the history
  • Loading branch information
skuzzis committed Jan 17, 2025
1 parent a17b735 commit 8ae5f06
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const dataFiles = [

let types = []
const GetType = (type) => {
if(types.includes(type)) return `number ${type}`
if (types.includes(type)) return `number ${type}`
return type
}

Expand Down Expand Up @@ -95,9 +95,10 @@ ${classVariable.toLowerCase()} = {}` : `---@meta`)
if (!existsSync(subfld)) writeFileSync(subfld, `--- @meta\n--- @alias GameEvent`)
appendFileSync(subfld, `\n--- | '"${data[key].title}"' # ${data[key].description}`)
} else if (data[key].template == "class-syntax") {
if (!existsSync("../EmmyLua/classes.lua")) writeFileSync("../EmmyLua/classes.lua", "--- @meta");
if (!existsSync("../EmmyLua/classes")) mkdirSync("../EmmyLua/classes")
writeFileSync("../EmmyLua/classes" + `/${key}.lua`, `--- @meta\n\n--- @class ${data[key].title.split(" ").join("")}${GenerateClassProperties(data[key].properties)}\n${key} = {}${!data[key].constructor.hide ? `\n\n--- This is the constructor for ${data[key].title} class.${ProcessParameters(data[key].constructor)}\n--- @return ${data[key].title}\nfunction ${data[key].title}(${Object.keys(data[key].constructor).join(", ")}) end` : ""}${GenerateClassFunctions(key, data[key])}`)

if (!existsSync("../EmmyLua/sdkclassalias.lua")) writeFileSync("../EmmyLua/sdkclassalias.lua", `--- @meta\n--- @alias AnySDKClass`)
appendFileSync("../EmmyLua/classes.lua", `\n\n--- @class ${data[key].title.split(" ").join("")}${GenerateClassProperties(data[key].properties)}\n${key} = {}${!data[key].constructor.hide ? `\n\n--- This is the constructor for ${data[key].title} class.${ProcessParameters(data[key].constructor)}\n--- @return ${data[key].title}\nfunction ${data[key].title}(${Object.keys(data[key].constructor).join(", ")}) end` : ""}${GenerateClassFunctions(key, data[key])}`)
if (data[key].description == "") appendFileSync("../EmmyLua/sdkclassalias.lua", `\n--- | ${data[key].title.split(" ").join("")}`)
}
}
Expand Down

0 comments on commit 8ae5f06

Please sign in to comment.