From 1f9397302c6e4381b86a15c3d28e41c9b199473e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 29 Sep 2013 00:10:42 +0200 Subject: [PATCH] APIDump: Added the possibility to ignore classes. Ignoring Lua builtins. --- MCServer/Plugins/APIDump/APIDesc.lua | 14 +++++++++++++- MCServer/Plugins/APIDump/main.lua | 27 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 0318c69ea..f260731f5 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -710,7 +710,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), despawn / remove that entity in between the calls. If you need to refer to an entity later, use its UniqueID and {{cWorld|cWorld}}'s entity manipulation functions DoWithEntityByID(), ForEachEntity() or ForEachEntityInChunk() to access the entity again.

-]], + ]], Functions = { AddPosition = @@ -1906,6 +1906,18 @@ World:ForEachEntity( }, }, + + IgnoreClasses = + { + "coroutine", + "debug", + "io", + "math", + "package", + "os", + "string", + "table", + }, IgnoreFunctions = { diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 7c200712d..a7b4f7511 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -291,6 +291,19 @@ end function ReadDescriptions(a_API) + -- Returns true if the class of the specified name is to be ignored + local function IsClassIgnored(a_ClsName) + if (g_APIDesc.IgnoreClasses == nil) then + return false; + end + for i, name in ipairs(g_APIDesc.IgnoreClasses) do + if (a_ClsName:match(name)) then + return true; + end + end + return false; + end + -- Returns true if the function (specified by its fully qualified name) is to be ignored local function IsFunctionIgnored(a_FnName) if (g_APIDesc.IgnoreFunctions == nil) then @@ -317,6 +330,20 @@ function ReadDescriptions(a_API) return false; end + -- Remove ignored classes from a_API: + local APICopy = {}; + for i, cls in ipairs(a_API) do + if not(IsClassIgnored(cls.Name)) then + table.insert(APICopy, cls); + else + LOG("Ignoring class " .. cls.Name); + end + end + for i = 1, #a_API do + a_API[i] = APICopy[i]; + end; + + -- Process the documentation for each class: for i, cls in ipairs(a_API) do -- Rename special functions: for j, fn in ipairs(cls.Functions) do