summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meta/template/io.lua3
-rw-r--r--meta/template/math.lua4
-rw-r--r--meta/template/package.lua5
-rw-r--r--meta/template/utf8.lua1
-rw-r--r--script-beta/core/hover/description.lua30
-rw-r--r--script-beta/core/hover/init.lua9
6 files changed, 45 insertions, 7 deletions
diff --git a/meta/template/io.lua b/meta/template/io.lua
index adf64ebc..c159fc4c 100644
--- a/meta/template/io.lua
+++ b/meta/template/io.lua
@@ -2,8 +2,11 @@
---#DES 'io'
---@class io*
+---#DES 'io.stdin'
---@field stdin file*
+---#DES 'io.stdout'
---@field stdout file*
+---#DES 'io.stderr'
---@field stderr file*
io = {}
diff --git a/meta/template/math.lua b/meta/template/math.lua
index a825d905..99d00555 100644
--- a/meta/template/math.lua
+++ b/meta/template/math.lua
@@ -2,11 +2,15 @@
---@DES 'math'
---@class math*
+---@DES 'math.huge'
---@field huge number
---#if VERSION >= 5.3 then
+---@DES 'math.maxinteger'
---@field maxinteger integer
+---@DES 'math.mininteger'
---@field mininteger integer
---#end
+---@DES 'math.pi'
---@field pi number
math = {}
diff --git a/meta/template/package.lua b/meta/template/package.lua
index 600a2f4c..62243607 100644
--- a/meta/template/package.lua
+++ b/meta/template/package.lua
@@ -15,10 +15,15 @@ function require(modname) end
---#DES 'package'
---@class package*
+---@DES 'package.config'
---@field conifg string
+---@DES 'package.cpath'
---@field cpath string
+---@DES 'package.loaded'
---@field loaded table
+---@DES 'package.path'
---@field path string
+---@DES 'package.preload'
---@field preload table
package = {}
diff --git a/meta/template/utf8.lua b/meta/template/utf8.lua
index f3619d68..1cc35361 100644
--- a/meta/template/utf8.lua
+++ b/meta/template/utf8.lua
@@ -3,6 +3,7 @@
---@version >5.3
---#DES 'utf8'
---@class utf8*
+---#DES 'utf8.charpattern'
---@field charpattern string
utf8 = {}
diff --git a/script-beta/core/hover/description.lua b/script-beta/core/hover/description.lua
index dd04373e..c421e3b6 100644
--- a/script-beta/core/hover/description.lua
+++ b/script-beta/core/hover/description.lua
@@ -184,13 +184,17 @@ local function tryLibrary(source)
return md:string()
end
-local function getBindComment(source)
+local function getBindComment(docGroup, base)
local lines = {}
- for _, doc in ipairs(source.bindDocs) do
+ for _, doc in ipairs(docGroup) do
if doc.type == 'doc.comment' then
lines[#lines+1] = doc.comment.text:sub(2)
- elseif #lines > 0 then
+ elseif #lines > 0 and not base then
break
+ elseif doc == base then
+ break
+ else
+ lines = {}
end
end
if #lines == 0 then
@@ -222,11 +226,11 @@ local function buildEnumChunk(docType, name)
return table.concat(lines, '\n')
end
-local function getBindEnums(source)
+local function getBindEnums(docGroup)
local mark = {}
local chunks = {}
local returnIndex = 0
- for _, doc in ipairs(source.bindDocs) do
+ for _, doc in ipairs(docGroup) do
if doc.type == 'doc.param' then
local name = doc.param[1]
if mark[name] then
@@ -253,12 +257,23 @@ local function getBindEnums(source)
return table.concat(chunks, '\n\n')
end
+local function tryDocFieldUpComment(source)
+ if source.type ~= 'doc.field' then
+ return
+ end
+ if not source.bindGroup then
+ return
+ end
+ local comment = getBindComment(source.bindGroup, source)
+ return comment
+end
+
local function tryDocComment(source)
if not source.bindDocs then
return
end
- local comment = getBindComment(source)
- local enums = getBindEnums(source)
+ local comment = getBindComment(source.bindDocs)
+ local enums = getBindEnums(source.bindDocs)
local md = markdown()
if comment then
md:add('md', comment)
@@ -292,5 +307,6 @@ return function (source)
end
return tryLibrary(source)
or tryDocOverloadToComment(source)
+ or tryDocFieldUpComment(source)
or tryDocComment(source)
end
diff --git a/script-beta/core/hover/init.lua b/script-beta/core/hover/init.lua
index a332cec0..96e01ab5 100644
--- a/script-beta/core/hover/init.lua
+++ b/script-beta/core/hover/init.lua
@@ -94,6 +94,15 @@ local function getHoverAsValue(source)
or source.type == 'setmethod'
local label = getLabel(source, oop)
local desc = getDesc(source)
+ if not desc then
+ local values = vm.getDefs(source, 'deep')
+ for _, def in ipairs(values) do
+ desc = getDesc(def)
+ if desc then
+ break
+ end
+ end
+ end
return {
label = label,
source = source,