diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-10-15 22:14:47 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-10-15 22:14:47 +0200 |
commit | cb9ccb36acfb1d80684098759f8f39c7022891dd (patch) | |
tree | f65f9ca3c1c70f447c41d9b7190bb5dc8fbb5071 /MCServer/Plugins/APIDump/main.lua | |
parent | Merge submodule changes (diff) | |
parent | Added HOOK_PLAYER_RIGHT_CLICK (diff) | |
download | cuberite-cb9ccb36acfb1d80684098759f8f39c7022891dd.tar cuberite-cb9ccb36acfb1d80684098759f8f39c7022891dd.tar.gz cuberite-cb9ccb36acfb1d80684098759f8f39c7022891dd.tar.bz2 cuberite-cb9ccb36acfb1d80684098759f8f39c7022891dd.tar.lz cuberite-cb9ccb36acfb1d80684098759f8f39c7022891dd.tar.xz cuberite-cb9ccb36acfb1d80684098759f8f39c7022891dd.tar.zst cuberite-cb9ccb36acfb1d80684098759f8f39c7022891dd.zip |
Diffstat (limited to '')
-rw-r--r-- | MCServer/Plugins/APIDump/main.lua | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 3827668e3..163c505b2 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -180,7 +180,12 @@ function DumpAPIHtml() -- Extract hook constants: for name, obj in pairs(cPluginManager) do - if (type(obj) == "number") and (name:match("HOOK_.*")) then + if ( + (type(obj) == "number") and + name:match("HOOK_.*") and + (name ~= "HOOK_MAX") and + (name ~= "HOOK_NUM_HOOKS") + ) then table.insert(Hooks, { Name = name }); end end @@ -327,10 +332,18 @@ function DumpAPIHtml() f:write("\t\t" .. hook .. " =\n\t\t{\n"); f:write("\t\t\tCalledWhen = \"\",\n"); f:write("\t\t\tDefaultFnName = \"On\", -- also used as pagename\n"); - f:write("\t\t\tDesc = [[]],\n"); + f:write("\t\t\tDesc = [[\n\t\t\t\t\n\t\t\t]],\n"); f:write("\t\t\tParams =\n\t\t\t{\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); - f:write("\t\t\tReturns = [[]],\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t},\n"); + f:write("\t\t\tReturns = [[\n\t\t\t\t\n\t\t\t]],\n"); f:write("\t\t}, -- " .. hook .. "\n"); end end @@ -604,8 +617,39 @@ end -- Make a link out of anything with the special linkifying syntax {{link|title}} function LinkifyString(a_String) - local txt = a_String:gsub("{{([^|}]*)|([^}]*)}}", "<a href=\"%1.html\">%2</a>") -- {{link|title}} - txt = txt:gsub("{{([^|}]*)}}", "<a href=\"%1.html\">%1</a>") -- {{LinkAndTitle}} + local function CreateLink(Link, Title) + if (Link:sub(1, 7) == "http://") then + -- The link is a full absolute URL, do not modify, do not track: + return "<a href=\"" .. Link .. "\">" .. Title .. "</a>"; + end + local idxHash = Link:find("#"); + if (idxHash ~= nil) then + -- The link contains an anchor: + if (idxHash == 1) then + -- Anchor in the current page, no need to track: + return "<a href=\"" .. Link .. "\">" .. Title .. "</a>"; + end + -- Anchor in another page: + -- TODO: track this link + return "<a href=\"" .. Link:sub(1, idxHash - 1) .. ".html#" .. Link:sub(idxHash + 1) .. "\">" .. Title .. "</a>"; + end + -- Link without anchor: + -- TODO; track this link + return "<a href=\"" .. Link .. ".html\">" .. Title .. "</a>"; + end + + local txt = a_String:gsub("{{([^|}]*)|([^}]*)}}", CreateLink) -- {{link|title}} + + txt = txt:gsub("{{([^|}]*)}}", -- {{LinkAndTitle}} + function(LinkAndTitle) + local idxHash = LinkAndTitle:find("#"); + if (idxHash ~= nil) then + -- The LinkAndTitle contains a hash, remove the hashed part from the title: + return CreateLink(LinkAndTitle, LinkAndTitle:sub(1, idxHash - 1)); + end + return CreateLink(LinkAndTitle, LinkAndTitle); + end + ); return txt; end |