Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions script/cli/doc/export.lua
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,12 @@ end
---@async
---@return table globals
function export.gatherGlobals()
local all_globals = vm.getAllGlobals()
local globals = {}
for _, g in pairs(all_globals) do
table.insert(globals, g)
local globalsMap = vm.getExportableGlobals()
local globalsTable = {}
for _, g in pairs(globalsMap) do
table.insert(globalsTable, g)
end
return globals
return globalsTable
end

---builds a lua table of based on `globals` and their elements
Expand Down
17 changes: 15 additions & 2 deletions script/vm/global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ local globalSubs = util.multiTable(2)
---@field links table<uri, vm.global.link>
---@field setsCache? table<uri, parser.object[]>
---@field cate vm.global.cate
---@field uri string
local mt = {}
mt.__index = mt
mt.type = 'global'
Expand Down Expand Up @@ -155,10 +156,11 @@ end

---@param cate vm.global.cate
---@return vm.global
local function createGlobal(name, cate)
local function createGlobal(name, cate, uri)
return setmetatable({
name = name,
cate = cate,
uri = uri,
links = util.multiTable(2, function ()
return {
sets = {},
Expand Down Expand Up @@ -444,7 +446,7 @@ function vm.declareGlobal(cate, name, uri)
globalSubs[uri][key] = true
end
if not allGlobals[key] then
allGlobals[key] = createGlobal(name, cate)
allGlobals[key] = createGlobal(name, cate, uri)
end
return allGlobals[key]
end
Expand Down Expand Up @@ -510,6 +512,17 @@ function vm.getAllGlobals()
return allGlobals
end

---@return table<string, vm.global>
function vm.getExportableGlobals()
local exportableGlobals = {}
for key, global in pairs(allGlobals) do
if not string.find(global.uri, METAPATH, 1, true) then
exportableGlobals[key] = global
end
end
return exportableGlobals
end

---@param suri uri
---@param cate vm.global.cate
---@return parser.object[]
Expand Down
Loading