Module:ScriptItem2: Difference between revisions

Jump to navigation Jump to search
no edit summary
(Created page with "local p = {} -- settings p.categoryItems = { -- Category Name = table. (Fully resolved item name(s), case-sensitive.) (Event names must start with a capital letter "O", to...")
 
No edit summary
Line 347: Line 347:


function p.syntax(frame)
function p.syntax(frame)
--[[
local args = p.getArgs(frame)
local args = p.getArgs(frame)
Line 361: Line 362:
return p.documentationMissing(frame, "Syntax")
return p.documentationMissing(frame, "Syntax")
]]
local returnType
local argsText = {}
do
local args = p.getArgs(frame)
local entries = p.getIndexedArgs(frame, 'return')
if #entries == 0 then
else
local tokens = p.split(entries[1], ' ')
returnType = tokens[1]
returnType = p.standardizeNullType(type)
end
end
do
local entries = p.getIndexedArgs(frame, 'arg')
local isEvent = args.type == 'event'
if isEvent and args.syntax and args.syntax:lower() == 'event event' then
elseif #entries == 0 then
elseif entries[1] == "void" then
table.insert(argsText, 'void')
else
for i,arg in ipairs(entries) do
local tokens = p.split(arg, ' ')
local isOptional = tokens[3] == 'optional'
local defaultValue = isOptional and "<span style='font-family: \"Source Code Pro\", monospace;'>"..tokens[4].."</span>" or "n/a"
if isOptional then
table.insert(argsText, '[ '..tokens[1]..' '..tokens[2]..' = '..defaultValue..' ]')
else
table.insert(argsText, tokens[1]..' '..tokens[2])
end
end
end
end
return returnType
..' '..p.getDisplayedName(frame)
..'('..(#argsText == 0 and 'void' or table.concat(argsText, ', ')..')')
end
end


6,834

edits

Navigation menu