打开/关闭搜索
搜索
打开/关闭菜单
17
78
34
2.1K
INFWiki
导航
百科首页
最近更改
随机页面
特殊页面
上传文件
人气页面
入服指南
回响地标
百科创作
介绍
语法
打开/关闭外观设置菜单
notifications
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
登录
查看“︁模块:Helper module”︁的源代码
来自INFWiki
查看
阅读
查看源代码
查看历史
associated-pages
模块
讨论
更多操作
←
Helper module
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
-- <nowiki> -- Helps [[Star Citizen:Lua/Helper modules]] format its table with dynamic documentation -- See [[Template:Helper module]] for documentation and usage require('Module:Mw.html extension') local getArgs = require("Module:Arguments").getArgs; --local tooltip = require('Module:Tooltip') local userError = require("Module:User error"); local p = {} function p.main(frame) local args = getArgs(frame); 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 not args.name then return userError( "Missing required parameter 'name' to {{[[Template:Helper module|Helper module]]}}", "Erroneous parameter" ); end if title.namespace == 828 and (title.text == args.name or title.text == args.name..'/doc') then local t = ""; if #function_list > 0 then t = mw.html.create('table') :addClass('wikitable') :tr() :th('Function') :th('Type') :th('Use') :done() :node(p._main(args.name, function_list, nil, false)) :allDone() end local category = '' if not (title.isSubpage and title.subpageText == 'doc') then category = '[[Category:Helper modules]][[Category:Modules required by modules]]' 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 = 'For a full list of modules using this helper <span class="plainlinks">[' .. tostring(uri) .. ' click here]</span>\n' end local example = '' if args.example then example = "'''Example:'''\n" .. args.example end return 'This module is a helper module to be used by other modules; it may not designed to be invoked directly. See [[Star Citizen:Lua/Helper modules]] for a full list and more information.\n' .. reqby .. tostring(t) .. example .. category else return p._main(args.name, function_list, args.example or '', true) 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><samp>OR</samp><br>") end function p._main(modn, func_list, example, showModuleName) local ret = mw.html.create('tr') local rowspan = math.max(#func_list, 1); local func = func_list[1]; ret :IF(showModuleName) :td{'[[Module:'..modn..'|'..modn..']]', attr={'rowspan', rowspan}} -- Name will group together with all functions once :END() :IF(func):exec(function(self) return self :td(formatFuncNames(func.fname)) :td(func.ftype) :td(func.fdesc) end):ELSEIF(showModuleName or (example ~= nil)) :td{ class = "table-na", attr = { colspan = 3 } } :END() --:IF(example == '') -- :td{attr={'rowspan', rowspan}} --:ELSEIF(example ~= nil) -- :td{tostring(tooltip._span{ name = modn, alt = 'Show' }) .. -- tostring(tooltip._div{ name = modn, limitwidth = 'no', content = '<br>' .. (example or '') }), -- attr = {'rowspan', rowspan}} --:END() for i = 2, #func_list do func = func_list[i]; ret:tr() :td(formatFuncNames(func.fname)) :td(func.ftype) :td(func.fdesc) end return ret end return p -- </nowiki>
该页面使用的模板:
Helper module/doc
(
查看源代码
)
返回
Helper module
。
查看“︁模块:Helper module”︁的源代码
来自INFWiki