「モジュール:Documentation」の版間の差分
ナビゲーションに移動
検索に移動
en:Module:Documentation 16:34, 28 August 2015(UTC)より
編集の要約なし |
template>K-iczn (en:Module:Documentation 16:34, 28 August 2015(UTC)より) |
||
1行目: | 1行目: | ||
-- This | -- This module implements {{documentation}}. | ||
-- Get required modules. | -- Get required modules. | ||
local getArgs = require(' | local getArgs = require('Module:Arguments').getArgs | ||
local messageBox = require('Module:Message box') | |||
local messageBox = require(' | |||
-- Get the config table. | -- Get the config table. | ||
local cfg = mw.loadData(' | local cfg = mw.loadData('Module:Documentation/config') | ||
local p = {} | local p = {} | ||
34行目: | 33行目: | ||
expectType = expectType or 'string' | expectType = expectType or 'string' | ||
if type(msg) ~= expectType then | if type(msg) ~= expectType then | ||
error(' | error('メッセージ: メッセージCFGの入力エラー。' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2) | ||
end | end | ||
if not valArray then | if not valArray then | ||
42行目: | 41行目: | ||
local function getMessageVal(match) | local function getMessageVal(match) | ||
match = tonumber(match) | match = tonumber(match) | ||
return valArray[match] or error(' | return valArray[match] or error('メッセージ: メッセージCFGにおいて$' .. match .. 'キーへの値の入力が必要です。' .. cfgKey, 4) | ||
end | end | ||
128行目: | 127行目: | ||
--]] | --]] | ||
local env = p.getEnvironment(args) | local env = p.getEnvironment(args) | ||
local root = | local root = mw.html.create() | ||
root | root | ||
:wikitext(p.protectionTemplate(env)) | |||
:wikitext(p.sandboxNotice(args, env)) | |||
-- This div tag is from {{documentation/start box}}, but moving it here | -- This div tag is from {{documentation/start box}}, but moving it here | ||
-- so that we don't have to worry about unclosed tags. | -- so that we don't have to worry about unclosed tags. | ||
:tag('div') | |||
:attr('id', message('main-div-id')) | |||
:addClass(message('main-div-classes')) | |||
:newline() | |||
:wikitext(p._startBox(args, env)) | |||
:wikitext(p._content(args, env)) | |||
:tag('div') | |||
:css('clear', 'both') -- So right or left floating items don't stick out of the doc box. | |||
:newline() | |||
:done() | |||
:done() | |||
:wikitext(p._endBox(args, env)) | |||
:wikitext(p.addTrackingCategories(env)) | |||
return tostring(root) | return tostring(root) | ||
end | end | ||
409行目: | 404行目: | ||
-- 'protection-template' --> 'pp-template' | -- 'protection-template' --> 'pp-template' | ||
-- 'protection-template-args' --> {docusage = 'yes'} | -- 'protection-template-args' --> {docusage = 'yes'} | ||
local protectionLevels, mProtectionBanner | |||
local title = env.title | local title = env.title | ||
if title.namespace ~= 10 and title.namespace ~= 828 then | |||
-- Don't display the protection template if we are not in the template or module namespaces. | -- Don't display the protection template if we are not in the template or module namespaces. | ||
return nil | return nil | ||
421行目: | 414行目: | ||
return nil | return nil | ||
end | end | ||
local | local editProt = protectionLevels.edit and protectionLevels.edit[1] | ||
local | local moveProt = protectionLevels.move and protectionLevels.move[1] | ||
if editProt then | |||
-- The page is | -- The page is edit-protected. | ||
mProtectionBanner = require('Module:Protection banner') | |||
return | local reason = message('protection-reason-edit') | ||
return mProtectionBanner._main{reason, small = true} | |||
elseif moveProt and moveProt ~= 'autoconfirmed' then | |||
-- The page is move-protected but not edit-protected. Exclude move | |||
-- protection with the level "autoconfirmed", as this is equivalent to | |||
-- no move protection at all. | |||
mProtectionBanner = require('Module:Protection banner') | |||
return mProtectionBanner._main{action = 'move', small = true} | |||
else | else | ||
return nil | return nil | ||
616行目: | 616行目: | ||
-- Renders the start box html. | -- Renders the start box html. | ||
-- @data - a table of data generated by p.makeStartBoxData. | -- @data - a table of data generated by p.makeStartBoxData. | ||
local sbox = | local sbox = mw.html.create('div') | ||
sbox | sbox | ||
:css('padding-bottom', '3px') | |||
:css('border-bottom', '1px solid #aaa') | |||
:css('margin-bottom', '1ex') | |||
:newline() | |||
:tag('span') | |||
:cssText(data.headingStyleText) | |||
:css('font-weight', data.headingFontWeight) | |||
:css('font-size', data.headingFontSize) | |||
:wikitext(data.heading) | |||
local links = data.links | local links = data.links | ||
if links then | if links then | ||
sbox | sbox:tag('span') | ||
:addClass(data.linksClass) | |||
:attr('id', data.linksId) | |||
:wikitext(links) | |||
end | end | ||
return tostring(sbox) | return tostring(sbox) | ||
730行目: | 730行目: | ||
-- Add sandbox and testcases links. | -- Add sandbox and testcases links. | ||
-- "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) | text = text .. (p.makeExperimentBlurb(args, env) or '') | ||
text = text .. '<br />' | text = text .. '<br />' | ||
if not args.content and not args[1] then | if not args.content and not args[1] then | ||
811行目: | 811行目: | ||
-- 'mirror-edit-summary' --> 'Create sandbox version of $1' | -- 'mirror-edit-summary' --> 'Create sandbox version of $1' | ||
-- 'mirror-link-display' --> 'mirror' | -- 'mirror-link-display' --> 'mirror' | ||
-- 'mirror-link-preload' --> 'Template:Documentation/mirror' | |||
-- 'sandbox-link-display' --> 'sandbox' | -- 'sandbox-link-display' --> 'sandbox' | ||
-- 'testcases-link-display' --> 'testcases' | -- 'testcases-link-display' --> 'testcases' | ||
-- 'testcases-edit-link-display'--> 'edit' | -- 'testcases-edit-link-display'--> 'edit' | ||
-- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' | -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' | ||
-- 'testcases-create-link-display' --> 'create' | -- 'testcases-create-link-display' --> 'create' | ||
859行目: | 859行目: | ||
local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay) | local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay) | ||
local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)}) | local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)}) | ||
local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = | local mirrorPreload = message('mirror-link-preload') | ||
local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary} | |||
local mirrorDisplay = message('mirror-link-display') | local mirrorDisplay = message('mirror-link-display') | ||
local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay) | local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay) |