Jump to content

Module:Road data/extra/doc/table

From Wikipedia, the free encyclopedia
local p = {}
local extra = require('Module:Road data/extra')
local TableTools = require('Module:TableTools')

function defaultFirst(a, b)
	if a == 'default' then return true end
	if b == 'default' then return false end
	return a < b
end

function p.table(frame)
	local out = ''
	
	for signType, signDef in TableTools.sortedPairs(extra) do
		out = out .. '{| class="wikitable" style="display:inline-table;"\n'
		out = out .. '|+ '  .. signType .. '\n'
		out = out .. '|-\n'
		out = out .. '! Region\n'
		out = out .. '! Sign\n'
		
		for countryType, countryDef in TableTools.sortedPairs(signDef, defaultFirst) do
			if type(countryDef) == 'table' then
				for stateType, stateDef in TableTools.sortedPairs(countryDef, defaultFirst) do
					out = out .. '|-\n'
					out = out .. '|' .. countryType .. '/' .. stateType .. '\n'
					out = out .. '|[[File:' .. stateDef .. '|24px]]\n'
				end
			else
				out = out .. '|-\n'
				out = out .. '|' .. countryType .. '\n'
				out = out .. '|[[File:' .. countryDef .. '|24px]]\n'
			end
		end
		
		out = out .. '|}\n'
	end
	
	return out
end

return p