From 2646668ef25f8a90d07f2cc929a037e62c729381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 20 Jul 2021 19:40:14 +0800 Subject: update --- tools/love-api.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/love-api.lua b/tools/love-api.lua index f909d200..954d542f 100644 --- a/tools/love-api.lua +++ b/tools/love-api.lua @@ -45,17 +45,25 @@ local function getTypeName(names) end local function formatIndex(key) - if key:match '^[%a_][%w_]+$' then + if key:match '^[%a_][%w_]*$' then return key end return ('[%q]'):format(key) end +local buildType + local function buildDocTable(tbl) - + local fields = {} + for _, field in ipairs(tbl) do + if field.name ~= '...' then + fields[#fields+1] = ('%s: %s'):format(formatIndex(field.name), field.type) + end + end + return ('{%s}'):format(table.concat(fields, ', ')) end -local function buildType(param) +function buildType(param) if param.table then return buildDocTable(param.table) end -- cgit v1.2.3