diff --git a/changelog.md b/changelog.md index 33fc397b6..50b9e7fef 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ ## Unreleased +* `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. diff --git a/script/cli/doc/export.lua b/script/cli/doc/export.lua index cd356b167..07d2cc416 100644 --- a/script/cli/doc/export.lua +++ b/script/cli/doc/export.lua @@ -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 diff --git a/script/vm/global.lua b/script/vm/global.lua index ed2b4802a..e54fbefde 100644 --- a/script/vm/global.lua +++ b/script/vm/global.lua @@ -23,6 +23,7 @@ local globalSubs = util.multiTable(2) ---@field links table ---@field setsCache? table ---@field cate vm.global.cate +---@field uri string local mt = {} mt.__index = mt mt.type = 'global' @@ -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 = {}, @@ -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 @@ -510,6 +512,19 @@ function vm.getAllGlobals() return allGlobals end +---@return table +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[]