Module:Documentation: Difference between revisions

Jump to navigation Jump to search
revert
(Reverted to revision 18690 by Tito Dutta (talk): Test. (TW))
(revert)
 
(23 intermediate revisions by 2 users not shown)
Line 146: Line 146:
.done()
.done()
.wikitext(p._endBox(args, env))
.wikitext(p._endBox(args, env))
.newline()
.wikitext(p.addTrackingCategories(env))
.wikitext(p.addTrackingCategories(env))
return tostring(root)
return tostring(root)
Line 170: Line 169:
--
--
-- Data includes:
-- Data includes:
-- env.protectionLevels - the protection levels table of the title object.
-- env.subjectSpace - the number of the title's subject namespace.
-- env.subjectSpace - the number of the title's subject namespace.
-- env.docSpace - the number of the namespace the title puts its documentation in.
-- env.docSpace - the number of the namespace the title puts its documentation in.
Line 269: Line 269:
--]]
--]]
return env.templateTitle:subPageTitle(message('print-subpage'))
return env.templateTitle:subPageTitle(message('print-subpage'))
end
function envFuncs.protectionLevels()
-- The protection levels table of the title object.
return env.title.protectionLevels
end
end


Line 327: Line 332:
--  
--  
-- Messages:
-- Messages:
-- 'sandbox-notice-image' --> '[[Image:Sandbox.png|50px|alt=|link=]]'
-- 'sandbox-notice-image' --> '[[Image:Sandbox.svg|50px|alt=|link=]]'
-- 'sandbox-notice-blurb' --> 'This is the $1 for $2.'
-- 'sandbox-notice-blurb' --> 'This is the $1 for $2.'
-- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).'
-- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).'
Line 374: Line 379:
local testcasesTitle = env.testcasesTitle
local testcasesTitle = env.testcasesTitle
if testcasesTitle and testcasesTitle.exists then
if testcasesTitle and testcasesTitle.exists then
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
if testcasesTitle.namespace == mw.site.namespaces.Module.id then
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink})
local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
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
end
-- Add the sandbox to the sandbox category.
-- Add the sandbox to the sandbox category.
text = text .. makeCategoryLink(message('sandbox-category'))
text = text .. makeCategoryLink(message('sandbox-category'))
omargs.text = text
omargs.text = text
return messageBox.main('ombox', omargs)
local ret = '<div style="clear: both;"></div>'
ret = ret .. messageBox.main('ombox', omargs)
return ret
end
end


Line 390: Line 405:
-- '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
local protectionTemplate = message('protection-template')
if title.namespace ~= 10 and title.namespace ~= 828 then
local namespace = title.namespace
if not (protectionTemplate and (namespace == 10 or 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
end
end
local frame = mw.getCurrentFrame()
protectionLevels = env.protectionLevels
local function getProtectionLevel(protectionType, page)
if not protectionLevels then
-- Gets the protection level for page, or for the current page if page is not specified.
return nil
local level = frame:callParserFunction('PROTECTIONLEVEL', protectionType, page)
if level ~= '' then
return level
else
return nil -- The parser function returns the blank string if there is no match.
end
end
end
local prefixedTitle = title.prefixedText
local editProt = protectionLevels.edit and protectionLevels.edit[1]
if getProtectionLevel('move', prefixedTitle) == 'sysop' or getProtectionLevel('edit', prefixedTitle) then
local moveProt = protectionLevels.move and protectionLevels.move[1]
-- The page is full-move protected, or full, template, or semi-protected.
if editProt then
return frame:expandTemplate{title = protectionTemplate, args = message('protection-template-args', nil, 'table')}
-- The page is edit-protected.
mProtectionBanner = require('Module:Protection banner')
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
return nil
end
end
return nil
end
end


Line 539: Line 557:
--
--
-- Messages:
-- Messages:
-- 'documentation-icon-wikitext' --> '[[File:Template-info.png|50px|link=|alt=Documentation icon]]'
-- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=Documentation icon]]'
-- 'template-namespace-heading' --> 'Template documentation'
-- 'template-namespace-heading' --> 'Template documentation'
-- 'module-namespace-heading' --> 'Module documentation'
-- 'module-namespace-heading' --> 'Module documentation'
Line 634: Line 652:
local content = args.content
local content = args.content
if not content and docTitle and docTitle.exists then
if not content and docTitle and docTitle.exists then
local frame = mw.getCurrentFrame()
content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}
content = frame:expandTemplate{title = docTitle.prefixedText}
end
end
-- The line breaks below are necessary so that "=== Headings ===" at the start and end
-- The line breaks below are necessary so that "=== Headings ===" at the start and end
-- of docs are interpreted correctly.
-- of docs are interpreted correctly.
return '\n' .. (content or '') .. '\n'  
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
end


Line 702: Line 731:
-- 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
14,061

edits

Navigation menu