کاربر ناشناس
remove test deleted a decade ago
جز (۱ نسخه واردشده) |
(remove test deleted a decade ago) |
||
خط ۱: | خط ۱: | ||
-- This module implements {{documentation}}. | -- This module implements {{documentation}}. | ||
خط ۳۳: | خط ۳۲: | ||
expectType = expectType or 'string' | expectType = expectType or 'string' | ||
if type(msg) ~= expectType then | if type(msg) ~= expectType then | ||
error(' | error('message: type error in message cfg.' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2) | ||
end | end | ||
if not valArray then | if not valArray then | ||
خط ۴۱: | خط ۴۰: | ||
local function getMessageVal(match) | local function getMessageVal(match) | ||
match = tonumber(match) | match = tonumber(match) | ||
return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4) | |||
return valArray[match] or error(' | |||
end | end | ||
return ugsub(msg, '$([1- | return ugsub(msg, '$([1-9][0-9]*)', getMessageVal) | ||
end | end | ||
خط ۹۸: | خط ۹۶: | ||
valueFunc = function (key, value) | valueFunc = function (key, value) | ||
if type(value) == 'string' then | if type(value) == 'string' then | ||
value = | value = value:match('^%s*(.-)%s*$') -- Remove whitespace. | ||
if key == 'heading' or value ~= '' then | if key == 'heading' or value ~= '' then | ||
return value | return value | ||
خط ۱۱۸: | خط ۱۱۶: | ||
function p.nonexistent(frame) | function p.nonexistent(frame) | ||
if mw.title.getCurrentTitle().subpageText == ' | if mw.title.getCurrentTitle().subpageText == 'testcases' then | ||
return frame:expandTemplate{title = ' | return frame:expandTemplate{title = 'module test cases notice'} | ||
else | else | ||
return p.main(frame) | return p.main(frame) | ||
خط ۳۱۳: | خط ۳۱۱: | ||
if templateTitle.exists and sandboxTitle.exists then | if templateTitle.exists and sandboxTitle.exists then | ||
local compareUrl = mw.uri.fullUrl( | local compareUrl = mw.uri.fullUrl( | ||
' | 'Special:ComparePages', | ||
{ page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText} | { page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText} | ||
) | ) | ||
خط ۴۶۱: | خط ۴۵۹: | ||
env = env or p.getEnvironment(args) | env = env or p.getEnvironment(args) | ||
local links | local links | ||
local content = args.content | local content = args.content | ||
if not content or args[1] then | if not content or args[1] then | ||
-- No need to include the links if the documentation is on the template page itself. | -- No need to include the links if the documentation is on the template page itself. | ||
خط ۴۹۰: | خط ۴۸۸: | ||
-- 'history-link-display' --> 'history' | -- 'history-link-display' --> 'history' | ||
-- 'purge-link-display' --> 'purge' | -- 'purge-link-display' --> 'purge' | ||
-- 'module-preload' --> 'Template:Documentation/preload-module-doc' | -- 'module-preload' --> 'Template:Documentation/preload-module-doc' | ||
-- 'docpage-preload' --> 'Template:Documentation/preload' | -- 'docpage-preload' --> 'Template:Documentation/preload' | ||
خط ۵۱۶: | خط ۵۱۳: | ||
local preload = args.preload | local preload = args.preload | ||
if not preload then | if not preload then | ||
if | if subjectSpace == 828 then -- Module namespace | ||
preload = message('module-preload') | preload = message('module-preload') | ||
else | else | ||
خط ۶۵۶: | خط ۶۵۱: | ||
env = env or p.getEnvironment(args) | env = env or p.getEnvironment(args) | ||
local docTitle = env.docTitle | local docTitle = env.docTitle | ||
local content = args.content | local content = args.content | ||
if not content and docTitle and docTitle.exists then | if not content and docTitle and docTitle.exists then | ||
content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText} | content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText} | ||
خط ۶۷۰: | خط ۶۶۵: | ||
env = env or p.getEnvironment(args) | env = env or p.getEnvironment(args) | ||
local docTitle = env.docTitle | local docTitle = env.docTitle | ||
if not | if not args.content and docTitle and docTitle.exists then | ||
return docTitle.prefixedText | return docTitle.prefixedText | ||
else | else | ||
خط ۷۲۵: | خط ۷۲۰: | ||
-- "Editors can experiment in this template's sandbox and testcases pages." | -- "Editors can experiment in this template's sandbox and testcases pages." | ||
text = text .. (p.makeExperimentBlurb(args, env) or '') .. '<br />' | text = text .. (p.makeExperimentBlurb(args, env) or '') .. '<br />' | ||
if not | if not args.content and not args[1] then | ||
-- "Please add categories to the /doc subpage." | -- "Please add categories to the /doc subpage." | ||
-- Don't show this message with inline docs or with an explicitly specified doc page, | -- Don't show this message with inline docs or with an explicitly specified doc page, | ||
خط ۹۴۴: | خط ۹۳۹: | ||
end | end | ||
local subpagesLink = makeWikilink( | local subpagesLink = makeWikilink( | ||
' | 'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/', | ||
message('subpages-link-display', {pagetype}) | message('subpages-link-display', {pagetype}) | ||
) | ) |