From 71885b139cdae9f3d65268278882bd4793f4fe24 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, 25 Apr 2023 16:57:52 +0800 Subject: export name and comment in returns --- script/cli/doc.lua | 7 +++++++ script/core/hover/description.lua | 3 +++ script/vm/compiler.lua | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/script/cli/doc.lua b/script/cli/doc.lua index efaa70c8..c643deea 100644 --- a/script/cli/doc.lua +++ b/script/cli/doc.lua @@ -59,6 +59,13 @@ local function packObject(source, mark) end new['view'] = getLabel(source, source.parent.type == 'setmethod') end + if source.type == 'local' + or source.type == 'self' then + new['name'] = source[1] + end + if source.type == 'function.return' then + new['desc'] = source.comment and getDesc(source.comment) + end if source.type == 'doc.type.table' then new['fields'] = packObject(source.fields, mark) end diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua index d515313b..f5890b21 100644 --- a/script/core/hover/description.lua +++ b/script/core/hover/description.lua @@ -512,6 +512,9 @@ return function (source) if source.type == 'string' then return asString(source) end + if source.type == 'doc.tailcomment' then + return source.text + end if source.type == 'field' then source = source.parent end diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 8487ec56..d4309cc9 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -478,6 +478,7 @@ function vm.getReturnOfFunction(func, index) parent = func, returnIndex = index, } + vm.compileNode(func._returns[index]) end return func._returns[index] end @@ -1382,6 +1383,10 @@ local compilerSwitch = util.switch() lastReturn = rtn if rtn.returnIndex == index then hasMarkDoc = true + source.comment = doc.comment + if rtn.name then + source.name = rtn.name[1] + end local hasGeneric if sign then guide.eachSourceType(rtn, 'doc.generic.name', function (src) -- cgit v1.2.3