Module:Jcon/documentation

require('strict')

local p = {} local data = mw.loadData('Module:Jcon/data')

-- Generates a list of supported regions function p.supported(frame) local reverseAliases = {} local entries = {} local tableEl = mw.html.create('table'):addClass('wikitable') -- Create output table element local headerRow = tableEl:tag('tr') headerRow:tag('th'):wikitext('Name') headerRow:tag('th'):wikitext('Aliases') headerRow:tag('th'):wikitext('Prefix')

for alias, name in pairs(data.aliases) do -- Reverse the alias table to allow lookup by name if not reverseAliases[name] then reverseAliases[name] = {} end table.insert(reverseAliases[name], alias) end

for name, info in pairs(data.types) do -- Create tables for each region local aliases = '' if reverseAliases[name] then for _, alias in ipairs(reverseAliases[name]) do aliases = aliases .. '\n* ' .. alias -- Add alias to list item end end local row = tableEl:tag('tr') row:tag('td'):wikitext(name) row:tag('td'):wikitext(aliases) row:tag('td'):wikitext(info.prefix .. ' ' .. info.type) end for sign, wikitext in pairs(data.signs) do		local aliases = '' if reverseAliases[sign] then for _, alias in ipairs(reverseAliases[sign]) do aliases = aliases .. '\n* ' .. alias -- Add alias to list item end end local row = tableEl:tag('tr') row:tag('td'):wikitext(sign) row:tag('td'):wikitext(aliases) row:tag('td'):wikitext(wikitext) end

return tostring(tableEl) end

return p