diff options
-rw-r--r-- | MCServer/Plugins/APIDump/APIDesc.lua | 7 | ||||
-rw-r--r-- | MCServer/Plugins/APIDump/WebWorldThreads.html | 9 | ||||
-rw-r--r-- | MCServer/Plugins/APIDump/main.lua | 89 | ||||
-rw-r--r-- | source/Globals.h | 1 | ||||
-rw-r--r-- | source/WebAdmin.cpp | 45 |
5 files changed, 105 insertions, 46 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 6209bfa76..246103acc 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -3612,7 +3612,12 @@ end "WriteHtmlClass", "WriteHtmlHook", }, - + + IgnoreVariables = + { + "__.*__", -- tolua exports multiple inheritance this way + } , + ExtraPages = { -- No sorting is provided for these, they will be output in the same order as defined here diff --git a/MCServer/Plugins/APIDump/WebWorldThreads.html b/MCServer/Plugins/APIDump/WebWorldThreads.html index 7cc94e9fa..2f117ab7c 100644 --- a/MCServer/Plugins/APIDump/WebWorldThreads.html +++ b/MCServer/Plugins/APIDump/WebWorldThreads.html @@ -2,8 +2,10 @@ <html> <head> <title>MCServer - Webserver vs World threads</title> - <script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script> - <script src="http://google-code-prettify.googlecode.com/svn/trunk/src/lang-lua.js"></script> + <link rel="stylesheet" type="text/css" href="main.css" /> + <link rel="stylesheet" type="text/css" href="prettify.css" /> + <script src="prettify.js"></script> + <script src="lang-lua.js"></script> </head> <body> <h1>Webserver vs World threads</h1> @@ -60,5 +62,8 @@ end ) </pre> + <script> + prettyPrint(); + </script> </body> </html>
\ No newline at end of file diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 285b0c1c3..75fc15965 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -117,7 +117,7 @@ function CreateAPITables() }; --]] - local Globals = {Functions = {}, Constants = {}, Descendants = {}}; + local Globals = {Functions = {}, Constants = {}, Variables = {}, Descendants = {}}; local API = {}; local function Add(a_APIContainer, a_ObjName, a_ObjValue) @@ -132,10 +132,18 @@ function CreateAPITables() end local function ParseClass(a_ClassName, a_ClassObj) - local res = {Name = a_ClassName, Functions = {}, Constants = {}, Descendants = {}}; + local res = {Name = a_ClassName, Functions = {}, Constants = {}, Variables = {}, Descendants = {}}; + -- Add functions and constants: for i, v in pairs(a_ClassObj) do Add(res, i, v); end + + -- Member variables: + if ((a_ClassObj[".get"] ~= nil) and (type(a_ClassObj[".get"]) == "table")) then + for k, v in pairs(a_ClassObj[".get"]) do + table.insert(res.Variables, { Name = k }); + end + end return res; end @@ -353,6 +361,19 @@ function ReadDescriptions(a_API) return false; end + -- Returns true if the member variable (specified by its fully qualified name) is to be ignored + local function IsVariableIgnored(a_VarName) + if (g_APIDesc.IgnoreVariables == nil) then + return false; + end; + for i, name in ipairs(g_APIDesc.IgnoreVariables) do + if (a_VarName:match(name)) then + return true; + end + end + return false; + end + -- Remove ignored classes from a_API: local APICopy = {}; for i, cls in ipairs(a_API) do @@ -407,6 +428,7 @@ function ReadDescriptions(a_API) cls.UndocumentedFunctions = {}; -- This will contain names of all the functions that are not documented cls.UndocumentedConstants = {}; -- This will contain names of all the constants that are not documented + cls.UndocumentedVariables = {}; -- This will contain names of all the variables that are not documented local DoxyFunctions = {}; -- This will contain all the API functions together with their documentation @@ -460,20 +482,31 @@ function ReadDescriptions(a_API) end -- for j, cons end -- if (APIDesc.Constants ~= nil) - -- 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; + -- Assign member variables' descriptions: + if (APIDesc.Variables ~= nil) then + for j, var in ipairs(cls.Variables) do + local VarDesc = APIDesc.Variables[var.Name]; + if (VarDesc == nil) then + -- Not documented + if not(IsVariableIgnored(cls.Name .. "." .. var.Name)) then + table.insert(cls.UndocumentedVariables, var.Name); + end + else + -- Copy all documentation: + for k, v in pairs(VarDesc) do + var[k] = v + end + end + end -- for j, var + end -- if (APIDesc.Variables ~= nil) else -- if (APIDesc ~= nil) -- Class is not documented at all, add all its members to Undocumented lists: cls.UndocumentedFunctions = {}; cls.UndocumentedConstants = {}; - cls.Variables = {}; + cls.UndocumentedVariables = {}; + cls.Variables = cls.Variables or {}; for j, func in ipairs(cls.Functions) do local FnName = func.DocID or func.Name; if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then @@ -485,6 +518,11 @@ function ReadDescriptions(a_API) table.insert(cls.UndocumentedConstants, cons.Name); end end -- for j, cons - cls.Constants[] + for j, var in ipairs(cls.Variables) do + if not(IsConstantIgnored(cls.Name .. "." .. var.Name)) then + table.insert(cls.UndocumentedVariables, var.Name); + end + end -- for j, var - cls.Variables[] end -- else if (APIDesc ~= nil) -- Remove ignored functions: @@ -517,6 +555,15 @@ function ReadDescriptions(a_API) end ); + -- Remove ignored functions: + local NewVariables = {}; + for j, var in ipairs(cls.Variables) do + if (not(IsVariableIgnored(cls.Name .. "." .. var.Name))) then + table.insert(NewVariables, var); + end + end -- for j, var + cls.Variables = NewVariables; + -- Sort the member variables: table.sort(cls.Variables, function(v1, v2) @@ -754,7 +801,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) cf:write(" </ul>\n\n"); -- Write the class description: - cf:write(" <a name=\"desc\"><hr /><h1>Class " .. ClassName .. "</h1></a>\n"); + cf:write(" <a name=\"desc\"><hr /><h1>" .. ClassName .. " class</h1></a>\n"); if (a_ClassAPI.Desc ~= nil) then cf:write(" <p>"); cf:write(LinkifyString(a_ClassAPI.Desc, ClassName)); @@ -907,7 +954,8 @@ function ListUndocumentedObjects(API, UndocumentedHooks) for i, cls in ipairs(API) do local HasFunctions = ((cls.UndocumentedFunctions ~= nil) and (#cls.UndocumentedFunctions > 0)); local HasConstants = ((cls.UndocumentedConstants ~= nil) and (#cls.UndocumentedConstants > 0)); - if (HasFunctions or HasConstants) then + local HasVariables = ((cls.UndocumentedVariables ~= nil) and (#cls.UndocumentedVariables > 0)); + if (HasFunctions or HasConstants or HasVariables) then f:write("\t\t" .. cls.Name .. " =\n\t\t{\n"); if ((cls.Desc == nil) or (cls.Desc == "")) then f:write("\t\t\tDesc = \"\"\n"); @@ -919,7 +967,7 @@ function ListUndocumentedObjects(API, UndocumentedHooks) table.sort(cls.UndocumentedFunctions); for j, fn in ipairs(cls.UndocumentedFunctions) do f:write("\t\t\t\t" .. fn .. " = { Params = \"\", Return = \"\", Notes = \"\" },\n"); - end -- for j, fn - cls.Undocumented[] + end -- for j, fn - cls.UndocumentedFunctions[] f:write("\t\t\t},\n\n"); end @@ -928,11 +976,20 @@ function ListUndocumentedObjects(API, UndocumentedHooks) table.sort(cls.UndocumentedConstants); for j, cn in ipairs(cls.UndocumentedConstants) do f:write("\t\t\t\t" .. cn .. " = { Notes = \"\" },\n"); - end -- for j, fn - cls.Undocumented[] + end -- for j, fn - cls.UndocumentedConstants[] + f:write("\t\t\t},\n\n"); + end + + if (HasVariables) then + f:write("\t\t\tVariables =\n\t\t\t{\n"); + table.sort(cls.UndocumentedVariables); + for j, vn in ipairs(cls.UndocumentedVariables) do + f:write("\t\t\t\t" .. vn .. " = { Type = \"\", Notes = \"\" },\n"); + end -- for j, fn - cls.UndocumentedVariables[] f:write("\t\t\t},\n\n"); end - if (HasFunctions or HasConstants) then + if (HasFunctions or HasConstants or HasVariables) then f:write("\t\t},\n\n"); end end -- for i, cls - API[] @@ -961,7 +1018,9 @@ function ListUndocumentedObjects(API, UndocumentedHooks) f:write("\t\t\tReturns = [[\n\t\t\t\t\n\t\t\t]],\n"); f:write("\t\t}, -- " .. hook .. "\n"); end + f:write("\t},\n"); end + f:write("}\n\n\n\n"); f:close(); end end diff --git a/source/Globals.h b/source/Globals.h index 174273bbc..ef79e4cf1 100644 --- a/source/Globals.h +++ b/source/Globals.h @@ -161,7 +161,6 @@ typedef unsigned short UInt16; #include <memory> #include <set> #include <queue> -#include <sstream> diff --git a/source/WebAdmin.cpp b/source/WebAdmin.cpp index d0b9648d9..3f9bc6c98 100644 --- a/source/WebAdmin.cpp +++ b/source/WebAdmin.cpp @@ -397,47 +397,38 @@ AString cWebAdmin::GetBaseURL( const AString& a_URL ) -AString cWebAdmin::GetHTMLEscapedString( const AString& a_Input ) +AString cWebAdmin::GetHTMLEscapedString(const AString & a_Input) { - - // Define a string to write the output to. - AString dst = ""; + AString dst; dst.reserve(a_Input.length()); - // Loop over input and substitute HTML characters for their alternatives. - for (size_t i = 0; i < a_Input.length(); i++) { - switch ( a_Input[i] ) + // Loop over input and substitute HTML characters for their alternatives: + size_t len = a_Input.length(); + for (size_t i = 0; i < len; i++) + { + switch (a_Input[i]) { - case '&': - dst =+ "&"; - break; - case '\'': - dst =+ "'"; - break; - case '"': - dst =+ """; - break; - case '<': - dst =+ "<"; - break; - case '>': - dst =+ ">"; - break; + case '&': dst.append("&"); break; + case '\'': dst.append("'"); break; + case '"': dst.append("""); break; + case '<': dst.append("<"); break; + case '>': dst.append(">"); break; default: - dst =+ a_Input[i]; + { + dst.push_back(a_Input[i]); break; - } - } + } + } // switch (a_Input[i]) + } // for i - a_Input[] return dst; - } -AString cWebAdmin::GetBaseURL( const AStringVector& a_URLSplit ) +AString cWebAdmin::GetBaseURL(const AStringVector & a_URLSplit) { AString BaseURL = "./"; if (a_URLSplit.size() > 1) |