Extension:Scribunto/Debug console

From MediaWiki.org
Jump to navigation Jump to search

Usage

Under the module editing window there are two useful fields. In one of them you can enter the name of an existing page and see how the changed version of the module will work on it. The second is the debugger window. There you can enter any line of text on Lua; the following is an example of code entered into the console debugging of the fn function, which is planned to be used in the call{{#invoke: Module | fn | a1 | a2 | un = ua | a3}}

--simplest case, may not work with getArgs() function
=p.fn{args={"a1","a2",["un"]="ua","a3"}} 

--if the function involves using the methods of the frame object
=p.fn(mw.getCurrentFrame():newChild{title="whatever",args={"a1","a2",["un"]="ua","a3"}}) 

--if we test the function for application through the template {{SHA| sha1| sha2| ASH= SAH}}, the most accurate way
=p.fn(mw.getCurrentFrame():newChild{title="Template:SHA",args={"sha1","sha2",["ASH"]="SAH"}}:newChild{title="Module:Module",args={"a1","a2",["un"]="ua","a3"}})

print() mw.log() mw.logObject()can be used to display information in the console.