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", "Zelda_Wiki", "Help", "Guidelines"}) 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." },		},		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." },		},		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.", },		},		examples = { {"OoS, OoA"}, {"TWWHD", reason = "Missing images of the second floor"}, {},		},	},	["Improve"] = { params = { [1] = {				name = "date", type = "string", desc = "The date the template was placed on the article. The month and year will do (e.g. December 2013).", },			[2] = {				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." },		},		examples = { {"December 2013", "OoS, OoA"}, {},		},	},	["Incomplete"] = { paramOrder = {"type", "reason", "subcat", "subcat2", "games"}, params = { type = { type = "string", desc = "The type of incomplete content. Ex: listing, section.", default = "article", },			reason = { type = "content", desc = "Reason why this article is incomplete. Brief and specific.", },			subcat = { type = "string", desc = "For adding the article to a different sub-category, if needed. (Supersedes )", enum = {"listing", "nomenclature"}, },			subcat2 = { type = "string", desc = "For adding an additional sub-category.", enum = {"listing", "nomenclature"}, },			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." }		},		examples = { {},			{ 				type = "section", reason = "A description of what's missing", games = "TWW, TWWHD", subcat2 = "listing", },		}	},	["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