From b063a86a7a528cf8cd5fd98a05a0baa882046520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 3 Nov 2022 19:58:14 +0800 Subject: fix #1480 --- script/parser/luadoc.lua | 53 ++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'script/parser/luadoc.lua') diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index f849ecb9..42564621 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -138,18 +138,20 @@ Symbol <- ({} { }) ---@class parser.object ----@field literal boolean ----@field signs parser.object[] ----@field originalComment parser.object ----@field as? parser.object ----@field touch? integer ----@field module? string ----@field async? boolean ----@field versions? table[] ----@field names? parser.object[] ----@field path? string ----@field bindComments? parser.object[] ----@field visible? parser.visibleType +---@field literal boolean +---@field signs parser.object[] +---@field originalComment parser.object +---@field as? parser.object +---@field touch? integer +---@field module? string +---@field async? boolean +---@field versions? table[] +---@field names? parser.object[] +---@field path? string +---@field bindComments? parser.object[] +---@field visible? parser.visibleType +---@field operators? parser.object[] +---@field calls? parser.object[] local function parseTokens(text, offset) Ci = 0 @@ -822,6 +824,7 @@ local docSwitch = util.switch() type = 'doc.class', fields = {}, operators = {}, + calls = {}, } result.class = parseName('doc.class.name', result) if not result.class then @@ -1395,12 +1398,16 @@ local docSwitch = util.switch() if checkToken('symbol', '(', 1) then nextToken() - local exp = parseType(result) - if exp then - result.exp = exp - result.finish = exp.finish + if checkToken('symbol', ')', 1) then + nextToken() + else + local exp = parseType(result) + if exp then + result.exp = exp + result.finish = exp.finish + end + nextSymbolOrError ')' end - nextSymbolOrError ')' end nextSymbolOrError ':' @@ -1725,10 +1732,9 @@ local function bindDoc(source, binded) source.bindDocs = {} end source.bindDocs[#source.bindDocs+1] = doc - if source.type ~= 'function' then - doc.bindSource = source + if source.type == 'function' then + bindDocWithSource(doc, source) end - bindDocWithSource(doc, source) ok = true elseif doc.type == 'doc.param' then if isParam @@ -1897,6 +1903,13 @@ local function bindCommentsAndFields(binded) end bindCommentsToDoc(doc, comments) comments = {} + elseif doc.type == 'doc.overload' then + if class then + class.calls[#class.calls+1] = doc + doc.class = class + end + bindCommentsToDoc(doc, comments) + comments = {} elseif doc.type == 'doc.alias' or doc.type == 'doc.enum' then bindCommentsToDoc(doc, comments) -- cgit v1.2.3