Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
<!-- Add all new changes here. They will be moved under a version at release -->
* `FIX` Autodoc generation so it does not include documentation for builtin Lua language features
* `FIX` Incorrect generation of function signatures with tuple-parameters
* `NEW` Doc output now contains file paths for `@alias` and `@enum` types
* `FIX` Typos in a few error messages.
Expand Down
7 changes: 1 addition & 6 deletions script/cli/doc/export.lua
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,7 @@ 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)
end
return globals
return util.valuesOf(vm.getExportableGlobals())
end

---builds a lua table of based on `globals` and their elements
Expand Down
19 changes: 17 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,19 @@ function vm.getAllGlobals()
return allGlobals
end

---@return table<string, vm.global>
function vm.getExportableGlobals()
local exportableGlobals = {}
for key, global in pairs(allGlobals) do
--If the source uri for the global matches the global variable METAPATH
--then the global is a builtin Lua language feature and should not be exported
if global.uri and 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