summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-09-12 19:52:47 +0200
committermadmaxoft <github@xoft.cz>2013-09-12 19:52:47 +0200
commite9a809dfb9da77b032a98de6395e46a36fb7fa77 (patch)
tree795c3cae2d1abe5784ed5373d464372df779f1b7 /MCServer/Plugins
parentAPIDump: replacing wiki-style markup with APIDump-style markup (diff)
downloadcuberite-e9a809dfb9da77b032a98de6395e46a36fb7fa77.tar
cuberite-e9a809dfb9da77b032a98de6395e46a36fb7fa77.tar.gz
cuberite-e9a809dfb9da77b032a98de6395e46a36fb7fa77.tar.bz2
cuberite-e9a809dfb9da77b032a98de6395e46a36fb7fa77.tar.lz
cuberite-e9a809dfb9da77b032a98de6395e46a36fb7fa77.tar.xz
cuberite-e9a809dfb9da77b032a98de6395e46a36fb7fa77.tar.zst
cuberite-e9a809dfb9da77b032a98de6395e46a36fb7fa77.zip
Diffstat (limited to '')
-rw-r--r--MCServer/Plugins/APIDump/main.lua31
1 files changed, 21 insertions, 10 deletions
diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua
index 188c6452f..53052da62 100644
--- a/MCServer/Plugins/APIDump/main.lua
+++ b/MCServer/Plugins/APIDump/main.lua
@@ -345,6 +345,7 @@ end
-- Only Windows-style paths are supported for now, since this is a one-time action
function ConvertWikiToDesc()
local fout = io.open("APIDesc.wiki.lua", "w");
+ fout:write("g_APIDesc =\n{\n\tClasses =\n\t{\n");
for filename in io.popen([[dir wikipages\\api\\*.txt /b]]):lines() do
-- Read file
local fin = io.open("wikipages\\api\\" .. filename, "r");
@@ -356,10 +357,16 @@ function ConvertWikiToDesc()
local Desc = "";
local Constants = {};
local Functions = {};
+ local ConstructorNumber = 1;
for line in fin:lines() do
-- Replace wiki-style markup:
line = line:gsub("%[%[.-:.-:(.-)|(.-)%]%]", "{{%1|%2}}"); -- Replaces [[API:Plugin:Hook|LinkText]]
+ line = line:gsub("%[%[.-:.-:(.-)%]%]", "{{%1|%1}}"); -- Replaces [[API:Plugin:Hook]]
line = line:gsub("%[%[.-:(.-)|(.-)%]%]", "{{%1|%2}}"); -- Replaces [[API:Class|LinkText]]
+ line = line:gsub("%[%[.-:(.-)%]%]", "{{%1|%1}}"); -- Replaces [[API:Class]]
+ line = line:gsub("%[%[(.-)|(.-)%]%]", "{{%1|%2}}"); -- Replaces [[Class|LinkText]]
+ line = line:gsub("%[%[(.-)%]%]", "{{%1|%1}}"); -- Replaces [[Class]]
+
if (line:find("======") ~= nil) then
state = 1; -- The following is the class description
ClassName = line:gsub("======", "");
@@ -378,10 +385,10 @@ function ConvertWikiToDesc()
elseif (state == 1) then
-- Class description:
- Desc = Desc .. AddNextTime .. line .. "\n";
if (line == "") then
- AddNextTime = "</p>\n<p>"; -- Replace empty lines with paragraph delimiters; add only when there's a followup text on next line
+ AddNextTime = "</p>\n\t\t<p>"; -- Replace empty lines with paragraph delimiters; add only when there's a followup text on next line
else
+ Desc = Desc .. AddNextTime .. line .. "\n";
AddNextTime = "";
end
elseif (state == 2) then
@@ -406,7 +413,8 @@ function ConvertWikiToDesc()
notes = notes:sub(1, notes:len() - 2); -- Remove the trailing " |"
local name = (Split[2] or "");
if ((name == "( )") or (name == "()")) then
- name = "constructor"; -- Special name is used for the constructor in the wiki
+ name = "constructor" .. ConstructorNumber; -- Special name is used for the constructor in the wiki
+ ConstructorNumber = ConstructorNumber + 1;
end
table.insert(Functions, {Name = name, Params = Split[3], Return = Split[4], Notes = notes});
end
@@ -415,19 +423,22 @@ function ConvertWikiToDesc()
fin:close();
-- Write the info into the output file:
- fout:write(ClassName .. " =\n{\n\tDesc = [[" .. Desc .. "]]\n\tFunctions =\n\t{\n");
+ fout:write("\t\t" .. ClassName .. " =\n\t\t{\n\t\t\tDesc = [[" .. Desc .. "]],\n\t\t\tFunctions =\n\t\t\t{\n");
for i, func in ipairs(Functions) do
- fout:write("\t\t{ " .. func.Name .. " = { Params = \"" .. func.Params .. "\", Return =\"" ..
- func.Return .. "\", Desc = \"" .. func.Notes .. "\" },\n"
- );
+ fout:write(string.format("\t\t\t\t{ %s = { Params = %q, Return = %q, Notes = %q } },\n",
+ func.Name, func.Params, func.Return, func.Notes
+ ));
end
- fout:write("\t},\n\tConstants =\n\t{\n");
+ fout:write("\t\t\t},\n\t\t\tConstants =\n\t\t\t{\n");
for i, cons in ipairs(Constants) do
- fout:write("\t\t{ " .. cons.Name .. " = { Notes = \"" .. cons.Notes .. "\" },\n");
+ fout:write(string.format("\t\t\t\t{ %s = { Notes = %q } },\n",
+ cons.Name, cons.Notes
+ ));
end
- fout:write("\t},\n},\n\n\n");
+ fout:write("\t\t\t},\n\t\t},\n\n");
end -- if fin ~= nil
end -- for file
+ fout:write("\t}\n}\n\n\n\n\n\n");
fout:close();
end