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 = mw.title.new(frame:getParent:getTitle).text local templateType, category, subcategoryFormat, communityCategory = frame.args[1], frame.args[2], frame.args[3], frame.args[4] local templateSpec = p.Templates[templateName] if not templateSpec and templateType then templateSpec = p.Templates[templateType] end if not templateSpec then error(string.format("No template spec found for template name '%s' or template type '%s'", 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, communityCategory, games) if err then result = result..utilsMarkup.categories(err.categories) end return result end

function p.printCategories(category, subcategoryFormat, communityCategory, games) if utilsPage.inNamespace("User") then return "" end local categories = ""..category.."" if utilsPage.inNamespace("Community") then communityCategory = communityCategory or string.format(subcategoryFormat, "Community") categories = categories..""..communityCategory.."" return categories end 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 = { ["Block"] = { 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 article or section pertains to." },			["..."] = {				name = "_games", deprecated = true, placeholder = "game", },		},		examples = { {"OoS, OoA"}, {},		},	},	["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." },			["..."] = {				name = "_games", deprecated = true, placeholder = "game", },		},		examples = { {"OoS, OoA"}, {},		},	},	["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 = { type = "string", desc = "An explanation of what is unclear or vague about the statement. This will appear in the template's tooltip.", },		},	},	["Images"] = { 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 article or section pertains to." },			reason = { type = "string", desc = "An explanation of what images are needed.", },			["..."] = {				name = "_games", deprecated = true, placeholder = "game", },		},		examples = { {"OoS, OoA"}, {"TWWHD", reason = "Missing images of the second floor"}, {},		},	},	["Verify"] = { 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." },		},	}, }

return p