summaryrefslogtreecommitdiffstats
path: root/Server/Plugins/APIDump/main_APIDump.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Server/Plugins/APIDump/main_APIDump.lua')
-rw-r--r--Server/Plugins/APIDump/main_APIDump.lua62
1 files changed, 62 insertions, 0 deletions
diff --git a/Server/Plugins/APIDump/main_APIDump.lua b/Server/Plugins/APIDump/main_APIDump.lua
index b1277ca0b..735a6ec05 100644
--- a/Server/Plugins/APIDump/main_APIDump.lua
+++ b/Server/Plugins/APIDump/main_APIDump.lua
@@ -2041,6 +2041,56 @@ end
+--- Checks if any functions that are documented are present in the API
+-- Returns an array-table of strings representing the unexported symbol names
+-- If no unexported are found, returns no value.
+-- If an error occurs, returns true and error message.
+local function CheckUnexportedFunctions()
+ local res = {}
+
+ local API, Globals, Desc = PrepareApi()
+ for clsname, cls in pairs(Desc.Classes) do
+ if not(cls.IsExported) then
+ -- The whole class is not exported
+ table.insert(res, "class\t" .. clsname .. "\n");
+ else
+ if (cls.Functions ~= nil) then
+ for fnname, fnapi in pairs(cls.Functions) do
+ if not(fnapi.IsExported) then
+ table.insert(res, "func\t" .. clsname .. "." .. fnname);
+ end
+ end -- for j, fn - cls.Functions[]
+ end
+ if (cls.Constants ~= nil) then
+ for cnname, cnapi in pairs(cls.Constants) do
+ if not(cnapi.IsExported) then
+ table.insert(res, "const\t" .. clsname .. "." .. cnname);
+ end
+ end -- for j, fn - cls.Functions[]
+ end
+ end
+ end -- for i, cls - a_APIDesc.Classes[]
+
+ table.sort(res)
+
+ -- Bail out if no items found:
+ if not(res[1]) then
+ return
+ end
+
+ -- Save any found items to a file:
+ local f = io.open("Unexported.lua", "w")
+ f:write(table.concat(res, "\n"))
+ f:write("\n")
+ f:close()
+
+ return res
+end
+
+
+
+
+
local function HandleWebAdminDump(a_Request)
if (a_Request.PostParams["Dump"] ~= nil) then
@@ -2101,6 +2151,18 @@ local function HandleCmdApiCheck(a_Split, a_EntireCmd)
end
end
+ LOG("Checking for unexported Objects...")
+ local unexported, msg = CheckUnexportedFunctions()
+ if (unexported) then
+ if (unexported == true) then
+ LOGERROR("Cannot check for unexported symbols: " .. (msg or "<no message>"))
+ return true
+ else
+ LOGERROR("Found unexported symbols:\n" .. table.concat(unexported, "\n"))
+ return true
+ end
+ end
+
-- The check completed successfully, remove the "test failed" flag from the filesystem:
cFile:DeleteFile("apiCheckFailed.flag")