Module:Jcon/documentation explained

require('strict')

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

-- Generates a list of supported regionsfunction p.supported(frame) local reverseAliases = local entries = local pre = 'Note: All inputs are converted to lowercase by the template and "Region of", "County Road", etc. are striped from the input.' local post = 'Table produced by with data from (' .. frame:expandTemplate .. ').' 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, fileName 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('') end

return pre .. tostring(tableEl) .. postend

return p