پودمان:Documentation: تفاوت میان نسخه‌ها

 
(Only load Module:Module wikitext if it's actually needed)
خط ۱: خط ۱:
-- برای فارسی‌سازی بهتر، بعضی از قسمت‌های این پودمان تغییر کرده‌است. لطفاً هنگام به‌روزرسانی به توضیحات پودمان توجه کنید.
-- 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('پیام: خطای نوع در متن cfg.' .. cfgKey .. ' (' .. expectType .. ' انتظار می‌رفت، ' .. type(msg) .. ' بدست آمد)', 2)
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('پیام: هیچ مقداری برای کلید $' .. match .. ' در متن cfg.' .. cfgKey .. ' یافت نشد', 4)
end
end


خط ۱۳۱: خط ۱۲۹:
local root = mw.html.create()
local root = mw.html.create()
root
root
:wikitext(p._getModuleWikitext(args, env))
:wikitext(p.protectionTemplate(env))
:wikitext(p.protectionTemplate(env))
:wikitext(p.sandboxNotice(args, env))
:wikitext(p.sandboxNotice(args, env))
خط ۳۱۰: خط ۳۰۹:
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}
)
)
خط ۳۲۵: خط ۳۲۴:
-- Auxiliary templates
-- Auxiliary templates
----------------------------------------------------------------------------
----------------------------------------------------------------------------
p.getModuleWikitext = makeInvokeFunc('_getModuleWikitext')
function p._getModuleWikitext(args, env)
local currentTitle = mw.title.getCurrentTitle()
if currentTitle.contentModel ~= 'Scribunto' then return end
pcall(require, currentTitle.prefixedText) -- if it fails, we don't care
local moduleWikitext =  package.loaded["Module:Module wikitext"]
if moduleWikitext then
return moduleWikitext.main()
end
end


function p.sandboxNotice(args, env)
function p.sandboxNotice(args, env)
خط ۳۷۸: خط ۳۸۹:
local testcasesTitle = env.testcasesTitle
local testcasesTitle = env.testcasesTitle
if testcasesTitle and testcasesTitle.exists then
if testcasesTitle and testcasesTitle.exists then
if testcasesTitle.namespace == mw.site.namespaces.Module.id then
if testcasesTitle.contentModel == "Scribunto" then
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
خط ۴۴۷: خط ۴۵۸:
local links
local links
local content = args.content
local content = args.content
if not content 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.
local linksData = p.makeStartBoxLinksData(args, env)
local linksData = p.makeStartBoxLinksData(args, env)
خط ۴۸۵: خط ۴۹۶:
if not title or not docTitle then
if not title or not docTitle then
return nil
return nil
end
if docTitle.isRedirect then
docTitle = docTitle.redirectTarget
end
end


خط ۸۷۲: خط ۸۸۶:
local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
-- for Modules, add testcases run link if exists
-- for Modules, add testcases run link if exists
if subjectSpace == 828 and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
if testcasesTitle.contentModel == "Scribunto"  and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
local testcasesRunLinkDisplay = message('testcases-run-link-display')
local testcasesRunLinkDisplay = message('testcases-run-link-display')
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
خط ۹۴۳: خط ۹۵۷:
end
end
local subpagesLink = makeWikilink(
local subpagesLink = makeWikilink(
'ویژه:نمایه پیشوندی/' .. templateTitle.prefixedText .. '/',
'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/',
message('subpages-link-display', {pagetype})
message('subpages-link-display', {pagetype})
)
)