Module:Check for deprecated parameters
Vilwelo
Vya masiku ghose
Print/export
Ma project ghanyake
![]() | This module issubject to page protection. It is ahighly visible module in use by a very large number of pages, or issubstituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it isprotected from editing. |
![]() | This Lua module is used onapproximately 60,000 pages and changes may be widely noticed. Test changes in the module's/sandbox or/testcases subpages, or in your ownmodule sandbox. Consider discussing changes on thetalk page before implementing them. |
![]() | This module depends on the following other modules: |
Module:Check for deprecated parameters may be appended to a template to check for uses of deprecated parameters. It will place the page in a specific category, and display a preview message, when it finds deprecated parameter uses.
Note: due to the nature of deprecations, this module will often have no templates implementing it.
{{#invoke:check for deprecated parameters|check|category=[[Category:<category_name>|_VALUE_]]| old_param1 = new_param1 | old_param2 = new_param2| ....| old_paramN = new_paramN}}
-- This module may be used to compare the arguments passed to the parent-- with a list of arguments, returning a specified result if an argument is-- on the listlocalp={}localfunctiontrim(s)returns:match('^%s*(.-)%s*$')endlocalfunctionisnotempty(s)returnsandtrim(s)~=''endfunctionp.check(frame)-- create the table of deprecated values and their matching new valuelocalargs=frame.argslocaldep_values={}fork,vinpairs(args)doifk=='ignoreblank'ork=='preview'ork=='deprecated'thenelsedep_values[k]=vendend-- loop over the parent args and see if any are deprecatedlocalvalues={}localignoreblank=isnotempty(frame.args['ignoreblank'])localpargs=frame:getParent().argsfork,vinpairs(pargs)doifignoreblankthenifdep_values[k]andv~=''thentable.insert(values,k)endelseifdep_values[k]thentable.insert(values,k)endendend-- add results to the output tableslocalres={}if#values>0thenlocalpreview=frame.args['preview']or'Page using [['..frame:getParent():getTitle()..']] with deprecated parameter _VALUE_'ifisnotempty(preview)thenpreview=require('Module:If preview')._warning({preview})end-- Kind of dangerous to trust that this is never nil, but I guess it's-- preferable to display that the use of the module is broken rather than-- have some sort of tracking category for pages which have an unknown-- parent tracking template.localcategory=frame.args['category']fork,vinpairs(values)dolocalc=category:gsub('_VALUE_',v)table.insert(res,c)ifv==''then-- Fix odd bug for | = which gets stripped to the empty string-- and breaks category linksv=' 'endlocalp=preview:gsub('_VALUE_','"'..v..'". Replace with "'..dep_values[v]..'".')table.insert(res,p)endendreturntable.concat(res)endreturnp