Difference between revisions of "Module:Documentation"

Jump to navigation Jump to search
reorder end box functions
>Mr. Stradivarius
(tweak the _endBox comment and fix a few variables that were accidentally left undefined)
>Mr. Stradivarius
(reorder end box functions)
Line 613: Line 613:


function p._endBox(args, env)
function p._endBox(args, env)
--[[
--[=[
-- This function generates the end box (also known as the link box).
-- This function generates the end box (also known as the link box).
-- @args - a table of arguments passed by the user
-- @args - a table of arguments passed by the user
Line 622: Line 622:
-- 'fmbox-style' --> 'background-color: #ecfcf4'
-- 'fmbox-style' --> 'background-color: #ecfcf4'
-- 'fmbox-textstyle' --> 'font-style: italic'
-- 'fmbox-textstyle' --> 'font-style: italic'
--]]
--  
-- The HTML is generated by the {{fmbox}} template, courtesy of [[Module:Message box]].
--]=]
-- Get environment data.
-- Get environment data.
Line 671: Line 673:
text = text .. (p.makeCategoriesBlurb(args, env) or '')
text = text .. (p.makeCategoriesBlurb(args, env) or '')
end
end
-- Show the "subpages" link.
-- Show the "subpages" link if we are not in the File namespace.
if subjectSpace ~= 6 then -- Don't show the link in file space.
if subjectSpace ~= 6 then
text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '')
text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '')
end
end
Line 684: Line 686:
fmargs.text = text
fmargs.text = text


-- Return the fmbox output.
return messageBox.main('fmbox', fmargs)
return messageBox.main('fmbox', fmargs)
end
function p.makePrintBlurb(args, env)
-- Get the /Print title object
local printTitle = env.printTitle
if not printTitle then
return nil
end
-- Make the print blurb.
local ret
if printTitle.exists then
local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display'))
ret = message('print-blurb', {printLink})
local displayPrintCategory = message('display-print-category', nil, 'boolean')
if displayPrintCategory then
ret = ret .. makeCategoryLink(message('print-category'))
end
end
return ret
end
function p.makeSubpagesBlurb(args, env)
-- Get the template title object
local subjectSpace = env.subjectSpace
local templateTitle = env.templateTitle
if not subjectSpace or not templateTitle then
return nil
end
-- Make the subpages blurb.
local pagetype
if subjectSpace == 10 then
pagetype = message('template-pagetype')
elseif subjectSpace == 828 then
pagetype = message('module-pagetype')
else
pagetype = message('default-pagetype')
end
return makeWikilink(
'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/',
message('subpages-link-display', {pagetype})
)
end
function p.makeCategoriesBlurb(args, env)
-- Get the title object.
local docTitle = env.docTitle
if not docTitle then
return nil
end
-- Make the blurb.
local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display'))
return message('add-categories-blurb', {docPathLink})
end
end


Line 842: Line 791:
end
end
return message(messageName, {sandboxLinks, testcasesLinks})
return message(messageName, {sandboxLinks, testcasesLinks})
end
function p.makeCategoriesBlurb(args, env)
-- Get the title object.
local docTitle = env.docTitle
if not docTitle then
return nil
end
-- Make the blurb.
local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display'))
return message('add-categories-blurb', {docPathLink})
end
function p.makeSubpagesBlurb(args, env)
-- Get the template title object
local subjectSpace = env.subjectSpace
local templateTitle = env.templateTitle
if not subjectSpace or not templateTitle then
return nil
end
-- Make the subpages blurb.
local pagetype
if subjectSpace == 10 then
pagetype = message('template-pagetype')
elseif subjectSpace == 828 then
pagetype = message('module-pagetype')
else
pagetype = message('default-pagetype')
end
return makeWikilink(
'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/',
message('subpages-link-display', {pagetype})
)
end
function p.makePrintBlurb(args, env)
-- Get the /Print title object
local printTitle = env.printTitle
if not printTitle then
return nil
end
-- Make the print blurb.
local ret
if printTitle.exists then
local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display'))
ret = message('print-blurb', {printLink})
local displayPrintCategory = message('display-print-category', nil, 'boolean')
if displayPrintCategory then
ret = ret .. makeCategoryLink(message('print-category'))
end
end
return ret
end
end


Anonymous user

Navigation menu