中文乐谱库
未登录
登录
搜索
导航
首页
最近更改
随机页面
乐谱
作曲家
所有乐谱
乐器/流派
国籍
时期
编辑
编辑作曲家
编辑乐谱
关于
捐助/支持
关于我们
成为贡献者
常见问题
工具
链入页面
相关更改
特殊页面
页面信息
页面历史
刷新页面
←
模块:Lang/documentor tool
查看“模块:Lang/documentor tool”的源代码
名字空间
模块
讨论
视图
查看
查看源代码
历史
操作
来自中文乐谱库
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
require('Module:No globals'); local p = {}; --[[-------------------------< L A N G - X X _ S E T T I N G S >----------------------------------------------- {{#invoke:Lang/documentor tool|lang_xx_settings|template={{ROOTPAGENAME}}}} reads the content of the template and extracts the parameters from {{#invoke:Lang|...}} for display on the template's documentation page ]] function p.lang_xx_settings (frame) local page = mw.title.makeTitle ('Template', frame.args['template'] or frame.args[1]); -- get a page object for this page in 'Template:' namespace if not page then return ''; -- TODO: error message? end local content = page:getContent(); -- get unparsed content if not page then return ''; -- TODO: error message? end local out = {}; local params; local style; if content:match ('{{%s*#invoke:%s*[Ll]ang%s*|[^|]+|[^}]+}}') or content:match ('{{%s*#invoke:%s*[Ll]ang/sandbox%s*|[^|]+|[^}]+}}') then -- if this template uses [[Module:Lang]] params = content:match ('{{%s*#invoke:%s*[Ll]ang%s*|[^|]+(|[^}]+)}}') or content:match ('{{%s*#invoke:%s*[Ll]ang/sandbox%s*|[^|]+(|[^}]+)}}') -- extract the #invoke:'s parameters if not params then return ''; -- there should be at least one or the template/module won't work TODO: error message? end table.insert (out, '{| class="wikitable" style="text-align:right; float:right"\n|+设定') -- start a wikitable for k, v in params:gmatch ('%s*|%s*([^%s=]+)%s*=%s*([^%s|]+)') do -- get the parameter names (k) and values (v) if 'label' == k then -- special case for labels because spaces and pipes v = params:match ('label%s*=%s*(%[%[[^%]]+%]%])') or params:match ('label%s*=%s*([^|\n]+)') or '缺少label'; end table.insert (out, table.concat ({k, '\n|', v})); -- make rudimentary wikitable entries end style = content:match ('lang_xx_([^|]+)'); return table.concat ({table.concat (out,'\n|-\n! scope="row" | '), '\n|-\n|colspan="2"|风格:', style, '\n|-\n|}'}); -- add inter-row markup and close the wikitable and done else return ''; -- does not use [[Module:Lang]] so abandon quietly end end --[[-------------------------< U S E S _ M O D U L E >--------------------------------------------------------- {{#invoke:Lang/documentor tool|uses_module|template={{ROOTPAGENAME}}}} reads the content of the template to determine if this {{lang-xx}} template uses Module:Lang. Returns the index of the substring '{{#invoke|lang|' in the template page content if true; empty string if false Used in template documentation {{#if:}} parser functions. ]] function p.uses_module (frame) local page = mw.title.makeTitle ('Template', frame.args['template'] or frame.args[1]); -- get a page object for this page in 'Template:' namespace if not page then return ''; -- TODO: error message? end local content = page:getContent(); -- get unparsed content if not page then return ''; -- TODO: error message? end return content:find ('{{%s*#invoke:[Ll]ang%s*|') or ''; -- return index or empty string end return p;
该页面使用的模板:
模块:Lang/documentor tool/doc
(
查看源代码
)
返回至
模块:Lang/documentor tool
。