Skip to content

Commit c0d0767

Browse files
committed
Update the global.lua to track the source uri and add a new getExportableGlobals() to filter globals by the new source uri so standard Lua language features are excluded from the auto documentation
1 parent 996e21a commit c0d0767

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

script/vm/global.lua

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ local globalSubs = util.multiTable(2)
2323
---@field links table<uri, vm.global.link>
2424
---@field setsCache? table<uri, parser.object[]>
2525
---@field cate vm.global.cate
26+
---@field uri string
2627
local mt = {}
2728
mt.__index = mt
2829
mt.type = 'global'
@@ -155,10 +156,11 @@ end
155156

156157
---@param cate vm.global.cate
157158
---@return vm.global
158-
local function createGlobal(name, cate)
159+
local function createGlobal(name, cate, uri)
159160
return setmetatable({
160161
name = name,
161162
cate = cate,
163+
uri = uri,
162164
links = util.multiTable(2, function ()
163165
return {
164166
sets = {},
@@ -444,7 +446,7 @@ function vm.declareGlobal(cate, name, uri)
444446
globalSubs[uri][key] = true
445447
end
446448
if not allGlobals[key] then
447-
allGlobals[key] = createGlobal(name, cate)
449+
allGlobals[key] = createGlobal(name, cate, uri)
448450
end
449451
return allGlobals[key]
450452
end
@@ -510,6 +512,17 @@ function vm.getAllGlobals()
510512
return allGlobals
511513
end
512514

515+
---@return table<string, vm.global>
516+
function vm.getExportableGlobals()
517+
local exportableGlobals = {}
518+
for key, global in pairs(allGlobals) do
519+
if not string.find(global.uri, METAPATH, 1, true) then
520+
exportableGlobals[key] = global
521+
end
522+
end
523+
return exportableGlobals
524+
end
525+
513526
---@param suri uri
514527
---@param cate vm.global.cate
515528
---@return parser.object[]

0 commit comments

Comments
 (0)