FANDOM


-- Shows functions or tables currently available for use in lua
local p = {}
 
-- list of frame methods available in Scribunto normally
-- source: <https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Frame_object>
-- last updated: 2015-03-10
local expectedFrameMethods = {
    'args',
    'callParserFunction',
    'expandTemplate',
    'extensionTag',
    'getParent',
    'getTitle',
    'newChild',
    'preprocess',
    'getArgument',
    'newParserValue',
    'newTemplateParserValue',
    'argumentPairs'
}
 
function p.view( frame )
 
    local frameMethods = {}
    for k, v in pairs( frame ) do
        frameMethods[k] = v
    end
 
    local sFunctions = mw.html.create( 'table' )
        :addClass( 'wikitable' )
        :addClass( 'sortable' )
        :tag( 'tr' )
            :tag( 'th' )
                :wikitext( 'Name' )
                :done()
            :tag( 'th' )
                :wikitext( 'Available?' )
                :done()
            :tag( 'th' )
                :wikitext( 'Type' )
                :done()
            :tag( 'th' )
                :wikitext( 'Docs' )
                :done()
            :done()
 
    local method, available
 
    for i = 1, #expectedFrameMethods do
        method = expectedFrameMethods[i]
        available = frameMethods[method]
 
        sFunctions
            :tag( 'tr' )
                :tag( 'td' )
                    :wikitext( method )
                    :done()
                :tag( 'td' )
                    :wikitext( available and 'Yes' or 'No' )
                    :done()
                :tag( 'td' )
                    :wikitext( available and type(available) or 'Unknown' )
                    :done()
                :tag( 'td' )
                    :wikitext( available and '[[Lua reference manual/Scribunto libraries#frame' .. ( method == 'args' and '.' or ':' ) .. method .. '|link]]' or '[[mw:Extension:Scribunto/Lua reference manual#frame' .. ( method == 'args' and '.' or ':' ) .. method .. '|mw link]]' )
                    :done()
                :done()
    end
 
    return sFunctions:allDone()
end 
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.