Module:Documentation: Difference between revisions
m
13 revisions imported: import clickable buttons 2
(use title.protectionLevels instead of {{PROTECTIONLEVEL}} in p.protectionTemplate) |
m (13 revisions imported: import clickable buttons 2) |
||
(41 intermediate revisions by 18 users not shown) | |||
Line 3:
-- Get required modules.
local getArgs = require('Module:Arguments').getArgs
local messageBox = require('Module:Message box')
Line 128 ⟶ 127:
--]]
local env = p.getEnvironment(args)
local root =
root
-- This div tag is from {{documentation/start box}}, but moving it here
-- so that we don't have to worry about unclosed tags.
▲ .wikitext(p.addTrackingCategories(env))
return tostring(root)
end
Line 333 ⟶ 331:
--
-- Messages:
-- 'sandbox-notice-image' --> '[[Image:Sandbox.
-- 'sandbox-notice-blurb' --> 'This is the $1 for $2.'
-- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).'
Line 357 ⟶ 355:
-- "This is the template sandbox for [[Template:Foo]] (diff)."
local text = ''
local pagetype
if subjectSpace == 10 then
Line 369 ⟶ 365:
local templateLink = makeWikilink(templateTitle.prefixedText)
local compareUrl = env.compareUrl
if
text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})▼
else▼
local compareDisplay = message('sandbox-notice-compare-link-display')
local compareLink = makeUrlLink(compareUrl, compareDisplay)
text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
▲ else
▲ text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
end
-- Get the test cases page blurb if the page exists. This is something like
Line 380 ⟶ 376:
local testcasesTitle = env.testcasesTitle
if testcasesTitle and testcasesTitle.exists then
if testcasesTitle.contentModel == "Scribunto" then
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)▼
▲ local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
text = text .. '<br />' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink})
else
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink})
end
end
-- Add the sandbox to the sandbox category.
Line 398 ⟶ 402:
-- 'protection-template' --> 'pp-template'
-- 'protection-template-args' --> {docusage = 'yes'}
local protectionLevels, mProtectionBanner
local title = env.title
if not protectionLevels then
return nil
end
local
if editProt then
-- The page is edit-protected.
mProtectionBanner = require('Module:Protection banner')
-- The page is full-move protected, or full, template, or semi-protected.▼
local
return mProtectionBanner._main{reason, small = true}
elseif moveProt and moveProt ~= 'autoconfirmed' then
-- 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
return nil
Line 437 ⟶ 445:
local links
local content = args.content
if not content or args[1] then
-- No need to include the links if the documentation is on the template page itself.
local linksData = p.makeStartBoxLinksData(args, env)
Line 475 ⟶ 483:
if not title or not docTitle then
return nil
end
if docTitle.isRedirect then
docTitle = docTitle.redirectTarget
end
Line 542 ⟶ 553:
--
-- Messages:
-- 'documentation-icon-wikitext' --> '[[File:Test Template Info-
-- 'template-namespace-heading' --> 'Template documentation'
-- 'module-namespace-heading' --> 'Module documentation'
Line 602 ⟶ 613:
-- Renders the start box html.
-- @data - a table of data generated by p.makeStartBoxData.
local sbox =
sbox
local links = data.links
if links then
sbox
end
return tostring(sbox)
Line 637 ⟶ 648:
local content = args.content
if not content and docTitle and docTitle.exists then
end
-- The line breaks below are necessary so that "=== Headings ===" at the start and end
-- of docs are interpreted correctly.
return '\n' .. (content or '') .. '\n'
end
p.contentTitle = makeInvokeFunc('_contentTitle')
function p._contentTitle(args, env)
env = env or p.getEnvironment(args)
local docTitle = env.docTitle
if not args.content and docTitle and docTitle.exists then
return docTitle.prefixedText
else
return ''
end
end
Line 705 ⟶ 727:
-- Add sandbox and testcases links.
-- "Editors can experiment in this template's sandbox and testcases pages."
text = text .. (p.makeExperimentBlurb(args, env) or '')
text = text .. '<br />'
if not args.content and not args[1] then
Line 786 ⟶ 808:
-- 'mirror-edit-summary' --> 'Create sandbox version of $1'
-- 'mirror-link-display' --> 'mirror'
-- '
-- 'sandbox-link-display' --> 'sandbox'
-- 'testcases-link-display' --> 'testcases'
-- 'testcases-edit-link-display'--> 'edit'
▲ -- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases'
-- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'
-- 'testcases-create-link-display' --> 'create'
Line 834 ⟶ 856:
local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
local mirrorPreload = message('mirror-link-preload')
local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload =
if subjectSpace == 828 then
mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
end
local mirrorDisplay = message('mirror-link-display')
local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
Line 846 ⟶ 872:
local testcasesEditDisplay = message('testcases-edit-link-display')
local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
-- for Modules, add testcases run link if exists
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)▼
if testcasesTitle.contentModel == "Scribunto" and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
local testcasesRunLinkDisplay = message('testcases-run-link-display')
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink)
else
▲ testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
end
else
local testcasesPreload
|