Module:Arguments

local arguments

function arguments.preprocess( frame, args ) -- TODO: Complete error messages, make sure that in the preprocessed version, the keys for numbered args are still numbered local parent = frame:getParent local valid = {} local required = {} local recommended = {} local deprecated = {} for i, v in ipairs( args.valid or {} ) do		local vl = mw.ustring.lower( tostring( v ) ) valid[ vl ] = true end for i, v in ipairs( args.required or {} ) do		local vl = mw.ustring.lower( tostring( v ) ) valid[ vl ] = true required[ vl ] = true end for i, v in ipairs( args.recommended or {} ) do		local vl = mw.ustring.lower( tostring( v ) ) valid[ vl ] = true recommended[ vl ] = true end for i, v in ipairs( args.deprecated or {} ) do		local vl = mw.ustring.lower( tostring( v ) ) valid[ vl ] = true deprecated[ vl ] = true end local preprocessed = {} local missingRequired = required local missingRecommended = recommended local usingDeprecated = {} local usingInvalid = {} local clobbered = {} for k, v in pairs( parent.args ) do		local kl = mw.ustring.lower( k ) kl = args.aliases[ kl ] or kl		missingRequired[ kl ] = nil missingRecommended[ kl ] = nil if not valid[ kl ] then usingInvalid[ kl ] = true end if deprecated[ kl ] then usingDeprecated[ kl ] = true end preprocessed[ kl ] = v	end for i, v in ipairs( parent.args ) do		local k = args.aliases[ i ] or i		missingRequired[ k ] = nil missingRecommended[ k ] = nil if not valid[ k ] then usingInvalid[ k ] = true end if deprecated[ k ] then usingDeprecated[ k ] = true end preprocessed[ k ] = v	end local foundError = false local out = '' if next( missingRequired ) then local missing = '' for k, v in pairs( missingRequired ) do missing = missing .. ', "' .. k .. '"' end missing = mw.ustring.sub( missing, 3 ) out = out .. utils.error(			'Template missing required fields: ' .. missing,			'template',			'Pages containing missing template parameter errors') end if next( missingRecommended ) then local missing = '' for k, v in pairs( missingRecommended ) do missing = missing .. ', "' .. k .. '"' end missing = mw.ustring.sub( missing, 3 ) out = out .. utils.warning(			'Template missing required fields: ' .. missing,			'template',			'Pages containing missing template parameter warnings') end end

return arguments