From 77af5c6fe72bee11e303924b2c3f30663e28085c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 20:49:30 +0200 Subject: APIDump: Do not list empty Constants or Functions sections. Also implemented writing inherited constants. --- MCServer/Plugins/APIDump/main.lua | 60 ++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 14 deletions(-) (limited to 'MCServer/Plugins/APIDump/main.lua') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 8d0f9f544..eadea622b 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -632,6 +632,24 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) cf:write(" \n\n"); end + local function WriteConstants(a_Constants, a_InheritedName) + if (#a_Constants == 0) then + return; + end + + if (a_InheritedName ~= nil) then + cf:write("

Constants inherited from " .. a_InheritedName .. "

\n"); + end + + cf:write(" \n \n \n \n \n \n"); + for i, cons in ipairs(a_Constants) do + cf:write(" \n \n"); + cf:write(" \n"); + cf:write(" \n \n"); + end + cf:write("
NameValueNotes
" .. cons.Name .. "" .. cons.Value .. "" .. LinkifyString(cons.Notes or "", a_InheritedName or a_ClassAPI.Name) .. "
\n\n"); + end + local function WriteDescendants(a_Descendants) if (#a_Descendants == 0) then return; @@ -676,12 +694,25 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) local HasInheritance = ((#a_ClassAPI.Descendants > 0) or (a_ClassAPI.Inherits ~= nil)); + local HasConstants = (#a_ClassAPI.Constants > 0); + local HasFunctions = (#a_ClassAPI.Functions > 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); + end + end + -- Write the table of contents: if (HasInheritance) then cf:write("
  • Inheritance
  • \n"); end - cf:write("
  • Constants
  • \n"); - cf:write("
  • Functions
  • \n"); + if (HasConstants) then + cf:write("
  • Constants
  • \n"); + end + if (HasFunctions) then + cf:write("
  • Functions
  • \n"); + end if (a_ClassAPI.AdditionalInfo ~= nil) then for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do cf:write("
  • " .. additional.Header .. "
  • \n"); @@ -715,20 +746,21 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end -- Write the constants: - cf:write("

    Constants

    \n"); - cf:write(" \n \n \n \n \n \n"); - for i, cons in ipairs(a_ClassAPI.Constants) do - cf:write(" \n \n"); - cf:write(" \n"); - cf:write(" \n \n"); - end - cf:write("
    NameValueNotes
    " .. cons.Name .. "" .. cons.Value .. "" .. LinkifyString(cons.Notes or "", ClassName) .. "
    \n\n"); + if (HasConstants) then + cf:write("

    Constants

    \n"); + WriteConstants(a_ClassAPI.Constants, nil); + for i, cls in ipairs(InheritanceChain) do + WriteConstants(cls.Constants, cls.Name); + end; + end; -- Write the functions, including the inherited ones: - cf:write("

    Functions

    \n"); - WriteFunctions(a_ClassAPI.Functions, nil); - for i, cls in ipairs(InheritanceChain) do - WriteFunctions(cls.Functions, cls.Name); + if (HasFunctions) then + cf:write("

    Functions

    \n"); + WriteFunctions(a_ClassAPI.Functions, nil); + for i, cls in ipairs(InheritanceChain) do + WriteFunctions(cls.Functions, cls.Name); + end end -- Write the additional infos: -- cgit v1.2.3