From c0d076750ef5268e241484a27842991e427ea16a Mon Sep 17 00:00:00 2001 From: Cody Rodgers Date: Sat, 22 Nov 2025 05:47:14 -0500 Subject: [PATCH 1/4] 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 --- script/vm/global.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/script/vm/global.lua b/script/vm/global.lua index ed2b4802a..2fe9381a2 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,17 @@ function vm.getAllGlobals() return allGlobals end +---@return table +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[] From 8f1c04229d938c00075a9e53f4a71d60d6f21bca Mon Sep 17 00:00:00 2001 From: Cody Rodgers Date: Sat, 22 Nov 2025 05:52:59 -0500 Subject: [PATCH 2/4] Update the default export.gatherGlobals() to use the new vm.getExportableGlobals() function instead --- script/cli/doc/export.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/script/cli/doc/export.lua b/script/cli/doc/export.lua index cd356b167..d7e837d6c 100644 --- a/script/cli/doc/export.lua +++ b/script/cli/doc/export.lua @@ -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 From b4e63142210d6699d602d6a14127fb9ee39e9ba8 Mon Sep 17 00:00:00 2001 From: Cody Rodgers Date: Sat, 22 Nov 2025 12:52:27 -0500 Subject: [PATCH 3/4] Changes requested by Gemini --- script/cli/doc/export.lua | 7 +------ script/vm/global.lua | 4 +++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/script/cli/doc/export.lua b/script/cli/doc/export.lua index d7e837d6c..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 globalsMap = vm.getExportableGlobals() - local globalsTable = {} - for _, g in pairs(globalsMap) do - table.insert(globalsTable, g) - end - return globalsTable + 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 2fe9381a2..e54fbefde 100644 --- a/script/vm/global.lua +++ b/script/vm/global.lua @@ -516,7 +516,9 @@ end function vm.getExportableGlobals() local exportableGlobals = {} for key, global in pairs(allGlobals) do - if not string.find(global.uri, METAPATH, 1, true) then + --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 From 6dc200f3566b209f3e76ec0be435a786882ed04b Mon Sep 17 00:00:00 2001 From: Cody Rodgers Date: Sat, 22 Nov 2025 12:55:18 -0500 Subject: [PATCH 4/4] Update changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) 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.