「モジュール: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 | ||
-- 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(' | 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(' | 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. | ||
-- | -- | ||
-- 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 | 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] | ||
if editProt then | if editProt then | ||
-- The page is edit-protected. | -- The page is edit-protected. | ||
return require('Module:Protection banner')._main{ | |||
message('protection-reason-edit'), small = true | message('protection-reason-edit'), small = true | ||
} | } | ||
elseif moveProt 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 | ||
-- no move protection at all. | |||
return require('Module:Protection banner')._main{ | |||
action = 'move', small = true | action = 'move', small = true | ||
} | } | ||
else | |||
return nil | |||
end | end | ||
end | end | ||
500行目: | 491行目: | ||
-- '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' | ||
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 | if 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) | ||
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" | ||
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') | ||
: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 | end | ||