diff options
author | madmaxoft <github@xoft.cz> | 2013-12-27 15:36:28 +0100 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-12-27 15:36:28 +0100 |
commit | 9a9888a8cc0be28af5217de38f1154db97fa649a (patch) | |
tree | b2daf1d83acf97f2bf8a51df294f6d37970b81f9 /MCServer/Plugins/APIDump | |
parent | APIDump: Added a quick-nav menu to class descriptions. (diff) | |
download | cuberite-9a9888a8cc0be28af5217de38f1154db97fa649a.tar cuberite-9a9888a8cc0be28af5217de38f1154db97fa649a.tar.gz cuberite-9a9888a8cc0be28af5217de38f1154db97fa649a.tar.bz2 cuberite-9a9888a8cc0be28af5217de38f1154db97fa649a.tar.lz cuberite-9a9888a8cc0be28af5217de38f1154db97fa649a.tar.xz cuberite-9a9888a8cc0be28af5217de38f1154db97fa649a.tar.zst cuberite-9a9888a8cc0be28af5217de38f1154db97fa649a.zip |
Diffstat (limited to '')
-rw-r--r-- | MCServer/Plugins/APIDump/main_APIDump.lua | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua index 42cd5bad4..fef827f3e 100644 --- a/MCServer/Plugins/APIDump/main_APIDump.lua +++ b/MCServer/Plugins/APIDump/main_APIDump.lua @@ -275,7 +275,7 @@ end -local function WriteHooks(f, a_Hooks, a_UndocumentedHooks) +local function WriteHooks(f, a_Hooks, a_UndocumentedHooks, a_HookNav) f:write([[ <a name="hooks"><h2>Hooks</h2></a> <p> @@ -301,7 +301,7 @@ local function WriteHooks(f, a_Hooks, a_UndocumentedHooks) table.insert(a_UndocumentedHooks, hook.Name); else f:write(" <tr>\n <td><a href=\"" .. hook.DefaultFnName .. ".html\">" .. hook.Name .. "</a></td>\n <td>" .. LinkifyString(hook.CalledWhen, hook.Name) .. "</td>\n </tr>\n"); - WriteHtmlHook(hook); + WriteHtmlHook(hook, a_HookNav); end end f:write([[ @@ -379,7 +379,7 @@ function DumpAPIHtml() return; end - -- Create a class menu that will be inserted into each class file for faster navigation (#403) + -- Create a class navigation menu that will be inserted into each class file for faster navigation (#403) local ClassMenuTab = {}; for idx, cls in ipairs(API) do table.insert(ClassMenuTab, "<a href='"); @@ -390,6 +390,17 @@ function DumpAPIHtml() end local ClassMenu = table.concat(ClassMenuTab, ""); + -- Create a hook navigation menu that will be inserted into each hook file for faster navigation(#403) + local HookNavTab = {}; + for idx, hook in ipairs(Hooks) do + table.insert(HookNavTab, "<a href='"); + table.insert(HookNavTab, hook.DefaultFnName); + table.insert(HookNavTab, ".html'>"); + table.insert(HookNavTab, (hook.Name:gsub("^HOOK_", ""))); -- remove the "HOOK_" part of the name + table.insert(HookNavTab, "</a><br />"); + end + local HookNav = table.concat(HookNavTab, ""); + -- Write the HTML file: f:write([[<!DOCTYPE html> <html> @@ -415,7 +426,7 @@ function DumpAPIHtml() WriteArticles(f); WriteClasses(f, API, ClassMenu); - WriteHooks(f, Hooks, UndocumentedHooks); + WriteHooks(f, Hooks, UndocumentedHooks, HookNav); -- Copy the static files to the output folder (overwrite any existing): cFile:Copy(g_Plugin:GetLocalFolder() .. "/main.css", "API/main.css"); @@ -1097,7 +1108,7 @@ end -function WriteHtmlHook(a_Hook) +function WriteHtmlHook(a_Hook, a_HookNav) local fnam = "API/" .. a_Hook.DefaultFnName .. ".html"; local f, error = io.open(fnam, "w"); if (f == nil) then @@ -1120,7 +1131,11 @@ function WriteHtmlHook(a_Hook) <h1>]], a_Hook.Name, [[</h1> <hr /> </header> - <p> + <table><tr><td style="vertical-align: top;">Quick navigation: + ]]); + f:write(a_HookNav); + f:write([[ + </td><td style="vertical-align: top;"><p> ]]); f:write(LinkifyString(a_Hook.Desc, HookName)); f:write("</p>\n<hr /><h1>Callback function</h1>\n<p>The default name for the callback function is "); @@ -1150,7 +1165,7 @@ function WriteHtmlHook(a_Hook) f:write("<p>", (example.Desc or "<i>missing Desc</i>"), "</p>\n"); f:write("<pre class=\"prettyprint lang-lua\">", (example.Code or "<i>missing Code</i>"), "\n</pre>\n\n"); end - f:write([[</div><script>prettyPrint();</script></body></html>]]); + f:write([[</td></tr></table></div><script>prettyPrint();</script></body></html>]]); f:close(); end |