Skip to content

Commit 7eaec04

Browse files
committed
update meta files for love2d and lovr
1 parent 9060bc4 commit 7eaec04

File tree

6 files changed

+30
-13
lines changed

6 files changed

+30
-13
lines changed

meta/3rd/love2d/library/love.graphics.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ function love.graphics.newFont(filename) end
569569
---@overload fun(imageData: love.ImageData, flags: table):love.Image
570570
---@overload fun(compressedImageData: love.CompressedImageData, flags: table):love.Image
571571
---@param filename string # The filepath to the image file.
572-
---@param flags {dpiscale: number, linear: boolean, mipmaps: boolean} # A table containing the following fields:
572+
---@param flags? {dpiscale: number, linear: boolean, mipmaps: boolean} # A table containing the following fields:
573573
---@return love.Image image # A new Image object which can be drawn on screen.
574574
function love.graphics.newImage(filename, flags) end
575575

meta/3rd/love2d/library/love.window.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ function love.window.setIcon(imagedata) end
229229
---
230230
---@param width number # Display width.
231231
---@param height number # Display height.
232-
---@param flags {fullscreen: boolean, fullscreentype: love.FullscreenType, vsync: boolean, msaa: number, stencil: boolean, depth: number, resizable: boolean, borderless: boolean, centered: boolean, display: number, minwidth: number, minheight: number, highdpi: boolean, x: number, y: number, usedpiscale: boolean, srgb: boolean} # The flags table with the options:
232+
---@param flags? {fullscreen: boolean, fullscreentype: love.FullscreenType, vsync: boolean, msaa: number, stencil: boolean, depth: number, resizable: boolean, borderless: boolean, centered: boolean, display: number, minwidth: number, minheight: number, highdpi: boolean, x: number, y: number, usedpiscale: boolean, srgb: boolean} # The flags table with the options:
233233
---@return boolean success # True if successful, false otherwise.
234234
function love.window.setMode(width, height, flags) end
235235

meta/3rd/lovr/library/lovr.audio.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ function lovr.audio.isStarted(type) end
186186
---@overload fun(blob: lovr.Blob, options: table):lovr.Source
187187
---@overload fun(sound: lovr.Sound, options: table):lovr.Source
188188
---@param filename string # The filename of the sound to load.
189-
---@param options {decode: boolean, effects: table} # Optional options.
189+
---@param options? {decode: boolean, effects: table} # Optional options.
190190
---@return lovr.Source source # The new Source.
191191
function lovr.audio.newSource(filename, options) end
192192

meta/3rd/lovr/library/lovr.graphics.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function lovr.graphics.compute(shader, x, y, z) end
129129
---
130130
---The window must be created before any `lovr.graphics` functions can be used.
131131
---
132-
---@param flags {width: number, height: number, fullscreen: boolean, resizable: boolean, msaa: number, title: string, icon: string, vsync: number} # Flags to customize the window's appearance and behavior.
132+
---@param flags? {width: number, height: number, fullscreen: boolean, resizable: boolean, msaa: number, title: string, icon: string, vsync: number} # Flags to customize the window's appearance and behavior.
133133
function lovr.graphics.createWindow(flags) end
134134

135135
---

tools/love-api.lua

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,16 @@ local function formatIndex(key)
5151
end
5252

5353
local function isTableOptional(tbl)
54-
local optional = true
55-
for _, field in ipairs(tbl) do
56-
if field.default == nil then
57-
optional = nil
58-
end
59-
end
60-
return optional
54+
if not tbl then
55+
return false
56+
end
57+
local optional = true
58+
for _, field in ipairs(tbl) do
59+
if field.default == nil then
60+
optional = nil
61+
end
62+
end
63+
return optional
6164
end
6265

6366
local buildType
@@ -156,7 +159,7 @@ local function buildFunction(func, node, typeName)
156159
for _, param in ipairs(func.variants[1].arguments or {}) do
157160
for paramName in param.name:gmatch '[%a_][%w_]*' do
158161
params[#params+1] = paramName
159-
local optional = param.type == 'table' and isTableOptional(param.table) or (param.default ~= nil)
162+
local optional = param.type == 'table' and isTableOptional(param.table) or (param.default ~= nil)
160163
text[#text+1] = ('---@param %s%s %s # %s'):format(
161164
paramName,
162165
optional and '?' or '',

tools/lovr-api.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ local function formatIndex(key)
5151
return ('[%q]'):format(key)
5252
end
5353

54+
local function isTableOptional(tbl)
55+
if not tbl then
56+
return false
57+
end
58+
local optional = true
59+
for _, field in ipairs(tbl) do
60+
if field.default == nil then
61+
optional = nil
62+
end
63+
end
64+
return optional
65+
end
66+
5467
local buildType
5568

5669
local function buildDocTable(tbl)
@@ -150,9 +163,10 @@ local function buildFunction(func, typeName)
150163
for _, param in ipairs(func.variants[1].arguments or {}) do
151164
for paramName in param.name:gmatch '[%a_][%w_]*' do
152165
params[#params+1] = paramName
166+
local optional = param.type == 'table' and isTableOptional(param.table) or (param.default ~= nil)
153167
text[#text+1] = ('---@param %s%s %s # %s'):format(
154168
paramName,
155-
param.default == nil and '' or '?',
169+
optional and '?' or '',
156170
buildType(param),
157171
param.description
158172
)

0 commit comments

Comments
 (0)