Module:Check for unknown parameters
- Адыгабзэ
- Afrikaans
- ak:Module:Check for unknown parameters
- Алтай тил
- አማርኛ
- Anarâškielâ
- अंगिका
- Ænglisc
- Аԥсшәа
- العربية
- Արեւմտահայերէն
- অসমীয়া
- Asturianu
- Avañe'ẽ
- Aymar aru
- Azərbaycanca
- تۆرکجه
- Basa Bali
- বাংলা
- 閩南語 / Bân-lâm-gí
- Basa Banyumasan
- Башҡортса
- Беларуская
- Беларуская (тарашкевіца)
- भोजपुरी
- Bikol Central
- Български
- བོད་ཡིག
- Bosanski
- Brezhoneg
- Буряад
- Català
- Cebuano
- Čeština
- Chamoru
- Chavacano de Zamboanga
- ChiTumbuka
- Corsu
- Cymraeg
- Dansk
- الدارجة
- डोटेली
- Eesti
- Ελληνικά
- Español
- Euskara
- فارسی
- Føroyskt
- Français
- Gàidhlig
- Galego
- ГӀалгӀай
- Gĩkũyũ
- گیلکی
- ગુજરાતી
- गोंयची कोंकणी / Gõychi Konknni
- 客家語 / Hak-kâ-ngî
- Хальмг
- 한국어
- Hawaiʻi
- Հայերեն
- हिन्दी
- Hrvatski
- Bahasa Hulontalo
- Ilokano
- বিষ্ণুপ্রিয়া মণিপুরী
- Bahasa Indonesia
- Ирон
- IsiZulu
- Íslenska
- Italiano
- עברית
- Jawa
- ಕನ್ನಡ
- Kapampangan
- ქართული
- Қазақша
- Ikinyarwanda
- Ikirundi
- Kongo
- Kurdî
- Кыргызча
- Ladin
- Лакку
- ລາວ
- Latina
- Latviešu
- Lëtzebuergesch
- Лезги
- Lietuvių
- Ligure
- Lingua Franca Nova
- La .lojban.
- Lombard
- Magyar
- Madhurâ
- मैथिली
- Македонски
- Malagasy
- മലയാളം
- Malti
- Māori
- मराठी
- მარგალური
- مصرى
- ဘာသာမန်
- مازِرونی
- Bahasa Melayu
- ꯃꯤꯇꯩ ꯂꯣꯟ
- Mfantse
- 閩東語 / Mìng-dĕ̤ng-ngṳ̄
- Mirandés
- Мокшень
- Монгол
- မြန်မာဘာသာ
- Na Vosa Vakaviti
- Nederlands
- Nedersaksies
- नेपाली
- 日本語
- Napulitano
- ߒߞߏ
- Нохчийн
- Norsk bokmål
- Norsk nynorsk
- Occitan
- Олык марий
- ଓଡ଼ିଆ
- Oʻzbekcha / ўзбекча
- ਪੰਜਾਬੀ
- पालि
- Pangasinan
- Pangcah
- ပအိုဝ်ႏဘာႏသာႏ
- Papiamentu
- پښتو
- Перем коми
- ភាសាខ្មែរ
- Pinayuanan
- Português
- Qaraqalpaqsha
- Qırımtatarca
- Română
- Русиньскый
- Русский
- Sakizaya
- Gagana Samoa
- संस्कृतम्
- ᱥᱟᱱᱛᱟᱲᱤ
- Sardu
- Scots
- Seediq
- Setswana
- Shqip
- සිංහල
- Simple English
- سنڌي
- Slovenščina
- Словѣньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ
- کوردی
- Српски / srpski
- Srpskohrvatski / српскохрватски
- Suomi
- Tagalog
- தமிழ்
- Taclḥit
- Taqbaylit
- Татарча / tatarça
- တႆး
- Tayal
- తెలుగు
- Tetun
- ไทย
- Thuɔŋjäŋ
- ትግርኛ
- Тоҷикӣ
- ᏣᎳᎩ
- ತುಳು
- Türkçe
- Удмурт
- Basa Ugi
- Українська
- اردو
- Vahcuengh
- Vèneto
- Tiếng Việt
- Volapük
- 文言
- Winaray
- 吴语
- Xitsonga
- 粵語
- 中文
- Batak Mandailing
- Kumoring
- Руски
- ᥖᥭᥰ ᥖᥬᥲ ᥑᥨᥒᥰ
- ⵜⴰⵎⴰⵣⵉⵖⵜ ⵜⴰⵏⴰⵡⴰⵢⵜ
Appearance
From Wikipedia, the free encyclopedia
[画像:Warning] This Lua module is used in system messages, and on approximately 22,600,000 pages, or roughly 35% of all pages.
Changes to it can cause immediate changes to the Wikipedia user interface.
To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them.
Changes to it can cause immediate changes to the Wikipedia user interface.
To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them.
This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
Page protected This module is currently protected from editing.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
This module can only be edited by administrators because it is transcluded onto one or more cascade-protected pages.
This module depends on the following other modules:
Module:Check for unknown parameters is used to check for uses of unknown parameters in a template or module. It may be appended to a template at the end or called directly from a module.
Usage
From a template
To sort entries into a tracking category by parameter, use:
{{#invoke:Check for unknown parameters|check|unknown=[[Category:Some tracking category|_VALUE_]]|arg1|arg2|arg3|argN}}
To sort the entries into a tracking category by parameter with a preview error message, use:
{{#invoke:Check for unknown parameters|check|unknown=[[Category:Some tracking category|_VALUE_]]|preview=unknown parameter "_VALUE_"|arg1|arg2|...|argN}}
For an explicit red error message, use:
{{#invoke:Check for unknown parameters|check|unknown=<span class="error">Sorry, I don't recognize _VALUE_</span>|arg1|arg2|...|argN}}
To use Lua patterns, use:
{{#invoke:Check for unknown parameters|check|unknown=[[Category:Some tracking category|_VALUE_]]|preview=unknown parameter "_VALUE_"|arg1|arg2|...|argN|regexp1=header[%d]+|regexp2=date[1-9]}}
From a module
To call from a module, use:
localcheckForUnknownParameters=require("Module:Check for unknown parameters") localresult=checkForUnknownParameters._check(validArgs,args)
Where the first set of args are the module args below and the second set of args are the parameters that are checked.
Parameters
arg1
,arg2
, ...,argN
, are the known parameters.- Unnamed (positional) parameters can be added too:
|1|2|arg1|arg2|...
. - Lua patterns (similar to regular expressions) usage with parameters is also supported (such as:
|regexp1=header[%d]+
,|regexp2=date[1-9]
,|regexp3=data[%d]+[abc]?
). This is useful when there are many known parameters which use a systematic pattern. |unknown=
– what happens when an unknown parameter is used. Typically use either a tracking category to place pages that use unknown parameters, or an error.|preview=
– the text to be displayed when in preview mode and an unknown parameter is used.- The
_VALUE_
keyword, if used, will be changed to the name of the parameter. This is useful for either sorting the entries in a tracking category, or for provide more explicit information. |ignoreblank=1
– by default, the module makes no distinction between a defined-but-blank parameter and a non-blank parameter. That is, both unlisted|foo=x
and|foo=
are reported. To only track non-blank parameters use|ignoreblank=1
. If you clean your arguments with Module:Arguments and call this module afterwards, you need not use this parameter as that module ignores blank arguments by default.|showblankpositional=1
– by default, the module ignores blank positional parameters. That is, an unlisted|2=
is ignored. To include blank positional parameters in the tracking use|showblankpositional=1
.|mapframe_args=
– When this is set to a non-null value, the various Module:Infobox mapframe parameters will be automatically included in the list of valid parameters. This eliminates the need to manually add all 20+ params. NOTE this should only be used when{{#invoke:Infobox mapframe|auto}}
and{{#invoke:Infobox mapframe|autocaption}}
are in the template calling Check for unknown. Do NOT use if using {{Infobox mapframe }} as not all parameters are included when calling the template.
Example
{{Infobox | above = {{{name|}}} | label1 = Height | data1 = {{{height|}}} | label2 = Weight | data2 = {{{weight|}}} | label3 = Website | data3 = {{{website|}}} }}<!-- end infobox, start tracking -->{{#invoke:Check for unknown parameters|check | unknown = {{Main other|[[Category:Some tracking category|_VALUE_]]}} | preview = unknown parameter "_VALUE_" | height | name | website | weight }}
Call from within Lua code
See the end of Module:Rugby box for a simple example or Module:Infobox3cols or Module:Flag for more complicated examples.
See also
- Category:Unknown parameters (304) (category page can have header {{Unknown parameters category }})
- Module:Params – for complex operations involving parameters
- Template:Checks for unknown parameters – adds documentation to templates using this module
- Module:Check for deprecated parameters – similar module that checks for deprecated parameters
- Module:Check for clobbered parameters – module that checks for conflicting parameters
- Module:TemplatePar – similar function (originally from dewiki)
- Template:Parameters and Module:Parameters – generates a list of parameter names for a given template
- Project:TemplateData based template parameter validation
- Module:Parameter validation checks a lot more
- User:Bamyers99/TemplateParametersTool - A tool for checking usage of template parameters
The above documentation is transcluded from Module:Check for unknown parameters/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (edit | run) pages.
Subpages of this module.
Editors can experiment in this module's sandbox (edit | diff) and testcases (edit | run) pages.
Subpages of this module.
-- 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 -- not on the list require('strict'); localp={} localmapframe_params={ 'mapframe', 'mapframe-area_km2', 'mapframe-area_mi2', 'mapframe-caption', 'mapframe-coord', 'mapframe-coordinates', 'mapframe-custom', 'mapframe-frame-coord', 'mapframe-frame-coordinates', 'mapframe-frame-height', 'mapframe-frame-width', 'mapframe-geomask', 'mapframe-geomask-fill', 'mapframe-geomask-fill-opacity', 'mapframe-geomask-stroke-color', 'mapframe-geomask-stroke-colour', 'mapframe-geomask-stroke-width', 'mapframe-height', 'mapframe-id', 'mapframe-length_km', 'mapframe-length_mi', 'mapframe-marker', 'mapframe-marker-color', 'mapframe-marker-colour', 'mapframe-point', 'mapframe-population', 'mapframe-shape', 'mapframe-shape-fill', 'mapframe-shape-fill-opacity', 'mapframe-stroke-color', 'mapframe-stroke-colour', 'mapframe-stroke-width', 'mapframe-switcher', 'mapframe-type', 'mapframe-width', 'mapframe-wikidata', 'mapframe-zoom' } localfunctiontrim(s) returns:match('^%s*(.-)%s*$') end localfunctionisnotempty(s) returnsands:match('%S') end localfunctionclean(text) -- Return text cleaned for display and truncated if too long. -- Strip markers are replaced with dummy text representing the original wikitext. localpos,truncated localfunctiontruncate(text) iftruncatedthen return'' end ifmw.ustring.len(text)>25then truncated=true text=mw.ustring.sub(text,1,25)..'...' end returnmw.text.nowiki(text) end localparts={} forbefore,tag,remainderintext:gmatch('([^127円]*)127円[^127円]*%-(%l+)%-[^127円]*127円()')do pos=remainder table.insert(parts,truncate(before)..'<'..tag..'>...</'..tag..'>') end table.insert(parts,truncate(text:sub(posor1))) returntable.concat(parts) end functionp._check(args,pargs) iftype(args)~="table"ortype(pargs)~="table"then -- TODO: error handling return end -- create the list of known args, regular expressions, and the return string localknownargs={} ifisnotempty(args['mapframe_args'])then for_,vinipairs(mapframe_params)do knownargs[v]=1 end end localregexps={} fork,vinpairs(args)do iftype(k)=='number'then v=trim(v) knownargs[v]=1 elseifk:find('^regexp[1-9][0-9]*$')then table.insert(regexps,'^'..v..'$') end end -- loop over the parent args, and make sure they are on the list localignoreblank=isnotempty(args['ignoreblank']) localshowblankpos=isnotempty(args['showblankpositional']) localvalues={} fork,vinpairs(pargs)do iftype(k)=='string'andknownargs[k]==nilthen localknownflag=false for_,regexpinipairs(regexps)do ifmw.ustring.match(k,regexp)then knownflag=true break end end ifnotknownflagand(notignoreblankorisnotempty(v))then table.insert(values,clean(k)) end elseiftype(k)=='number'andknownargs[tostring(k)]==nilthen localknownflag=false for_,regexpinipairs(regexps)do ifmw.ustring.match(tostring(k),regexp)then knownflag=true break end end ifnotknownflagand(showblankposorisnotempty(v))then table.insert(values,k..' = '..clean(v)) end end end -- add results to the output tables localres={} if#values>0then localunknown_text=args['unknown']or'Found _VALUE_, ' ifmw.getCurrentFrame():preprocess("{{REVISIONID}}")==""then localpreview_text=args['preview'] ifisnotempty(preview_text)then preview_text=require('Module:If preview')._warning({preview_text}) elseifpreview_text==nilthen preview_text=unknown_text end unknown_text=preview_text end for_,vinpairs(values)do -- Fix odd bug for | = which gets stripped to the empty string and -- breaks category links ifv==''thenv=' 'end -- avoid error with v = 'example%2' ("invalid capture index") localr=unknown_text:gsub('_VALUE_',{_VALUE_=v}) table.insert(res,r) end end returntable.concat(res) end functionp.check(frame) localargs=frame.args localpargs=frame:getParent().args returnp._check(args,pargs) end returnp