Module:Sandbox/Johnuniq/debug explained

--[=[ Module:Sandbox/Johnuniq/debug -- Whatever is pasted in the debug console is interpreted as a single command. -- That means you cannot paste, say, two lines where each is a command. -- In the debug console, can get the current frame and pass it to main. -- Setting args has no effect. f = mw.getCurrentFrame f.args[1] = 'Ignored'f.args[2] = 42=mw.logObject(f, 'f')=p.main(f)

-- Can create a child frame with specified args.f2 = f:newChildf3 = mw.getCurrentFrame:newChild=mw.logObject(f2, 'f2')=p.main(f2)=p.main(f3)

-- If main uses Module:Arguments, can pass a table to main.-- That means argument values may be any data type (normally, arguments are strings).-- main gets a table, not a frame, so methods like frame:getTitle cannot be used.=p.mainargs

-- See talk for examples of displaying a table.

]=]

local function spell(number) local names = if number >= 200 then mw.log('number = ' .. number) mw.logObject(names, 'names') end local digits = repeat local unit = number % 10 number = math.floor(number / 10) digits = names[unit] .. digits until number

0 return digitsend

local function listArgs(frame, args) local results, n =, 0 local function add(k, v) n = n + 1 if type(k)

'string' then k = '"' .. k .. '"' end results[n] = 'parameter ' .. tostring(k) .. ', value ' .. tostring(v) end for k, v in pairs(args) do add(k, v) if tonumber(v) then add('...spelled', spell(tonumber(v))) elseif type(v)

'string' and v:sub(1, 2)