Difference between revisions 51873 and 51874 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.
local cfg = mw.loadData('Module:Documentation/config')

local p = {}

-- Often-used functions.
(contracted; show full)	-- @args - table of arguments passed by the user
	-- 
	-- Messages:
	-- 'main-div-id' --> 'template-documentation'
	-- 'main-div-classes' --> 'template-documentation iezoomfix'
	--]]
	local env = p.getEnvironment(args)
	local root = 
mw.htmlBuilder.create()
	root
		.:wikitext(p.protectionTemplate(env))
		.:wikitext(p.sandboxNotice(args, env))
		 -- This div tag is from {{documentation/start box}}, but moving it here
		 -- so that we don't have to worry about unclosed tags.
		.:tag('div')
			.:attr('id', message('main-div-id'))
			.:addClass(message('main-div-classes'))
			.:newline()
			.:wikitext(p._startBox(args, env))
			.:wikitext(p._content(args, env))
			.:tag('div')
				.:css('clear', 'both') -- So right or left floating items don't stick out of the doc box.
				.:newline()
				.:done()
			.:done()
		.:wikitext(p._endBox(args, env))
		.:wikitext(p.addTrackingCategories(env))
	return tostring(root)
end

----------------------------------------------------------------------------
-- Environment settings
----------------------------------------------------------------------------

(contracted; show full)	
	return data
end

function p.renderStartBox(data)
	-- Renders the start box html.
	-- @data - a table of data generated by p.makeStartBoxData.
	local sbox = 
mw.htmlBuilder.create('div')
	sbox
		.:css('padding-bottom', '3px')
		.:css('border-bottom', '1px solid #aaa')
		.:css('margin-bottom', '1ex')
		.:newline()
		.:tag('span')
			.:cssText(data.headingStyleText)
			.:css('font-weight', data.headingFontWeight)
			.:css('font-size', data.headingFontSize)
			.:wikitext(data.heading)
	local links = data.links
	if links then
		sbox.:tag('span')
			.:addClass(data.linksClass)
			.:attr('id', data.linksId)
			.:wikitext(links)
	end
	return tostring(sbox)
end

----------------------------------------------------------------------------
-- Documentation content
----------------------------------------------------------------------------
(contracted; show full)		)
	then
		ret = ret .. makeCategoryLink(message('strange-usage-category'))
	end
	return ret
end

return p