Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed on Discord, this is my first attempt at generating subclasses.
Anywhere the json docs for an attribute or method have a
subclasses
field, we currently just note that in the docs, the same way the official html docs do, e.g. "Can only be used if this is Ghost, CombatRobot, HighlightBox, SmokeWithTrigger or Sticker". This PR changes that behavior to instead generate new classes. Instead of oneLuaEntity
with dozens of "Can only be used if..." fields and methods, we haveLuaEntity.base
with the parts that are not specific to any subclasses, and new classes such asLuaEntity.Spawner
andLuaEntity.CombatRobot
with the subclass-specific parts. Then to wrap it all up the originalLuaEntity
identifier is now an alias that unions all the subclasses with the base class, similar to howvariant_parameter_groups
are currently handled.Notable places to look in the generated output are
LuaEntity
,LuaEntityPrototype
,LuaGuiElement
, andLuaGuiElement_funcs
, although the effects are wide reaching.---@alias LuaEntity (LuaEntity.Spawner)|(LuaEntity.Unit)|(LuaEntity.ProgrammableSpeaker)|(LuaEntity.Character)|(...|(LuaEntity.base)
---@alias LuaGuiElement_funcs (LuaGuiElement_funcs.drop-down)|(LuaGuiElement_funcs.list-box)|(LuaGuiElement_funcs.tabbed-pane)|...|(LuaGuiElement_funcs.base)
I haven't done a thorough test or diff between the old and new generated output. I'm posting this before I fall asleep in case there's useful review feedback I can act on when I pick this back up soon.
I'm also not sure I like the way the _funcs naming scheme ends up with subclasses.