summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-09-14 16:52:15 +0200
committermadmaxoft <github@xoft.cz>2013-09-14 16:52:15 +0200
commitde77eaaecdb36dacfb2a616a07588670f2375006 (patch)
treef461c146af48d027a0fe932fb66d09efc6ad1dcd /MCServer/Plugins
parentAPIDump: Do not dump the g_APIDesc and APIDump's functions. (diff)
downloadcuberite-de77eaaecdb36dacfb2a616a07588670f2375006.tar
cuberite-de77eaaecdb36dacfb2a616a07588670f2375006.tar.gz
cuberite-de77eaaecdb36dacfb2a616a07588670f2375006.tar.bz2
cuberite-de77eaaecdb36dacfb2a616a07588670f2375006.tar.lz
cuberite-de77eaaecdb36dacfb2a616a07588670f2375006.tar.xz
cuberite-de77eaaecdb36dacfb2a616a07588670f2375006.tar.zst
cuberite-de77eaaecdb36dacfb2a616a07588670f2375006.zip
Diffstat (limited to '')
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua28
-rw-r--r--MCServer/Plugins/APIDump/main.lua42
2 files changed, 57 insertions, 13 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 7e033f2af..7d1ea4cce 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -152,10 +152,16 @@ g_APIDesc =
Functions =
{
GetContents = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the cItemGrid object representing the items stored within this block entity" },
- GetSlot = { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot number. Returns nil for invalid slot numbers" },
- GetSlot = { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot coords. Returns nil for invalid slot coords" },
- SetSlot = { Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot number. Ignored if invalid slot number" },
- SetSlot = { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot coords. Ignored if invalid slot coords" },
+ GetSlot =
+ {
+ { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot number. Returns nil for invalid slot numbers" },
+ { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot coords. Returns nil for invalid slot coords" },
+ },
+ SetSlot =
+ {
+ { Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot number. Ignored if invalid slot number" },
+ { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot coords. Ignored if invalid slot coords" },
+ },
},
Constants =
{
@@ -297,10 +303,16 @@ g_APIDesc =
GetIngredientsHeight = { Params = "", Return = "number", Notes = "Returns the height of the ingredients' grid" },
GetIngredientsWidth = { Params = "", Return = "number", Notes = "Returns the width of the ingredients' grid" },
GetResult = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the result of the recipe" },
- SetIngredient = { Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the ingredient at the specified coords" },
- SetIngredient = { Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the ingredient at the specified coords" },
- SetResult = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the result item" },
- SetResult = { Params = "ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the result item" },
+ SetIngredient =
+ {
+ { Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the ingredient at the specified coords" },
+ { Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the ingredient at the specified coords" },
+ },
+ SetResult =
+ {
+ { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the result item" },
+ { Params = "ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the result item" },
+ },
},
Constants =
{
diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua
index 35b99eb8b..e1aa39dd2 100644
--- a/MCServer/Plugins/APIDump/main.lua
+++ b/MCServer/Plugins/APIDump/main.lua
@@ -269,20 +269,42 @@ function ReadDescriptions(a_API)
end
end
end
+
+ cls.Undocumented = {}; -- This will contain all the API objects that are not documented
+
+ local DoxyFunctions = {}; -- This will contain all the API functions together with their documentation
+
+ local function AddFunction(a_Name, a_Params, a_Return, a_Notes)
+ table.insert(DoxyFunctions, {Name = a_Name, Params = a_Params, Return = a_Return, Notes = a_Notes});
+ end
if (APIDesc.Functions ~= nil) then
-- Assign function descriptions:
for j, func in ipairs(cls.Functions) do
local FnName = func.DocID or func.Name;
local FnDesc = APIDesc.Functions[FnName];
- if (FnDesc ~= nil) then
- func.Params = FnDesc.Params;
- func.Return = FnDesc.Return;
- func.Notes = FnDesc.Notes;
+ if (FnDesc == nil) then
+ -- No description for this API function
+ AddFunction(func.Name);
+ table.insert(cls.Undocumented, func.Name);
+ else
+ -- Description is available
+ if (FnDesc[1] == nil) then
+ -- Single function definition
+ AddFunction(func.Name, FnDesc.Params, FnDesc.Return, FnDesc.Notes);
+ else
+ -- Multiple function overloads
+ for k, desc in ipairs(FnDesc) do
+ AddFunction(func.Name, desc.Params, desc.Return, desc.Notes);
+ end -- for k, desc - FnDesc[]
+ end
FnDesc.IsExported = true;
end
end -- for j, func
+ -- Replace functions with their described and overload-expanded versions:
+ cls.Functions = DoxyFunctions;
+
-- Add all non-exported function descriptions to UnexportedDocumented:
for j, func in pairs(APIDesc.Functions) do
-- TODO
@@ -293,7 +315,10 @@ function ReadDescriptions(a_API)
-- Assign constant descriptions:
for j, cons in ipairs(cls.Constants) do
local CnDesc = APIDesc.Constants[cons.Name];
- if (CnDesc ~= nil) then
+ if (CnDesc == nil) then
+ -- Not documented
+ table.insert(cls.Undocumented, cons.Name);
+ else
cons.Notes = CnDesc.Notes;
CnDesc.IsExported = true;
end
@@ -318,6 +343,13 @@ function ReadDescriptions(a_API)
-- Sort the functions (they may have been renamed):
table.sort(cls.Functions,
function(f1, f2)
+ if (f1.Name == f2.Name) then
+ -- Same name, either comparing the same function to itself, or two overloads, in which case compare the params
+ if ((f1.Params == nil) or (f2.Params == nil)) then
+ return 0;
+ end
+ return (f1.Params < f2.Params);
+ end
return (f1.Name < f2.Name);
end
);