Difference between revisions 51831 and 51832 on wikimaniawiki

-- This module implements {{documentation}}.

-- Get required modules.
local getArgs = require('Module:Arguments').getArgs
local htmlBuilder = require('Module:HtmlBuilder')
local messageBox = require('Module:Message box')

-- Get the config table.
(contracted; show full)	--[[
	-- This function generates the end box (also known as the link box).
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'fmbox-id' --> 'documentation-meta-data'
	-- 
'fmbox-style' --> 'background-color: #ecfcf4'
	-- 'fmbox-textstyle' --> 'font-style: italic'
	--]]
	
	-- Get environment data.
	local subjectSpace = env.subjectSpace
	local docTitle = env.docTitle
	if not subjectSpace or not docTitle then
		return nil
	end
		
	-- Check whether we should output the end box at all. Add the end
	-- box by default if the documentation exists or if we are in the
	-- user, module or template namespaces.
	local linkBox = args['link box']
	if linkBox == 'off'
		or not (
			docTitle.exists
			or subjectSpace == 2
			or subjectSpace == 828
			or subjectSpace == 10
		)
	then
		return nil
	end

	-- Assemble the arguments for {{fmbox}}.
	local fmargs = {}
	fmargs.id = message('fmbox-id') -- Sets 'documentation-meta-data'
	fmargs.image = 'none'
	fmargs.style = message('fmbox-style') -- Sets 'background-color: #ecfcf4'
	fmargs.textstyle = message('fmbox-textstyle') -- 'font-style: italic;'

	-- Assemble the fmbox text field.
	local text = ''
	if linkBox then
		-- Use custom link box content if it is defined.
		text = text .. linkBox
	else
		text = text .. (p.makeDocPageBlurb(args, env) or '')
		-- Add links to /sandbox and /testcases when appropriate.
		if subjectSpace == 2 or subjectSpace == 828 or subjectSpace == 10 then
			-- We are in the user, module or template namespaces. 
			text = text .. p.makeEndBoxExperimentBlurb(args, env)
			text = text .. '<br />'
			-- Show the categories text, but not if "content" fed or "docname fed"
			--we have the content on the template page itself,
			-- or if the documentation page has been specified explicitly, since then it is unclear
			-- where to add the categories.
			if not args.content and not docnameFedargs[1] then
				text = text .. (p.makeCategoriesBlurb(args, env) or '')
			end
			-- Show the "subpages" link.
			if subjectSpace ~= 6 then -- Don't show the link in file space.
				text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '')
			end
			-- Show the "print" link if it exists.
(contracted; show full)	if message('display-strange-usage-category', nil, 'boolean') and (subpage == message('doc-subpage') or subpage == message('testcases-subpage')) then
		local sort = (title.namespace == 0 and message('strange-usage-category-mainspace-sort') or '') .. title.prefixedText -- Sort on namespace.
		ret = ret .. makeCategoryLink(message('strange-usage-category'), sort)
	end
	return ret
end

return p