summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/APIDump
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-10-18 21:29:38 +0200
committermadmaxoft <github@xoft.cz>2013-10-18 21:29:38 +0200
commit07ba48840da5447e12d8c54a20c0f049a3ec67a7 (patch)
tree1e5a08adea2f60940c4bca3269abaa3ebae360e5 /MCServer/Plugins/APIDump
parentAPIDump: Added prettify's license. (diff)
downloadcuberite-07ba48840da5447e12d8c54a20c0f049a3ec67a7.tar
cuberite-07ba48840da5447e12d8c54a20c0f049a3ec67a7.tar.gz
cuberite-07ba48840da5447e12d8c54a20c0f049a3ec67a7.tar.bz2
cuberite-07ba48840da5447e12d8c54a20c0f049a3ec67a7.tar.lz
cuberite-07ba48840da5447e12d8c54a20c0f049a3ec67a7.tar.xz
cuberite-07ba48840da5447e12d8c54a20c0f049a3ec67a7.tar.zst
cuberite-07ba48840da5447e12d8c54a20c0f049a3ec67a7.zip
Diffstat (limited to 'MCServer/Plugins/APIDump')
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua9
-rw-r--r--MCServer/Plugins/APIDump/main.lua54
2 files changed, 59 insertions, 4 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 4961c9baf..0a1e91a54 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -31,6 +31,11 @@ g_APIDesc =
ConstantName = { Notes = "Notes about the constant" },
} ,
+ Variables =
+ {
+ VariableName = { Type = "string", Notes = "Notes about the variable" },
+ } ,
+
AdditionalInfo = -- Paragraphs to be exported after the function definitions table
{
{
@@ -610,8 +615,8 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
},
Variables =
{
- p1 = { Notes = "{{Vector3i}} of one corner. Usually the lesser of the two coords in each set" },
- p2 = { Notes = "{{Vector3i}} of the other corner. Usually the larger of the two coords in each set" },
+ p1 = { Type = "{{Vector3i}}", Notes = "The first corner. Usually the lesser of the two coords in each set" },
+ p2 = { Type = "{{Vector3i}}", Notes = "The second corner. Usually the larger of the two coords in each set" },
},
},
diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua
index 6d85a1281..93f3e7258 100644
--- a/MCServer/Plugins/APIDump/main.lua
+++ b/MCServer/Plugins/APIDump/main.lua
@@ -459,10 +459,21 @@ function ReadDescriptions(a_API)
end
end -- for j, cons
end -- if (APIDesc.Constants ~= nil)
- else
+
+ -- Process member variables:
+ local vars = {};
+ for name, desc in pairs(APIDesc.Variables or {}) do
+ desc.Name = name;
+ table.insert(vars, desc);
+ end
+ cls.Variables = vars;
+
+ else -- if (APIDesc ~= nil)
+
-- Class is not documented at all, add all its members to Undocumented lists:
cls.UndocumentedFunctions = {};
cls.UndocumentedConstants = {};
+ cls.Variables = {};
for j, func in ipairs(cls.Functions) do
local FnName = func.DocID or func.Name;
if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then
@@ -505,6 +516,13 @@ function ReadDescriptions(a_API)
return (c1.Name < c2.Name);
end
);
+
+ -- Sort the member variables:
+ table.sort(cls.Variables,
+ function(v1, v2)
+ return (v1.Name < v2.Name);
+ end
+ );
end -- for i, cls
-- Sort the descendants lists:
@@ -618,7 +636,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
cf:write(" <tr>\n <td>" .. func.Name .. "</td>\n");
cf:write(" <td>" .. LinkifyString(func.Params or "", (a_InheritedName or a_ClassAPI.Name)).. "</td>\n");
cf:write(" <td>" .. LinkifyString(func.Return or "", (a_InheritedName or a_ClassAPI.Name)).. "</td>\n");
- cf:write(" <td>" .. LinkifyString(func.Notes or "", (a_InheritedName or a_ClassAPI.Name)) .. "</td>\n </tr>\n");
+ cf:write(" <td>" .. LinkifyString(func.Notes or "<i>(undocumented)</i>", (a_InheritedName or a_ClassAPI.Name)) .. "</td>\n </tr>\n");
end
cf:write(" </table>\n\n");
end
@@ -641,6 +659,24 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
cf:write(" </table>\n\n");
end
+ local function WriteVariables(a_Variables, a_InheritedName)
+ if (#a_Variables == 0) then
+ return;
+ end
+
+ if (a_InheritedName ~= nil) then
+ cf:write(" <h2>Member variables inherited from " .. a_InheritedName .. "</h2>\n");
+ end
+
+ cf:write(" <table>\n <tr>\n <th>Name</th>\n <th>Type</th>\n <th>Notes</th>\n </tr>\n");
+ for i, var in ipairs(a_Variables) do
+ cf:write(" <tr>\n <td>" .. var.Name .. "</td>\n");
+ cf:write(" <td>" .. LinkifyString(var.Type or "<i>(undocumented)</i>", a_InheritedName or a_ClassAPI.Name) .. "</td>\n");
+ cf:write(" <td>" .. LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name) .. "</td>\n </tr>\n");
+ end
+ cf:write(" </table>\n\n");
+ end
+
local function WriteDescendants(a_Descendants)
if (#a_Descendants == 0) then
return;
@@ -688,10 +724,12 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
local HasConstants = (#a_ClassAPI.Constants > 0);
local HasFunctions = (#a_ClassAPI.Functions > 0);
+ local HasVariables = (#a_ClassAPI.Variables > 0);
if (a_ClassAPI.Inherits ~= nil) then
for idx, cls in ipairs(a_ClassAPI.Inherits) do
HasConstants = HasConstants or (#cls.Constants > 0);
HasFunctions = HasFunctions or (#cls.Functions > 0);
+ HasVariables = HasVariables or (#cls.Variables > 0);
end
end
@@ -702,6 +740,9 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
if (HasConstants) then
cf:write(" <li><a href=\"#constants\">Constants</a></li>\n");
end
+ if (HasVariables) then
+ cf:write(" <li><a href=\"#variables\">Member variables</a></li>\n");
+ end
if (HasFunctions) then
cf:write(" <li><a href=\"#functions\">Functions</a></li>\n");
end
@@ -746,6 +787,15 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
end;
end;
+ -- Write the member variables:
+ if (HasVariables) then
+ cf:write(" <a name=\"variables\"><hr /><h1>Member variables</h1></a>\n");
+ WriteVariables(a_ClassAPI.Variables, nil);
+ for i, cls in ipairs(InheritanceChain) do
+ WriteVariables(cls.Variables, cls.Name);
+ end;
+ end
+
-- Write the functions, including the inherited ones:
if (HasFunctions) then
cf:write(" <a name=\"functions\"><hr /><h1>Functions</h1></a>\n");