Module:Transclusion Arguments

local p = {}

local utilsArg = require("Module:UtilsArg") local utilsCargo = require("Module:UtilsCargo")

local TABLE = "TransclusionArguments" local TABLE_LINK = "Special:CargoTables/"..TABLE..""

function p.query(args) local isValid = args.isValid if isValid ~= nil then isValid = isValid and "1" or "0" end local rows = utilsCargo.query(TABLE, "_pageName, template, module, pageInstance, parameter, argument, isValid", {		where = utilsCargo.allOf({ template = args.template, module = args.module, pageInstance = args.pageInstance, parameter = args.parameter, argument = args.argument, isValid = isValid }),		limit = args.limit,	}) return rows end

function p.store(transclusion) return utilsArg.store(transclusion) end

p.Templates = { ["Arguments/Store"] = { purpose = "Stores data regarding template/module usage for the benefit of Module:Arguments.", storesData = true, categories = {"Metatemplates"}, paramOrder = {"template", "module", "pageInstance", "parameter", "argument", "isValid"}, params = { template = { desc = "The template being used.", type = "wiki-template-name", },			module = { desc = "The module being used.", type = "wiki-page-name", },			pageInstance = { desc = "Specifies the instance of the template, when a template is used multiple times on a page.", type = "number", },			parameter = { desc = "A parameter name.", type = "string", },			argument = { desc = "The value of the argument corresponding to .", type = "string", },			isValid = { desc = " or   if the argument is valid,   or   if it is not valid.", enum = {"1", "0", "yes", "no"}, },		}	} }

p.Schemas = { store = { transclusion = { type = "record", required = true, properties = { {					name = "module", desc = "A module name. Defaults to .", },				{					name = "args", desc = "Template/module arguments.", type = "map", keys = { oneOf = { {								type = "string" },							{								type = "number" },						},					},					values = { type = "string" }, },				{					name = "isValid", type = "boolean", desc = "Indicates whether or not the template transclusion or module function call is valid.", },			},		},	}, }

p.Documentation = { query = { params = {"args"}, returns = string.format("Data from %s.", TABLE_LINK), cases = { {				desc = "Category:Articles Using Invalid Color Names", args = { {						template = "Template:Color", isValid = false, limit = 3, },				},			},		},	},	store = { desc = string.format("Stores data in %s.", TABLE_LINK), params = {"transclusion"}, returns = nil, cases = { {				args = { {						module = "Module:Arguments", isValid = true, args = { [1] = "foo", bar = "baz", },					},				},			},		},	}, }

return p