Module:Maintenance

local p = {}

local Franchise = require("Module:Franchise") local utilsArg = require("Module:UtilsArg") local utilsMarkup = require("Module:UtilsMarkup") local utilsPage = require("Module:UtilsPage") local utilsTable = require("Module:UtilsTable")

function p.Categories(frame) local templateName = frame:getTitle local templateType, category, subcategoryFormat = frame.args[1], frame.args[2], frame.args[3] local templateSpec = p.Templates[templateName] if templateType then templateSpec = p.Templates[templateType] else error("Template type required") end if not templateSpec then error(string.format("No template spec found for template name  or template type  ", templateName, templateType)) end local args, err = utilsArg.parse(frame:getParent.args, templateSpec) local games = utilsTable.concat(args.games or {}, args._games or {}) local result = p.printCategories(category, subcategoryFormat, games) if err then result = result..utilsMarkup.categories(err.categories) end return result end

function p.printCategories(category, subcategoryFormat, games) if utilsPage.inNamespace("User") then return "" end local categories = ""..category.."" if subcategoryFormat and games then for i, game in ipairs(games) do			local gameName = Franchise.shortName(game) if gameName then categories = categories..""..string.format(subcategoryFormat, gameName).."" end end end return categories end p.Templates = { ["Inline"] = { usage = "To use this template, insert the following immediately after punctuation, as if adding a reference.", params = { [1] = {				name = "games", type = "string", enum = Franchise.enum, split = true, trim = true, nilIfEmpty = true, desc = "A comma-separated list of game codes indicating which game(s) the statement pertains to." },			reason = { name = "reason", type = "string", desc = "An explanation of what is unclear or vague about the statement. This will appear in the template's tooltip.", },			["..."] = {				name = "_games", deprecated = true, },		},	},	["Clarify"] = { usage = "To use this template, insert the following immediately after punctuation, as if adding a reference.", params = { [1] = {				name = "games", type = "string", enum = Franchise.enum, split = true, trim = true, nilIfEmpty = true, desc = "A comma-separated list of game codes indicating which game(s) the statement pertains to." },			reason = { name = "reason", type = "string", desc = "An explanation of what is unclear or vague about the statement. This will appear in the template's tooltip.", },			["..."] = {				name = "_games", deprecated = true, placeholder = " ", },		},	}, }

return p