Module:tree chart

Hello, you have come here looking for the meaning of the word Module:tree chart. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:tree chart, but we will also tell you about its etymology, its characteristics and you will know how to say Module:tree chart in singular and plural. Everything you need to know about the word Module:tree chart you have here. The definition of the word Module:tree chart will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:tree chart, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

Usage

Implements Template:tree chart; Full documentation on chart syntax exists at Template:tree chart/documentation

This module uses the mw.html library to create rows of table cells whose borders draw lines to show relationships between elements. When an unnamed parameter matches a key in Module:tree chart/data, the module will create a block with stylings as defined in the table. Each key in the table has a subtable with 0, 1, or 2 keys of its own: t for the "top" row and b for the "bottom row". Any unnamed parameter whose value does not exist in the table will be used to create elements on the chart, and additional named parameters for that value will be looked for.


--[[
	This code was copied from \\]
	on 2023-01-01. Please see that page for further information
	and its edit history.
	
	This module helps support \\].
]]

require('strict')

local p = {}

local cells = mw.loadData('Module:tree chart/data')

function p._main(cell_args)
	local ret = mw.html.create()
	local top = ret:tag('tr')
						:css{ height = '1px',
								 = 'center' }
	local bottom = ret:tag('tr')
						:css{ height = '1px',
								 = 'center' }
	for _, v in ipairs(cell_args) do
		if type(v) == 'string' then
			top:wikitext(cells.t)
			bottom:wikitext(cells.b)
		else
			top:tag('td')
				:attr{ colspan = v.colspan or cell_args.colspan or 6,
						rowspan = v.rowspan or cell_args.rowspan or 2 }
				:css{ padding = '0.2em',
						border = (v.border or cell_args.border or '2') .. 'px solid black' }
				:cssText(v.boxstyle or cell_args.boxstyle)
				:wikitext(v.text)
		end
	end
	return tostring(ret)
end

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:tree chart', trim = false, removeBlanks = false})
	local cell_args = {
		colspan = args.colspan,
		rowspan = args.rowspan,
		border = args.border,
		boxstyle = args.boxstyle
	}
	for _, val in ipairs(args) do
		local trimmedVal = val:match('^%s*(.-)%s*$')
		if trimmedVal == '' then
			trimmedVal = '$'
		end
		if cells then
			table.insert(cell_args, trimmedVal)
		else
			-- Unnamed params behave weirdly
			-- white space at the front counts for param_{{{1}}}, but not whitespace at the end, so remove it
			local rightTrimmedVal = val:gsub('%s+$','')
			table.insert(cell_args, {
				text = args or ('{{{'..trimmedVal..'}}}'),
				colspan = args,
				rowspan = args,
				border = args,
				boxstyle = args
			})
		end
	end
	
	return p._main(cell_args)
end

return p