「モジュール:Documentation」の版間の差分

sync from sandbox, add aria role and label to container
mediawiki>本日晴天
(コメントを修正)
 
mediawiki>Matt Fitzpatrick
(sync from sandbox, add aria role and label to container)
3行目: 3行目:
-- Get required modules.
-- Get required modules.
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local messageBox = require('Module:Message box')


-- Get the config table.
-- Get the config table.
33行目: 32行目:
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
41行目: 40行目:
local function getMessageVal(match)
local function getMessageVal(match)
match = tonumber(match)
match = tonumber(match)
return valArray[match] or error('メッセージ: メッセージ設定で$' .. match .. 'キーの値が見つかりませんでした。' .. cfgKey, 4)
return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4)
end
end


140行目: 139行目:
-- 'documentation-container'
-- 'documentation-container'
:addClass(message('container'))
:addClass(message('container'))
:attr('role', 'complementary')
:attr('aria-labelledby', args.heading ~= '' and 'documentation-heading' or nil)
:attr('aria-label', args.heading == '' and 'Documentation' or nil)
:newline()
:newline()
:tag('div')
:tag('div')
178行目: 180行目:
-- env.sandboxTitle - the /sandbox subpage.
-- env.sandboxTitle - the /sandbox subpage.
-- env.testcasesTitle - the /testcases subpage.
-- env.testcasesTitle - the /testcases subpage.
-- env.printTitle - the print version of the template, located at the /Print subpage.
--
--
-- Data includes:
-- Data includes:
272行目: 273行目:
--]]
--]]
return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))
return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))
end
function envFuncs.printTitle()
--[[
-- Title object for the /Print subpage.
-- Messages:
-- 'print-subpage' --> 'Print'
--]]
return env.templateTitle:subPageTitle(message('print-subpage'))
end
end


435行目: 427行目:
local editProt = protectionLevels.edit and protectionLevels.edit[1]
local editProt = protectionLevels.edit and protectionLevels.edit[1]
local moveProt = protectionLevels.move and protectionLevels.move[1]
local moveProt = protectionLevels.move and protectionLevels.move[1]
-- 日本語版独自仕様: 編集保護と移動保護で保護レベルが異なる場合に、両方のアイコンを表示する
local ret = ''
if editProt then
if editProt then
-- The page is edit-protected.
-- The page is edit-protected.
ret = ret .. require('Module:Protection banner')._main{
return require('Module:Protection banner')._main{
message('protection-reason-edit'), small = true
message('protection-reason-edit'), small = true
}
}
end
elseif moveProt and moveProt ~= 'autoconfirmed' then
if moveProt and moveProt ~= editProt and moveProt ~= 'autoconfirmed' then
-- The page is move-protected but not edit-protected. Exclude move
-- The page is move-protected.
-- protection with the level "autoconfirmed", as this is equivalent to
ret = ret .. require('Module:Protection banner')._main{
-- no move protection at all.
return require('Module:Protection banner')._main{
action = 'move', small = true
action = 'move', small = true
}
}
else
return nil
end
end
return ret
end
end


500行目: 491行目:
-- 'history-link-display' --> 'history'
-- 'history-link-display' --> 'history'
-- 'purge-link-display' --> 'purge'
-- 'purge-link-display' --> 'purge'
-- 'file-docpage-preload' --> 'Template:Documentation/preload-filespace'
-- 'module-preload' --> 'Template:Documentation/preload-module-doc'
-- 'module-preload' --> 'Template:Documentation/preload-module-doc'
-- 'docpage-preload' --> 'Template:Documentation/preload'
-- 'docpage-preload' --> 'Template:Documentation/preload'
511行目: 501行目:
return nil
return nil
end
end
if docTitle.isRedirect then
if docTitle.isRedirect then  
docTitle = docTitle.redirectTarget
docTitle = docTitle.redirectTarget
end
end
526行目: 516行目:
local preload = args.preload
local preload = args.preload
if not preload then
if not preload then
if subjectSpace == 6 then -- File namespace
if subjectSpace == 828 then -- Module namespace
preload = message('file-docpage-preload')
elseif subjectSpace == 828 then -- Module namespace
preload = message('module-preload')
preload = message('module-preload')
else
else
541行目: 529行目:
function p.renderStartBoxLinks(data)
function p.renderStartBoxLinks(data)
--[[
--[[
-- Generates the [view][edit][history][purge] or [create] links from the data table.
-- Generates the [view][edit][history][purge] or [create][purge] links from the data table.
-- @data - a table of data generated by p.makeStartBoxLinksData
-- @data - a table of data generated by p.makeStartBoxLinksData
--]]
--]]
555行目: 543行目:
local docTitle = data.docTitle
local docTitle = data.docTitle
local title = data.title
local title = data.title
local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay)
if docTitle.exists then
if docTitle.exists then
local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay)
local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay)
local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay)
local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay)
local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay)
ret = '[%s] [%s] [%s] [%s]'
ret = '[%s] [%s] [%s] [%s]'
ret = escapeBrackets(ret)
ret = escapeBrackets(ret)
565行目: 553行目:
else
else
local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
ret = '[%s]'
ret = '[%s] [%s]'
ret = escapeBrackets(ret)
ret = escapeBrackets(ret)
ret = mw.ustring.format(ret, createLink)
ret = mw.ustring.format(ret, createLink, purgeLink)
end
end
return ret
return ret
642行目: 630行目:
:tag('span')
:tag('span')
:addClass(data.headingClass)
:addClass(data.headingClass)
:attr('id', 'documentation-heading')
:cssText(data.headingStyleText)
:cssText(data.headingStyleText)
:wikitext(data.heading)
:wikitext(data.heading)
742行目: 731行目:
end
end
text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template"
text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template"
local printBlurb = p.makePrintBlurb(args, env) -- Two-line blurb about print versions of templates.
if printBlurb then
text = text .. '<br />' .. printBlurb
end
end
end
end
end
local box = mw.html.create('div')
local box = mw.html.create('div')
-- 'documentation-metadata'
box:attr('role', 'note')
box:attr('role', 'note')
-- 'documentation-metadata'
:addClass(message('end-box-class'))
:addClass(message('end-box-class'))
-- 'plainlinks'
-- 'plainlinks'
887行目: 872行目:
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 testcasesTitle.contentModel == "Scribunto" 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)
962行目: 947行目:
)
)
return message('subpages-blurb', {subpagesLink})
return message('subpages-blurb', {subpagesLink})
end
function p.makePrintBlurb(args, env)
--[=[
-- Generates the blurb displayed when there is a print version of the template available.
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
-- Messages:
-- 'print-link-display' --> '/Print'
-- 'print-blurb' --> 'A [[Help:Books/for experts#Improving the book layout|print version]]'
-- .. ' of this template exists at $1.'
-- .. ' If you make a change to this template, please update the print version as well.'
-- 'display-print-category' --> true
-- 'print-category' --> 'Templates with print versions'
--]=]
local printTitle = env.printTitle
if not printTitle then
return nil
end
local ret
if printTitle.exists then
local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display'))
ret = message('print-blurb', {printLink})
local displayPrintCategory = message('display-print-category', nil, 'boolean')
if displayPrintCategory then
ret = ret .. makeCategoryLink(message('print-category'))
end
end
return ret
end
end