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.
Summary
As discussed via Matrix, this PR adds a fresh new LuaCATS API annotations generator to this repository. Please consider this PR work in progress for the time being; I'm opening it at this point in order to discuss further work and gather feedback.
Notes
tools/generate-cats.lua
script.@examples
(with proper Lua-synatx-highlighted code blocks), and provides correct overload definitions (see below).@overload
tag, but renders multiple documentation blocks per overload as suggested by the LuaCATS documentation: "it is recommended to instead write multiple function definitions, one for each needed signature with its @param and @return annotations. This allows the functions to be as detailed as possible. Because the functions do not exist at runtime, this is acceptable."injected.lua
file containing thevec3
,Vec3
etc. globals injected fromlovr.math.*
ift.math.globals = true
. Hopefully this isn't too annoying for when folks disable that setting?@field
annotations (sourced from the newfields
property of object API definitions.)swizzles
property of the object API definitions.)Testing
To test the generated annotations in a project, point your LuaLS at it like this:
To run the generator script:
# It's important to do this from the repo root lua tools/generate-cats.lua
Todo
lovr.math.Vec3
and other objects from that module just won't work. The objects from all other modules appear to work fine. Only themath
module somehow is problematic..x
,.y
etc. vector fields to theapi
projectThere's probably more bits and pieces missing. Feedback welcome!