Module:Documentation: Difference between revisions
mNo edit summary |
No edit summary |
||
| Line 3: | Line 3: | ||
local static = require('Module:Static') | local static = require('Module:Static') | ||
local | local i18n = { | ||
createOutputFormat = '%s%s', | |||
createSplitDocPagePrompt = '\n<!-- Put categories/interwikis on the documentation page -->', | |||
createNoSubstCategory = 'Category:Pages with templates requiring substitution', | |||
} | |||
local function getType( namespace, page ) | |||
local pageType = 'template' | local pageType = 'template' | ||
if namespace == 'Module' then | if namespace == 'Module' then | ||
pageType = 'module' | pageType = 'module' | ||
| Line 16: | Line 23: | ||
pageType = 'message' | pageType = 'message' | ||
end | end | ||
return pageType | return pageType | ||
end | end | ||
| Line 32: | Line 39: | ||
local templateArgs = {} | local templateArgs = {} | ||
for _, key in ipairs{ 'type', 'page', 'content', 'nodoc', 'baddoc' } do | for _, key in ipairs{ 'type', 'page', 'content', 'nodoc', 'baddoc' } do | ||
local val = args[key] | local val = args[ key ] | ||
if val then | if val then | ||
if key == 'content' then val = '\n' .. val .. '\n' end | if key == 'content' then val = '\n' .. val .. '\n' end | ||
| Line 38: | Line 45: | ||
end | end | ||
end | end | ||
out = '{{documentation|' .. table.concat( templateArgs, '|' ) .. '}}' | out = '{{documentation|' .. table.concat( templateArgs, '|' ) .. '}}' | ||
out = out:gsub( '|}}', '}}' ) | out = out:gsub( '|}}', '}}' ) | ||
out = i18n.createOutputFormat:format( out, args.content and '' or i18n.createSplitDocPagePrompt ) | |||
end | end | ||
if not mw.isSubsting() then | if not mw.isSubsting() then | ||
out = f:preprocess( out ) | out = f:preprocess( out ) | ||
if not args.nocat then | if not args.nocat then | ||
out = out .. '[[ | out = out .. '[[' .. i18n.createNoSubstCategory .. ']]' | ||
end | end | ||
end | end | ||
return out | return out | ||
end | end | ||