local modules = {
flavor = require("Module:API_info/flavor"),
elink = require("Module:API_info/elink"),
patch = require("Module:API_info/patch"),
metrics = require("Module:API_info/metrics"),
multi = require("Module:API_info/multi"),
flavorbox = require("Module:API_info/flavor_ambox"),
infobox = require("Module:API_info/util/infobox"),
}
local m = {}
local comparison = {
a = "Global_functions/Classic",
e = "Events/Classic",
}
local function GetDefaultInfobox(args, name)
local added, removed = modules.patch:GetPatches(args.t, name)
if #added > 0 then -- check if we have data on this since {{wowapi}} doesnt guarantee its an API
local t = {}
local flavors = modules.flavor:GetFlavors(args.t, name)
if flavors then
table.insert(t, string.format("! Game [[%s|Flavors]]", comparison[args.t]))
table.insert(t, flavors)
end
local elinks = modules.elink:GetElinks(args.t, name)
if #elinks > 0 then
table.insert(t, "! Links")
table.insert(t, elinks)
end
table.insert(t, "! Info")
table.insert(t, "| Added in "..added)
if #removed > 0 then
table.insert(t, "| Removed in "..removed)
end
local metrics = modules.metrics:main(args.t, name)
if metrics then
table.insert(t, "| "..modules.metrics:GetScoreString(metrics, true))
end
return t
end
end
local function GetInfobox(f, name)
local infobox
if modules.multi.data[name] then
infobox = modules.multi:main(f.args, name, modules.multi.data[name])
else
local defaultInfobox = GetDefaultInfobox(f.args, name)
if defaultInfobox then
infobox = modules.infobox:main(defaultInfobox)
end
end
return infobox
end
function m.main(f)
local PAGENAME = f.args[1]
local name = PAGENAME:gsub("API ", ""):gsub(" ", "_")
local text = ""
local flavorbox = modules.flavorbox:GetAmbox(f, name)
if flavorbox then
text = text..flavorbox
end
local infobox = GetInfobox(f, name)
if infobox then
text = text..infobox
end
return text
end
return m