Módulo:Helper module
Documentação do módulo
Esta documentação é transcluída de Módulo:Helper module/doc. [editar] [atualizar]
Módulo:Helper module's a função main é invocada por Predefinição:Módulo de apoio.
Módulo:Helper module requer Módulo:Mw.html extension.
Módulo:Helper module requer Módulo:Tooltip.
Módulo:Helper module evoca Módulo:Helper module usando Lua.
Generates helper module information for use in documentation, which is automatically used by RuneScape:Lua/Helper modules.
-- <nowiki>
-- Helps [[RuneScape:Lua/Helper modules]] format its table with dynamic documentation
-- See [[Template:Helper module]] for documentation and usage
require('Módulo:Mw.html extension')
local tooltip = require('Módulo:Tooltip')
local p = {}
function p.main(frame)
local args = frame:getParent().args
local function_list = {}
-- Let there be no limit to number of parameters
local i = 1
while args['fname'..i] do
local funcname = args['fname'..i] or ''
local functype = args['ftype'..i] or ''
local funcuse = args['fuse'..i] or ''
function_list[i] = {
fname = funcname,
ftype = functype,
fdesc = funcuse
}
i = i + 1
end
local title = mw.title.getCurrentTitle()
if title.namespace == 828 and (title.text == args.name or title.text == args.name..'/doc') then
local t = mw.html.create('table')
t :addClass('wikitable')
:tag('tr')
:tag('th'):wikitext('Módulo'):done()
:tag('th'):wikitext('Função'):done()
:tag('th'):wikitext('Tipo'):done()
:tag('th'):wikitext('Uso'):done()
:IF(args.example)
:tag('th'):wikitext('Example'):done()
:END()
:done()
:wikitext(p._main(args.name, function_list, args.example or 'sem célula de exemplo'))
local category = ''
if not (title.isSubpage and title.subpageText == 'doc') then
category = '[[Categoria:Módulos de apoio]]'
end
local reqby = ''
if not (title.isSubpage and title.subpageText == 'doc') then
local uri = mw.uri.canonicalUrl('Special:WhatLinksHere', 'target=Module:'..args.name..'&namespace=828')
reqby = 'Para uma lista completa de módulos usando esse apoio <span class="plainlinks">[' .. tostring(uri) .. ' clique aqui]</span>\n'
end
return 'Este módulo é um módulo de apoio para ser usado por outros módulos; ele pode não ser projetado para ser invocado diretamente. See [[RuneScape:Lua/Helper modules]] for a full list and more information.\n' .. reqby .. tostring(t) .. category
else
return p._main(args.name,function_list, args.example)
end
end
local function formatFuncNames(list)
list = mw.text.split(list or '', ';;')
local res = {}
for _, v in ipairs(list) do
v = mw.text.trim(v)
table.insert(res, string.format("<code>%s</code>", v))
end
return table.concat(res, '<br>')
end
function p._main(modn, func_list, example)
local ret_row = mw.html.create('tr')
:tag('td')
-- Name will group together with all functions once
:attr('rowspan',#func_list)
:wikitext('[[Module:'..modn..'|'..modn..']]')
:done()
:tag('td')
:wikitext(formatFuncNames(func_list[1].fname))
:done()
:tag('td')
:wikitext(func_list[1].ftype)
:done()
:tag('td')
:wikitext(func_list[1].fdesc)
:done()
:IF(example ~= 'no example cell')
:tag('td')
:attr('rowspan',#func_list)
:IF(example)
:wikitext(tostring(tooltip._span{ name = modn, alt = 'Clique para ver'}), tostring(tooltip._div{name = modn, limitwidth = 'no', content = '<br>' .. (example or '')}))
:END()
:done()
:END()
:done()
local ret = tostring(ret_row)
for i=2,#func_list,1 do
local next_row = mw.html.create('tr')
:tag('td')
:wikitext(formatFuncNames(func_list[i].fname))
:done()
:tag('td')
:wikitext(func_list[i].ftype)
:done()
:tag('td')
:wikitext(func_list[i].fdesc)
:done()
:done()
ret = ret..tostring(next_row)
end
return ret
end
return p