build: add support for documentation of __index

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-07-02 10:32:35 +02:00
parent 2c5333e9a3
commit 414e227a1a
1 changed files with 28 additions and 16 deletions

View File

@ -10,16 +10,19 @@ function string.replace_param(s)
end end
function string.comment_translate(s) function string.comment_translate(s)
local lua_comment = ""; local lua_comment = "";
nparam = 0; nparam = 0;
for line in s:gmatch("[^\r\n]+") do for line in s:gmatch("[^\r\n]+") do
line = line:gsub("/%*%*", "---") line = line:gsub("/%*%*", "---")
line = line:gsub("^.*%*", "--") line = line:gsub("^.*%*", "--")
line = line:gsub("\\lvalue", "") line = line:gsub("\\lvalue", "")
line = line:gsub("\\(lparam)", string.replace_param) line = line:gsub("\\(lparam)", string.replace_param)
line = line:gsub("\\lreturn", "@return") line = line:gsub("\\lreturn", "@return")
lua_comment = lua_comment .. line .. "\n" line = line:gsub("\\lfield", "@field")
end lua_comment = lua_comment .. line .. "\n"
end
-- remove last \n
lua_comment = lua_comment:sub(1, #lua_comment - 1)
return lua_comment return lua_comment
end end
@ -70,13 +73,22 @@ for i, line in ipairs(ilines) do
else else
local fctname, fctdef local fctname, fctdef
_, _, fctname, fctdef = line:find("\"(.+)\", (.+) },?") _, _, fctname, fctdef = line:find("\"(.+)\", (.+) },?")
if fctname and (not fctname:find("^__") or fctname:find("^__call")) then if fctname and (not fctname:find("^__")
or fctname:find("^__call")
or fctname:find("^__index")) then
if function_doc[fctdef] then if function_doc[fctdef] then
fctname = "." .. fctname if fctname:find("^__index") then
fctname = fctname:gsub("^.__call", "") print(function_doc[fctdef]:comment_translate())
print(function_doc[fctdef]:comment_translate()) print("-- @class table")
print("function " .. libname .. fctname .. "()") print("-- @name " .. libname)
print("end"); print(libname)
else
fctname = "." .. fctname
fctname = fctname:gsub("^.__call", "")
print(function_doc[fctdef]:comment_translate())
print("function " .. libname .. fctname .. "()")
print("end");
end
else else
print("This function is not yet documented.") print("This function is not yet documented.")
end end