可在模块:文件页信息框/doc创建此模块的帮助文档
local p = {}
local b = require("Module:Basic")
function p.main(frame)
local args = frame.args
local be_data_list = { "描述", "状态", "人物", "许可", "来源", "注释" }
local be_have_template_list = { "状态", "人物", "许可" }
local smwset_set_table = {}
local html = mw.html.create()
local tableElem = html:tag('table')
:addClass('wikitable')
:addClass('doc')
for _, value in ipairs(args) do
for _, s_value in ipairs(be_data_list) do
if mw.ustring.find(value, "模板:" .. s_value) then
args[s_value] = value
end
end
end
for _, row_data in ipairs(be_data_list) do
local row = tableElem:tag('tr')
row:tag('th'):wikitext(row_data)
if b.is_include_value(row_data, be_have_template_list) then
if mw.ustring.find(args[row_data], "模板:" .. row_data) then
row:tag('td'):wikitext(args[row_data])
else
row:tag('td'):wikitext("{{" .. row_data .. "|" .. args[row_data] .. "}}")
end
else
local temporary_list = b.str_split(args[row_data], "、")
for _, value in ipairs(temporary_list) do
table.insert(smwset_set_table, row_data .. '=' .. value)
end
row:tag('td'):wikitext(args[row_data])
end
end
mw.smw.set(smwset_set_table)
local result = frame:preprocess(tostring(html))
return result
end
--
return p