From bd9566eb4c856d041e705be59e9b62b0a09d3ed4 Mon Sep 17 00:00:00 2001 From: sumneko Date: Sun, 6 Mar 2022 21:40:34 +0800 Subject: update --- script/parser/guide.lua | 11 +++++------ script/parser/luadoc.lua | 32 +++++++++++++++----------------- 2 files changed, 20 insertions(+), 23 deletions(-) (limited to 'script/parser') diff --git a/script/parser/guide.lua b/script/parser/guide.lua index 831534a7..9be84e4e 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -128,12 +128,11 @@ local childMap = { ['doc.generic.object'] = {'generic', 'extends', 'comment'}, ['doc.vararg'] = {'vararg', 'comment'}, ['doc.type.array'] = {'node'}, - ['doc.type.table'] = {'tkey', 'tvalue', 'comment'}, ['doc.type.function'] = {'#args', '#returns', 'comment'}, - ['doc.type.ltable'] = {'#fields', 'comment'}, + ['doc.type.table'] = {'#fields', 'comment'}, ['doc.type.literal'] = {'node'}, ['doc.type.arg'] = {'name', 'extends'}, - ['doc.type.field'] = {'extends'}, + ['doc.type.field'] = {'name', 'extends'}, ['doc.overload'] = {'overload', 'comment'}, ['doc.see'] = {'name', 'field'}, ['doc.version'] = {'#versions'}, @@ -885,17 +884,17 @@ function m.getKeyNameOfLiteral(obj) elseif tp == 'number' then local n = obj[1] if n then - return formatNumber(obj[1]) + return obj[1] end elseif tp == 'integer' then local n = obj[1] if n then - return formatNumber(obj[1]) + return obj[1] end elseif tp == 'boolean' then local b = obj[1] if b then - return tostring(b) + return b end end end diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index ccc38eac..d516643b 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -223,25 +223,24 @@ local function parseIndexField(tp, parent) return nil end nextToken() - local class = { - type = tp, - start = getStart(), - finish = getFinish(), - parent = parent, - } - local indexTP, index = nextToken() - if indexTP ~= 'integer' - and indexTP ~= 'string' then - pushWarning { - type = 'LUADOC_INDEX_MUST_INT', + local indexTP, index = peekToken() + if indexTP == 'name' then + local field = parseType(parent) + nextSymbolOrError ']' + return field + else + nextToken() + local class = { + type = tp, start = getStart(), finish = getFinish(), + parent = parent, } + class[1] = index + nextSymbolOrError ']' + class.finish = getFinish() + return class end - class[1] = index - nextSymbolOrError ']' - class.finish = getFinish() - return class end local function parseClass(parent) @@ -427,7 +426,7 @@ end local function parseTypeUnitLiteralTable() local typeUnit = { - type = 'doc.type.ltable', + type = 'doc.type.table', start = getStart(), fields = {}, } @@ -527,7 +526,6 @@ function parseTypeUnit(parent, content) result.parent = parent while true do local newResult = parseTypeUnitArray(parent, result) - or parseTypeUnitTable(parent, result) if not newResult then break end -- cgit v1.2.3