Module:ScriptItem2: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 591: Line 591:
local parameterTokens = p.split(parameters[i], ' ')
local parameterTokens = p.split(parameters[i], ' ')
local rows = {}
local rows = {}
for i2,callbackNParameter in ipairs(callbackNParameters) do
local callbackTokens = p.split(callbackNParameter, ' ')
local parameterType = callbackTokens[1]
local parameterName = callbackTokens[2]
local description = p.formatDescription(table.concat(callbackTokens, ' ', 3))
local argsText = {}
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[1]:sub(1, 1) == '['
if isOptional then
tokens[1] = tokens[1]:sub(2, tokens[1]:len())
tokens[4] = tokens[4]:sub(1, tokens[4]:len() - 1)
end
local defaultValue = isOptional and tokens[4] 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
argsText = p.loadTemplate(frame, 'CodeSyntax', {
'function('..(#argsText == 0 and 'void' or table.concat(argsText, ', ')..')')
})
rows[i2] = { i2..') ', p.formatType(parameterType, frame), p.formatName(parameterName, frame), description }
end
if #parameterTokens > 0 then
if #parameterTokens > 0 then
Line 600: Line 643:
if callbackText and #callbackText > 0 then
if callbackText and #callbackText > 0 then
table.insert(html, callbackText)
table.insert(html, callbackText)
end
for i2,callbackNParameter in ipairs(callbackNParameters) do
local callbackTokens = p.split(callbackNParameter, ' ')
local parameterType = callbackTokens[1]
local parameterName = callbackTokens[2]
local description = p.formatDescription(table.concat(callbackTokens, ' ', 3))
rows[i2] = { i2..') ', p.formatType(parameterType, frame), p.formatName(parameterName, frame), description }
end
end
6,834

edits