|
1 | 1 | import { ClassFunction, Enum, Function, HookFunction, LibraryFunction, Panel, PanelFunction, Realm, Struct, WikiPage, isPanel } from '../scrapers/wiki-page-markup-scraper.js'; |
2 | | -import { putCommentBeforeEachLine, removeNewlines, toLowerCamelCase } from '../utils/string.js'; |
| 2 | +import { putCommentBeforeEachLine, removeNewlines, safeFileName, toLowerCamelCase } from '../utils/string.js'; |
3 | 3 | import { |
4 | 4 | isClassFunction, |
5 | 5 | isHookFunction, |
@@ -62,19 +62,20 @@ export class GluaApiWriter { |
62 | 62 | } |
63 | 63 |
|
64 | 64 | public addOverride(pageAddress: string, override: string) { |
65 | | - this.pageOverrides.set(pageAddress, override); |
| 65 | + this.pageOverrides.set(safeFileName(pageAddress, '.'), override); |
66 | 66 | } |
67 | 67 |
|
68 | 68 | public writePage(page: WikiPage) { |
69 | | - if (this.pageOverrides.has(page.address)) { |
| 69 | + const fileSafeAddress = safeFileName(page.address, '.'); |
| 70 | + if (this.pageOverrides.has(fileSafeAddress)) { |
70 | 71 | let api = ''; |
71 | 72 |
|
72 | 73 | if (isClassFunction(page)) |
73 | 74 | api += this.writeClass(page.parent); |
74 | 75 | else if (isLibraryFunction(page)) |
75 | 76 | api += this.writeLibraryGlobal(page); |
76 | 77 |
|
77 | | - api += this.pageOverrides.get(page.address); |
| 78 | + api += this.pageOverrides.get(fileSafeAddress); |
78 | 79 |
|
79 | 80 | return `${api}\n\n`; |
80 | 81 | } else if (isClassFunction(page)) |
@@ -184,18 +185,8 @@ export class GluaApiWriter { |
184 | 185 | } |
185 | 186 | }; |
186 | 187 |
|
187 | | - for (const item of _enum.items) { |
188 | | - const keys = item.key.split(' or '); |
189 | | - |
190 | | - if (keys.length > 1) { |
191 | | - console.warn(`Enum item ${item.key} has multiple keys. This is not supported by the Glua API.`); |
192 | | - for (const key of keys) { |
193 | | - writeItem(key, item); |
194 | | - } |
195 | | - } else { |
196 | | - writeItem(item.key, item); |
197 | | - } |
198 | | - } |
| 188 | + for (const item of _enum.items) |
| 189 | + writeItem(item.key, item); |
199 | 190 |
|
200 | 191 | if (isContainedInTable) |
201 | 192 | api += '}'; |
|
0 commit comments