Skip to content

Commit 8db0ff6

Browse files
committed
Derive panels D... from Panel
1 parent 321292e commit 8db0ff6

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/api-writer/glua-api-writer.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class GluaApiWriter {
8282
return this.writeStruct(page);
8383
}
8484

85-
private writeClass(className: string, classFields: string = '') {
85+
private writeClass(className: string, parent?: string, classFields: string = '') {
8686
let api: string = '';
8787

8888
if (!this.writtenClasses.has(className)) {
@@ -91,7 +91,12 @@ export class GluaApiWriter {
9191
api += this.pageOverrides.get(classOverride)!.replace(/\n$/g, '') + '\n\n';
9292
api = api.replace('---{{CLASS_FIELDS}}\n', classFields);
9393
} else {
94-
api += `---@class ${className}\n`;
94+
api += `---@class ${className}`;
95+
96+
if (parent)
97+
api += ` : ${parent}`;
98+
99+
api += '\n';
95100
api += classFields;
96101
api += `local ${className} = {}\n\n`;
97102
}
@@ -131,7 +136,12 @@ export class GluaApiWriter {
131136
}
132137

133138
private writePanelFunction(func: PanelFunction) {
134-
return this.writeClassFunction(func);
139+
let api: string = this.writeClass(func.parent, 'Panel');
140+
141+
api += this.writeFunctionLuaDocComment(func, func.realm);
142+
api += this.writeFunctionDeclaration(func, func.realm, ':');
143+
144+
return api;
135145
}
136146

137147
private writeEnum(_enum: Enum) {
@@ -165,7 +175,7 @@ export class GluaApiWriter {
165175
fields += `---@field ${GluaApiWriter.safeName(field.name)} ${this.transformType(field.type)} ${removeNewlines(field.description!)}\n`;
166176
}
167177

168-
return this.writeClass(struct.name, fields);
178+
return this.writeClass(struct.name, undefined, fields);
169179
}
170180

171181
public writePages(pages: WikiPage[]) {

0 commit comments

Comments
 (0)