Module:Documentation: Difference between revisions
m
13 revisions imported: import clickable buttons 2
(add the equivalent of {{clear}} before the sandbox notice - this was in the old {{documentation}} template, but somehow didn't find its way into the module before) |
m (13 revisions imported: import clickable buttons 2) |
||
(43 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 170 ⟶ 168:
--
-- Data includes:
-- env.protectionLevels - the protection levels table of the title object.
-- env.subjectSpace - the number of the title's subject namespace.
-- env.docSpace - the number of the namespace the title puts its documentation in.
Line 269 ⟶ 268:
--]]
return env.templateTitle:subPageTitle(message('print-subpage'))
end▼
function envFuncs.protectionLevels()
-- The protection levels table of the title object.
return env.title.protectionLevels
end
Line 327 ⟶ 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 351 ⟶ 355:
-- "This is the template sandbox for [[Template:Foo]] (diff)."
local text = ''
local pagetype
if subjectSpace == 10 then
Line 363 ⟶ 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 374 ⟶ 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 392 ⟶ 402:
-- 'protection-template' --> 'pp-template'
-- 'protection-template-args' --> {docusage = 'yes'}
local protectionLevels, mProtectionBanner
local title = env.title
protectionLevels = env.protectionLevels
local protectionTemplate = message('protection-template')▼
if not protectionLevels then
return nil
end
local editProt = protectionLevels.edit and protectionLevels.edit[1]
local moveProt = protectionLevels.move and protectionLevels.move[1]
if editProt then
-- The page is edit-protected.
mProtectionBanner = require('Module:Protection banner')
if level ~= '' then▼
return level▼
return mProtectionBanner._main{reason, small = true}
▲ else
elseif moveProt and moveProt ~= 'autoconfirmed' then
▲ end
-- protection with the level "autoconfirmed", as this is equivalent to
▲ end
-- no move protection at all.
mProtectionBanner = require('Module:Protection banner')
return mProtectionBanner._main{action = 'move', small = true}
▲ -- The page is full-move protected, or full, template, or semi-protected.
else
end
return nil▼
end
Line 436 ⟶ 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 474 ⟶ 483:
if not title or not docTitle then
return nil
end
if docTitle.isRedirect then
docTitle = docTitle.redirectTarget
end
Line 541 ⟶ 553:
--
-- Messages:
-- 'documentation-icon-wikitext' --> '[[File:Test Template Info-
-- 'template-namespace-heading' --> 'Template documentation'
-- 'module-namespace-heading' --> 'Module documentation'
Line 601 ⟶ 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 636 ⟶ 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
end
end
Line 704 ⟶ 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 785 ⟶ 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 833 ⟶ 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 =
mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
end
local mirrorDisplay = message('mirror-link-display')
local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
Line 845 ⟶ 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
|