From f58d11fc1aa673bad1463718ff518ee518c78252 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 22 Jan 2014 10:18:58 +0100 Subject: InfoDump: Dump all referenced permissions. --- MCServer/Plugins/InfoDump.lua | 116 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 112 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins/InfoDump.lua') diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index df47d566b..c272f7818 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -17,22 +17,23 @@ if (_VERSION ~= "Lua 5.1") then return; end --- Try to load lfs, do not abort if not found +-- Try to load lfs, do not abort if not found ... local lfs, err = pcall( function() return require("lfs") end ); --- Rather, print a nice message with instructions: +-- ... rather, print a nice message with instructions: if not(lfs) then print([[ Cannot load LuaFileSystem Install it through luarocks by executing the following command: - sudo luarocks install luafilesystem + luarocks install luafilesystem (Windows) + sudo luarocks install luafilesystem (*nix) If you don't have luarocks installed, you need to install them using your OS's package manager, usually: - sudo apt-get install luarocks + sudo apt-get install luarocks (Ubuntu / Debian) On windows, a binary distribution can be downloaded from the LuaRocks homepage, http://luarocks.org/en/Download ]]); @@ -161,6 +162,21 @@ end +--- Returns a string specifying the command. +-- If a_Command is a simple string, returns a_Command colorized to blue +-- If a_Command is a table, expects members Name (full command name) and Params (command parameters), +-- colorizes command name blue and params green +local function GetCommandRefForum(a_Command) + if (type(a_Command) == "string") then + return "[color=blue]" .. a_Command .. "[/color]"; + end + return "[color=blue]" .. a_Command.Name .. "[/color] [color=green]" .. a_Command.Params .. "[/color]"; +end + + + + + --- Writes the specified command detailed help array to the output file, in the forum dump format local function WriteCommandParameterCombinationsForum(a_CmdString, a_ParameterCombinations, f) assert(type(a_CmdString) == "string"); @@ -270,6 +286,97 @@ end +--- Collects all permissions mentioned in the info, returns them as a sorted array +-- Each array item is {Name = "PermissionName", Info = { PermissionInfo }} +local function BuildPermissions(a_PluginInfo) + -- Collect all used permissions from Commands, reference the commands that use the permission: + local Permissions = a_PluginInfo.Permissions or {}; + local function CollectPermissions(a_CmdPrefix, a_Commands) + for cmd, info in pairs(a_Commands) do + CommandString = a_CmdPrefix .. cmd; + if ((info.Permission ~= nil) and (info.Permission ~= "")) then + -- Add the permission to the list of permissions: + local Permission = Permissions[info.Permission] or {}; + Permissions[info.Permission] = Permission; + -- Add the command to the list of commands using this permission: + Permission.CommandsAffected = Permission.CommandsAffected or {}; + table.insert(Permission.CommandsAffected, CommandString); + end + + -- Process the command param combinations for permissions: + local ParamCombinations = info.ParameterCombinations or {}; + for idx, comb in ipairs(ParamCombinations) do + if ((comb.Permission ~= nil) and (comb.Permission ~= "")) then + -- Add the permission to the list of permissions: + local Permission = Permissions[comb.Permission] or {}; + Permissions[info.Permission] = Permission; + -- Add the command to the list of commands using this permission: + Permission.CommandsAffected = Permission.CommandsAffected or {}; + table.insert(Permission.CommandsAffected, {Name = CommandString, Params = comb.Params}); + end + end + + -- Process subcommands: + if (info.Subcommands ~= nil) then + CollectPermissions(CommandString .. " ", info.Subcommands); + end + end + end + CollectPermissions("", a_PluginInfo.Commands); + + -- Copy the list of permissions to an array: + local PermArray = {}; + for name, perm in pairs(Permissions) do + table.insert(PermArray, {Name = name, Info = perm}); + end + + -- Sort the permissions array: + table.sort(PermArray, + function(p1, p2) + return (p1.Name < p2.Name); + end + ); + return PermArray; +end + + + + + +local function DumpPermissionsForum(a_PluginInfo, f) + -- Get the processed sorted array of permissions: + local Permissions = BuildPermissions(a_PluginInfo); + if ((Permissions == nil) or (#Permissions <= 0)) then + return; + end + + -- Dump the permissions: + f:write("\n[size=X-Large]Permissions[/size]\n[list]\n"); + for idx, perm in ipairs(Permissions) do + f:write(" - [color=red]", perm.Name, "[/color] - "); + f:write(perm.Info.Description or ""); + local CommandsAffected = perm.Info.CommandsAffected or {}; + if (#CommandsAffected > 0) then + f:write("\n[list] Commands affected:\n- "); + local Affects = {}; + for idx2, cmd in ipairs(CommandsAffected) do + table.insert(Affects, GetCommandRefForum(cmd)); + end + f:write(table.concat(Affects, "\n - ")); + f:write("\n[/list]"); + end + if (perm.Info.RecommendedGroups ~= nil) then + f:write("\n[list] Recommended groups: ", perm.Info.RecommendedGroups, "[/list]"); + end + f:write("\n"); + end + f:write("[/list]"); +end + + + + + local function DumpPluginInfoForum(a_PluginFolder, a_PluginInfo) -- Open the output file: local f, msg = io.open(a_PluginInfo.Name .. "_forum.txt", "w"); @@ -282,6 +389,7 @@ local function DumpPluginInfoForum(a_PluginFolder, a_PluginInfo) f:write(ForumizeString(a_PluginInfo.Description), "\n"); DumpAdditionalInfoForum(a_PluginInfo, f); DumpCommandsForum(a_PluginInfo, f); + DumpPermissionsForum(a_PluginInfo, f); f:close(); end -- cgit v1.2.3 From a6661e899a486badd8215bbc2fb04adc5542795c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 22 Jan 2014 12:41:19 +0100 Subject: InfoDump: Can dump a single plugin without LFS. --- MCServer/Plugins/InfoDump.lua | 112 ++++++++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 47 deletions(-) (limited to 'MCServer/Plugins/InfoDump.lua') diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index c272f7818..6b1da7a77 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -2,10 +2,17 @@ -- InfoDump.lua --- Goes through all subfolders, loads Info.lua and dumps its g_PluginInfo into various text formats --- This is used for generating plugin documentation for the forum and for GitHub's INFO.md files +--[[ +Loads plugins' Info.lua and dumps its g_PluginInfo into various text formats +This is used for generating plugin documentation for the forum and for GitHub's INFO.md files --- This script requires LuaRocks with LFS installed, instructions are printed when this is not present. +This script can be used in two ways: +Executing "lua InfoDump.lua" will go through all subfolders and dump each Info.lua file it can find + Note that this mode of operation requires LuaRocks with LFS installed; instructions are printed + when the prerequisites are not met. +Executing "lua InfoDump.lua PluginName" will load the Info.lua file from PluginName's folder and dump +only that one plugin's documentation. This mode of operation doesn't require LuaRocks +--]] @@ -17,34 +24,6 @@ if (_VERSION ~= "Lua 5.1") then return; end --- Try to load lfs, do not abort if not found ... -local lfs, err = pcall( - function() - return require("lfs") - end -); - --- ... rather, print a nice message with instructions: -if not(lfs) then - print([[ -Cannot load LuaFileSystem -Install it through luarocks by executing the following command: - luarocks install luafilesystem (Windows) - sudo luarocks install luafilesystem (*nix) - -If you don't have luarocks installed, you need to install them using your OS's package manager, usually: - sudo apt-get install luarocks (Ubuntu / Debian) -On windows, a binary distribution can be downloaded from the LuaRocks homepage, http://luarocks.org/en/Download -]]); - - print("Original error text: ", err); - return; -end - --- We now know that LFS is present, get it normally: -lfs = require("lfs"); - - @@ -409,12 +388,6 @@ end --- Tries to load the g_PluginInfo from the plugin's Info.lua file -- Returns the g_PluginInfo table on success, or nil and error message on failure local function LoadPluginInfo(a_FolderName) - -- Check if the Info file is present at all: - local Attribs = lfs.attributes(a_FolderName .. "/Info.lua"); - if ((Attribs == nil) or (Attribs.mode ~= "file")) then - return nil; - end - -- Load and compile the Info file: local cfg, err = loadfile(a_FolderName .. "/Info.lua"); if (cfg == nil) then @@ -440,7 +413,7 @@ local function ProcessPluginFolder(a_FolderName) local PluginInfo, Msg = LoadPluginInfo(a_FolderName); if (PluginInfo == nil) then if (Msg ~= nil) then - print("\tCannot load Info.lua: " .. Msg); + print("\t" .. Msg); end return; end @@ -451,19 +424,64 @@ end -print("Processing plugin subfolders:"); -for fnam in lfs.dir(".") do - if ((fnam ~= ".") and (fnam ~= "..")) then - local Attributes = lfs.attributes(fnam); - if (Attributes ~= nil) then - if (Attributes.mode == "directory") then - print(fnam); - ProcessPluginFolder(fnam); - end +--- Tries to load LFS through LuaRocks, returns the LFS instance, or nil on error +local function LoadLFS() + -- Try to load lfs, do not abort if not found ... + local lfs, err = pcall( + function() + return require("lfs") end + ); + + -- ... rather, print a nice message with instructions: + if not(lfs) then + print([[ + Cannot load LuaFileSystem + Install it through luarocks by executing the following command: + luarocks install luafilesystem (Windows) + sudo luarocks install luafilesystem (*nix) + + If you don't have luarocks installed, you need to install them using your OS's package manager, usually: + sudo apt-get install luarocks (Ubuntu / Debian) + On windows, a binary distribution can be downloaded from the LuaRocks homepage, http://luarocks.org/en/Download + ]]); + + print("Original error text: ", err); + return nil; end + + -- We now know that LFS is present, get it normally: + return require("lfs"); end + +local Arg1 = ...; +if ((Arg1 ~= nil) and (Arg1 ~= "")) then + -- Called with a plugin folder name, export only that one + ProcessPluginFolder(Arg1) +else + -- Called without any arguments, process all subfolders: + local lfs = LoadLFS(); + if (lfs == nil) then + -- LFS not loaded, error has already been printed, just bail out + return; + end + print("Processing plugin subfolders:"); + for fnam in lfs.dir(".") do + if ((fnam ~= ".") and (fnam ~= "..")) then + local Attributes = lfs.attributes(fnam); + if (Attributes ~= nil) then + if (Attributes.mode == "directory") then + print(fnam); + ProcessPluginFolder(fnam); + end + end + end + end +end +print("Done."); + + -- cgit v1.2.3 From 1bd939c4d4f27b5a04c65446d8119c132a2b64ab Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 4 Feb 2014 00:16:13 +0100 Subject: InfoDump: Fixed export for undeclared command param combinations. --- MCServer/Plugins/InfoDump.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins/InfoDump.lua') diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index 6b1da7a77..28a17c214 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -149,7 +149,7 @@ local function GetCommandRefForum(a_Command) if (type(a_Command) == "string") then return "[color=blue]" .. a_Command .. "[/color]"; end - return "[color=blue]" .. a_Command.Name .. "[/color] [color=green]" .. a_Command.Params .. "[/color]"; + return "[color=blue]" .. a_Command.Name .. "[/color] [color=green]" .. (a_Command.Params or "") .. "[/color]"; end @@ -169,7 +169,7 @@ local function WriteCommandParameterCombinationsForum(a_CmdString, a_ParameterCo f:write("The following parameter combinations are recognized:\n"); for idx, combination in ipairs(a_ParameterCombinations) do - f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params, "[/color]"); + f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params or "", "[/color]"); if (combination.Help ~= nil) then f:write(" - ", ForumizeString(combination.Help)); end -- cgit v1.2.3 From aec7ffd3f69a07a8d207d2b00f54433affff8139 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 5 Feb 2014 21:50:35 +0100 Subject: InfoDump: Added github output. --- MCServer/Plugins/InfoDump.lua | 233 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 228 insertions(+), 5 deletions(-) (limited to 'MCServer/Plugins/InfoDump.lua') diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index 28a17c214..8fac09d60 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -69,6 +69,47 @@ end +--- Replaces generic formatting with forum-specific formatting +-- Also removes the single line-ends +local function GithubizeString(a_Str) + assert(type(a_Str) == "string"); + + -- Remove the indentation, unless in the code tag: + -- Only one code or /code tag per line is supported! + local IsInCode = false; + local function RemoveIndentIfNotInCode(s) + if (IsInCode) then + -- we're in code section, check if this line terminates it + IsInCode = (s:find("{%%/code}") ~= nil); + return s .. "\n"; + else + -- we're not in code section, check if this line starts it + IsInCode = (s:find("{%%code}") ~= nil); + return s:gsub("^%s*", "") .. "\n"; + end + end + a_Str = a_Str:gsub("(.-)\n", RemoveIndentIfNotInCode); + + -- Replace multiple line ends with {%p} and single line ends with a space, + -- so that manual word-wrap in the Info.lua file doesn't wrap in the forum. + a_Str = a_Str:gsub("\n\n", "{%%p}"); + a_Str = a_Str:gsub("\n", " "); + + -- Replace the generic formatting: + a_Str = a_Str:gsub("{%%p}", "\n\n"); + a_Str = a_Str:gsub("{%%b}", "**"):gsub("{%%/b}", "**"); + a_Str = a_Str:gsub("{%%i}", "*"):gsub("{%%/i}", "*"); + a_Str = a_Str:gsub("{%%list}", ""):gsub("{%%/list}", ""); + a_Str = a_Str:gsub("{%%li}", " - "):gsub("{%%/li}", ""); + -- TODO: Other formatting + + return a_Str; +end + + + + + --- Builds an array of categories, each containing all the commands belonging to the category, -- and the category description, if available. -- Returns the array table, each item has the following format: @@ -156,6 +197,28 @@ end +--- Returns a string specifying the command. +-- If a_CommandParams is nil, returns a_CommandName apostrophed +-- If a_CommandParams is a string, apostrophes a_CommandName with a_CommandParams +local function GetCommandRefGithub(a_CommandName, a_CommandParams) + assert(type(a_CommandName) == "string"); + if (a_CommandParams == nil) then + return "`" .. a_CommandName .. "`"; + end + + assert(type(a_CommandParams) == "table"); + if ((a_CommandParams.Params == nil) or (a_CommandParams.Params == "")) then + return "`" .. a_CommandName .. "`"; + end + + assert(type(a_CommandParams.Params) == "string"); + return "`" .. a_CommandName .. " " .. a_CommandParams.Params .. "`"; +end + + + + + --- Writes the specified command detailed help array to the output file, in the forum dump format local function WriteCommandParameterCombinationsForum(a_CmdString, a_ParameterCombinations, f) assert(type(a_CmdString) == "string"); @@ -184,6 +247,34 @@ end +--- Writes the specified command detailed help array to the output file, in the forum dump format +local function WriteCommandParameterCombinationsGithub(a_CmdString, a_ParameterCombinations, f) + assert(type(a_CmdString) == "string"); + assert(type(a_ParameterCombinations) == "table"); + assert(f ~= nil); + + if (#a_ParameterCombinations == 0) then + -- No explicit parameter combinations to write + return; + end + + f:write("The following parameter combinations are recognized:\n\n"); + for idx, combination in ipairs(a_ParameterCombinations) do + f:write(GetCommandRefGithub(a_CmdString, combination)); + if (combination.Help ~= nil) then + f:write(" - ", GithubizeString(combination.Help)); + end + if (combination.Permission ~= nil) then + f:write(" (Requires permission '**", combination.Permission, "**')"); + end + f:write("\n"); + end +end + + + + + --- Writes all commands in the specified category to the output file, in the forum dump format local function WriteCommandsCategoryForum(a_Category, f) -- Write category name: @@ -206,7 +297,7 @@ local function WriteCommandsCategoryForum(a_Category, f) f:write("Permission required: [color=red]", cmd.Info.Permission, "[/color]\n"); end if (cmd.Info.DetailedDescription ~= nil) then - f:write(cmd.Info.DetailedDescription); + f:write(ForumizeString(cmd.Info.DetailedDescription)); end if (cmd.Info.ParameterCombinations ~= nil) then WriteCommandParameterCombinationsForum(cmd.CommandString, cmd.Info.ParameterCombinations, f); @@ -219,6 +310,41 @@ end +--- Writes all commands in the specified category to the output file, in the Github dump format +local function WriteCommandsCategoryGithub(a_Category, f) + -- Write category name: + local CategoryName = a_Category.Name; + if (CategoryName == "") then + CategoryName = "General"; + end + f:write("\n## ", GithubizeString(a_Category.DisplayName or CategoryName), "\n"); + + -- Write description: + if (a_Category.Description ~= "") then + f:write(GithubizeString(a_Category.Description), "\n"); + end + + -- Write commands: + f:write("\n"); + for idx2, cmd in ipairs(a_Category.Commands) do + f:write("\n### ", cmd.CommandString, "\n", GithubizeString(cmd.Info.HelpString or "UNDOCUMENTED"), "\n\n"); + if (cmd.Info.Permission ~= nil) then + f:write("Permission required: **", cmd.Info.Permission, "**\n\n"); + end + if (cmd.Info.DetailedDescription ~= nil) then + f:write(GithubizeString(cmd.Info.DetailedDescription)); + end + if (cmd.Info.ParameterCombinations ~= nil) then + WriteCommandParameterCombinationsGithub(cmd.CommandString, cmd.Info.ParameterCombinations, f); + end + end + f:write("\n\n") +end + + + + + local function DumpCommandsForum(a_PluginInfo, f) -- Copy all Categories from a dictionary into an array: local Categories = BuildCategories(a_PluginInfo); @@ -246,9 +372,36 @@ end +local function DumpCommandsGithub(a_PluginInfo, f) + -- Copy all Categories from a dictionary into an array: + local Categories = BuildCategories(a_PluginInfo); + + -- Sort the categories by name: + table.sort(Categories, + function(cat1, cat2) + return (string.lower(cat1.Name) < string.lower(cat2.Name)); + end + ); + + if (#Categories == 0) then + return; + end + + f:write("\n# Commands\n"); + + -- Dump per-category commands: + for idx, cat in ipairs(Categories) do + WriteCommandsCategoryGithub(cat, f); + end +end + + + + + local function DumpAdditionalInfoForum(a_PluginInfo, f) local AInfo = a_PluginInfo.AdditionalInfo; - if ((AInfo == nil) or (type(AInfo) ~= "table")) then + if (type(AInfo) ~= "table") then -- There is no AdditionalInfo in a_PluginInfo return; end @@ -265,6 +418,25 @@ end +local function DumpAdditionalInfoGithub(a_PluginInfo, f) + local AInfo = a_PluginInfo.AdditionalInfo; + if (type(AInfo) ~= "table") then + -- There is no AdditionalInfo in a_PluginInfo + return; + end + + for idx, info in ipairs(a_PluginInfo.AdditionalInfo) do + if ((info.Title ~= nil) and (info.Contents ~= nil)) then + f:write("\n# ", GithubizeString(info.Title), "\n"); + f:write(GithubizeString(info.Contents), "\n"); + end + end +end + + + + + --- Collects all permissions mentioned in the info, returns them as a sorted array -- Each array item is {Name = "PermissionName", Info = { PermissionInfo }} local function BuildPermissions(a_PluginInfo) @@ -333,7 +505,7 @@ local function DumpPermissionsForum(a_PluginInfo, f) f:write("\n[size=X-Large]Permissions[/size]\n[list]\n"); for idx, perm in ipairs(Permissions) do f:write(" - [color=red]", perm.Name, "[/color] - "); - f:write(perm.Info.Description or ""); + f:write(ForumizeString(perm.Info.Description or "")); local CommandsAffected = perm.Info.CommandsAffected or {}; if (#CommandsAffected > 0) then f:write("\n[list] Commands affected:\n- "); @@ -356,6 +528,43 @@ end +local function DumpPermissionsGithub(a_PluginInfo, f) + -- Get the processed sorted array of permissions: + local Permissions = BuildPermissions(a_PluginInfo); + if ((Permissions == nil) or (#Permissions <= 0)) then + return; + end + + -- Dump the permissions: + f:write("\n# Permissions\n"); + for idx, perm in ipairs(Permissions) do + f:write("### ", perm.Name, "\n"); + f:write(GithubizeString(perm.Info.Description or "")); + local CommandsAffected = perm.Info.CommandsAffected or {}; + if (#CommandsAffected > 0) then + f:write("\n\nCommands affected:\n - "); + local Affects = {}; + for idx2, cmd in ipairs(CommandsAffected) do + if (type(cmd) == "string") then + table.insert(Affects, GetCommandRefGithub(cmd)); + else + table.insert(Affects, GetCommandRefGithub(cmd.Name, cmd)); + end + end + f:write(table.concat(Affects, "\n - ")); + f:write("\n"); + end + if (perm.Info.RecommendedGroups ~= nil) then + f:write("\n\nRecommended groups: ", perm.Info.RecommendedGroups, "\n"); + end + f:write("\n"); + end +end + + + + + local function DumpPluginInfoForum(a_PluginFolder, a_PluginInfo) -- Open the output file: local f, msg = io.open(a_PluginInfo.Name .. "_forum.txt", "w"); @@ -377,8 +586,21 @@ end -local function DumpPluginInfoGitHub() - -- TODO +local function DumpPluginInfoGithub(a_PluginFolder, a_PluginInfo) + -- Open the output file: + local f, msg = io.open(a_PluginInfo.Name .. ".md", "w"); -- TODO: Save to a_PluginFolder .. "/Readme.md" instead + if (f == nil) then + print("\tCannot dump github info for plugin " .. a_PluginFolder .. ": " .. msg); + return; + end + + -- Write the description: + f:write(GithubizeString(a_PluginInfo.Description), "\n"); + DumpAdditionalInfoGithub(a_PluginInfo, f); + DumpCommandsGithub(a_PluginInfo, f); + DumpPermissionsGithub(a_PluginInfo, f); + + f:close(); end @@ -418,6 +640,7 @@ local function ProcessPluginFolder(a_FolderName) return; end DumpPluginInfoForum(a_FolderName, PluginInfo); + DumpPluginInfoGithub(a_FolderName, PluginInfo); end -- cgit v1.2.3 From 6129b6edf161c61db91d91145e9b1f23db688529 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 1 Mar 2014 14:29:40 +0100 Subject: If there is a SourceLocation available the InfoDump will note it in the forum version. --- MCServer/Plugins/InfoDump.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins/InfoDump.lua') diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index 8fac09d60..03ce46d99 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -578,7 +578,10 @@ local function DumpPluginInfoForum(a_PluginFolder, a_PluginInfo) DumpAdditionalInfoForum(a_PluginInfo, f); DumpCommandsForum(a_PluginInfo, f); DumpPermissionsForum(a_PluginInfo, f); - + if (a_PluginInfo.SourceLocation ~= nil) then + f:write("[b][color=blue]Source:[/color] [url=" .. a_PluginInfo.SourceLocation .. "]Link[/url][/b]"); + end + f:close(); end -- cgit v1.2.3 From 854cf9df999691463aa382bc760d3a4322d015a5 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 1 Mar 2014 14:45:38 +0100 Subject: Using comma instead of string concatenation. --- MCServer/Plugins/InfoDump.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins/InfoDump.lua') diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index 03ce46d99..e7ed157e3 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -579,7 +579,7 @@ local function DumpPluginInfoForum(a_PluginFolder, a_PluginInfo) DumpCommandsForum(a_PluginInfo, f); DumpPermissionsForum(a_PluginInfo, f); if (a_PluginInfo.SourceLocation ~= nil) then - f:write("[b][color=blue]Source:[/color] [url=" .. a_PluginInfo.SourceLocation .. "]Link[/url][/b]"); + f:write("[b][color=blue]Source:[/color] [url=", a_PluginInfo.SourceLocation, "]Link[/url][/b]"); end f:close(); -- cgit v1.2.3 From 0c8d08cb0962640bb3688f80ff782245daa2747c Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 2 Mar 2014 16:48:55 +0100 Subject: Simplified and more clearer infodump for Github. --- MCServer/Plugins/InfoDump.lua | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'MCServer/Plugins/InfoDump.lua') diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index e7ed157e3..ede4c0e8b 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -317,26 +317,19 @@ local function WriteCommandsCategoryGithub(a_Category, f) if (CategoryName == "") then CategoryName = "General"; end - f:write("\n## ", GithubizeString(a_Category.DisplayName or CategoryName), "\n"); + f:write("\n### ", GithubizeString(a_Category.DisplayName or CategoryName), "\n"); -- Write description: if (a_Category.Description ~= "") then - f:write(GithubizeString(a_Category.Description), "\n"); + f:write(GithubizeString(a_Category.Description), "\n\n"); end + f:write("| Command | Permission | Discription | \n") + f:write("| ------- | ---------- | ----------- | \n") + -- Write commands: - f:write("\n"); for idx2, cmd in ipairs(a_Category.Commands) do - f:write("\n### ", cmd.CommandString, "\n", GithubizeString(cmd.Info.HelpString or "UNDOCUMENTED"), "\n\n"); - if (cmd.Info.Permission ~= nil) then - f:write("Permission required: **", cmd.Info.Permission, "**\n\n"); - end - if (cmd.Info.DetailedDescription ~= nil) then - f:write(GithubizeString(cmd.Info.DetailedDescription)); - end - if (cmd.Info.ParameterCombinations ~= nil) then - WriteCommandParameterCombinationsGithub(cmd.CommandString, cmd.Info.ParameterCombinations, f); - end + f:write("|", cmd.CommandString, " | ", cmd.Info.Permission or "", " | ", GithubizeString(cmd.Info.HelpString or "UNDOCUMENTED"), "| \n") end f:write("\n\n") end @@ -601,7 +594,7 @@ local function DumpPluginInfoGithub(a_PluginFolder, a_PluginInfo) f:write(GithubizeString(a_PluginInfo.Description), "\n"); DumpAdditionalInfoGithub(a_PluginInfo, f); DumpCommandsGithub(a_PluginInfo, f); - DumpPermissionsGithub(a_PluginInfo, f); + --DumpPermissionsGithub(a_PluginInfo, f); -- Seems a little overkill since they are already mentioned in the commands. f:close(); end -- cgit v1.2.3 From 20e377ea7b64f60bd5565b8c97ce26750e0eeb5e Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 2 Mar 2014 16:55:04 +0100 Subject: Fixed typo Discription => Description --- MCServer/Plugins/InfoDump.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins/InfoDump.lua') diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index ede4c0e8b..59263d056 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -324,7 +324,7 @@ local function WriteCommandsCategoryGithub(a_Category, f) f:write(GithubizeString(a_Category.Description), "\n\n"); end - f:write("| Command | Permission | Discription | \n") + f:write("| Command | Permission | Description | \n") f:write("| ------- | ---------- | ----------- | \n") -- Write commands: -- cgit v1.2.3 From dc0cbd594c05395b5d71af8a8a1f24b10c2d0d50 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 5 Mar 2014 19:17:59 +0100 Subject: The APIDump generates a list of all the permissions again. --- MCServer/Plugins/InfoDump.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'MCServer/Plugins/InfoDump.lua') diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index 59263d056..c61f9c9e6 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -530,12 +530,13 @@ local function DumpPermissionsGithub(a_PluginInfo, f) -- Dump the permissions: f:write("\n# Permissions\n"); + f:write("| Permissions | Description | Commands | Recommended groups |\n") + f:write("| ----------- | ----------- | -------- | ------------------ |\n") for idx, perm in ipairs(Permissions) do - f:write("### ", perm.Name, "\n"); - f:write(GithubizeString(perm.Info.Description or "")); + f:write(perm.Name, " | "); + f:write(GithubizeString(perm.Info.Description or ""), " | "); local CommandsAffected = perm.Info.CommandsAffected or {}; if (#CommandsAffected > 0) then - f:write("\n\nCommands affected:\n - "); local Affects = {}; for idx2, cmd in ipairs(CommandsAffected) do if (type(cmd) == "string") then @@ -544,11 +545,10 @@ local function DumpPermissionsGithub(a_PluginInfo, f) table.insert(Affects, GetCommandRefGithub(cmd.Name, cmd)); end end - f:write(table.concat(Affects, "\n - ")); - f:write("\n"); + f:write(table.concat(Affects, ", "), " | "); end if (perm.Info.RecommendedGroups ~= nil) then - f:write("\n\nRecommended groups: ", perm.Info.RecommendedGroups, "\n"); + f:write(perm.Info.RecommendedGroups, " |"); end f:write("\n"); end @@ -594,7 +594,7 @@ local function DumpPluginInfoGithub(a_PluginFolder, a_PluginInfo) f:write(GithubizeString(a_PluginInfo.Description), "\n"); DumpAdditionalInfoGithub(a_PluginInfo, f); DumpCommandsGithub(a_PluginInfo, f); - --DumpPermissionsGithub(a_PluginInfo, f); -- Seems a little overkill since they are already mentioned in the commands. + DumpPermissionsGithub(a_PluginInfo, f); f:close(); end -- cgit v1.2.3