Documentation for this module may be created at Module:SiteList/doc

local p = {}
local SiteDictionary = require('Module:SiteDictionary')

local function buildRow(siteType, site, id, sceneid, alias, notes)
    local siteInfo = SiteDictionary[site]
    local link

    if sceneid ~= '' then
        link = string.format(siteInfo.sceneFormat, sceneid)
    elseif id ~= '' then
        link = string.format(siteInfo.idFormat, id)
    else
        link = siteInfo.defaultLink
    end

    return string.format('|-\n| %s || [ %s %s] || %s || %s || %s\n', 
        siteType, link, siteInfo.name, alias, sceneid, notes)
end

function p.siteList(frame)
    local args = frame:getParent().args
    local siteType = args[1] or 'N/A'
    local site = args.site or 'N/A'
    local id = args.id or ''
    local sceneid = args.sceneid or ''
    local alias = args.alias or 'N/A'
    local notes = args.notes or 'N/A'
    return buildRow(siteType, site, id, sceneid, alias, notes)
end

return p