Module talk:Check for unknown parameters: Difference between revisions

Content deleted Content added
m Reverted edit by 154.81.225.164 (talk) to last version by Trappist the monk
 
(235 intermediate revisions by 59 users not shown)
Line 1:
{{Permanently protected}}
==Just some ideas==
{{oldtfdfull|date= 2019 December 30 |result=no consensus |disc=Module:Check for deprecated parameters|merge=self}}
Great and useful. Here are some earlier thoughts.
{{talk header}}
{{WikiProject banner shell|
{{WikiProject Templates|module_for_template_maintenance=y}}
}}
{{User:MiszaBot/config
| algo=old(90d)
| archive=Module talk:Check for unknown parameters/Archive %(counter)d
| counter=1
| maxarchivesize=900K
| archiveheader={{aan}}
| minthreadsleft=2
| minthreadstoarchive=1
}}
 
== Protected edit request on 29 August 2024 ==
0. Change name to e.g. [[module:Parameter check]], to cover more wide goals. Definitely do not limit to infoboxes.
 
{{edit fully-protected|Module:Check for unknown parameters|answered=yes}}
The parameter '''whitelist''' could be a [[module:Parameter check/data/Template:Foo]] page for the {{draft:tlno|foo}} template (module data page).
On [[Module:Check_for_unknown_parameters#L-94]], please replace the undefined variable <code>preview</code> with <code>preview_text</code>. That expression is always going to evaluate to true and so will never reach the third expression. [[User:Awesome Aasim|Awesome]] [[User_talk:Awesome Aasim|Aasim]] 17:57, 29 August 2024 (UTC)
With that whitelist, some extra options are possible:
:Done. Also added <syntaxhighlight lang="wikitext" inline="1">require ('strict')</syntaxhighlight> which will catch other globals. Keep an eye on {{cl|Pages with script errors}} to see if the addition reveals other globals.
::1. Unnamed (positional) parameters could be defined white or black
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 18:08, 29 August 2024 (UTC)
::2. Per parameter, an "accept blank input yes/no" switch can be added.
::3. Per parameter, a more special value check could be performed (numeric, pattern, listcheck).
::4. Big-issue parameters (black/white) or special interest parameters could have their own category or their own catsort letter.
::4b. Deprecated parameters can be defined and categorized separate (idea added later).
::5. Category name automated? Parent cat available (using template name, by "parameter check module" name?)
:::Tree suggestion (all are maintenance categories):
:::[[:Category:Template foo maintenance categories]] (could be existing name, any name, host cat for this module outcomes)
:::[[:Category:Parameter check categories]] -- The module's view.
:::::[[:Category:Parameter checks for template foo]] -- dedicated for & created through [[module:Parameter check]]
::::: -- Has the default checks (forced adding of the word "pages" makes the name awkward. Better not use title word "articles", because that is to be an option for the template editor).
::::::[[:Category:Foo template parameter 'country' checks]] -- special checks
::::::[[:Category:Foo template parameter '1=' checks]] --spcial checks
 
== Suggested enhancement ==
6. We could add a ''maintenance tag'' to the pages, demo {{draft:tlno|do something|latincheck=}}:
::<code>Lorem <nowiki>{{do something|latincehck=ipsum}}</nowiki> foo.<code> &rarr; Lorem ipsum<sup><nowiki>[</nowiki>[[template:infobox language|unknown parameter]]<nowiki>]</nowiki></sup> foo. Currently in {{tl|convert}}: {{convert|12|km|xyz}}.
 
{{see also|Module_talk:WikiProject banner}}
7. Note: As always, categorising a wikilabel works out bad. Say the template is used in the {do something} template, which is used like this:
We are using this module on [[Module:WikiProject banner]]. We first check if [[:Category:Pages using WikiProject PROJECT with unknown parameters]] exists and if not, then we use [[:Category:WikiProject templates with unknown parameters]] instead. The problem is that this is causing thousands of links to non-existent categories to be recorded, which can be seen in [[Special:WantedPages]]. My suggestion is as follows. The module can accept an additional argument called <code>fallback</code> which is a category which will be used if the one specified in <code>unknown</code> does not exist. In this way we can check existence of that category only when unknown parameters are discovered, not in every single case. &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 14:19, 4 September 2024 (UTC)
::<code><nowiki>[[Mercury (element)|{{do something|Mercury}}]]</nowiki><code>. When the category name is expanded into the page including a category name, it ''shows'' like this in the article: <code><nowiki>[[Mercury (element)Mercury blabla foobar]]</nowiki><code>. The template could have a "{{para|parametercheck this instance|no}} option (the offended page must be edited for this).
:What is it that I'm missing? If the problem is caused by something that happens in [[Module:WikiProject banner]], that is where the fix should be applied. Adding miscellaneous one-off patches to this module is not a good idea. When you switch to the default category, you know that the preferred category does not exist so why link to it? Link to the preferred category only when it exists.
 
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 15:35, 4 September 2024 (UTC)
8. Options for (easy) ns differentiation please.
::I'll try and explain better. Or you can look at the code at around [[Module:WikiProject banner#L-831]]. We have to check existence before calling this module. Checking existence adds a link to the page. Therefore every transclusion of {{tl|WikiProject Lepidoptera}} is generating a link to [[:Category:Pages using WikiProject Lepidoptera with unknown parameters]] which is not so good. I would prefer to only check if the category exists if there are some unknown parameters. That check can only happen in this module. Or perhaps you have a better idea &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 21:02, 4 September 2024 (UTC)
 
:::I haven't taken any real time to study the code (it has taken me more time to write this than I spent looking at the code) but [[Module:Check_for_unknown_parameters#L-113|Module:Check for unknown parameters line 113]] appears to return a concatenated string of unknown parameters (apparently without delimiters). If there are no unknowns then the <syntaxhighlight lang="lua" inline="1">table.concat(res)</syntaxhighlight> returns an empty string. So, it looks like <syntaxhighlight lang="lua" inline="1">p._check(args, pargs)</syntaxhighlight> returns:
9. Catsort could be <code><nowiki>[[Category: ... |__VALUE__, {{PAGENAME}}]]</nowiki></code>
::::<code>nil</code> when either of <code>args</code> and <code>pargs</code> is not a table
-[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 08:04, 25 March 2014 (UTC)
::::<code>''empty string''</code> when there are no unknown parameters
 
::::some sort of list of unknown parameters
:I like the idea of loading the required parameters from a module data page, rather than using frame args and parent frame args. This option will be much better performance-wise, especially for templates that are called many times on one page. (This is assuming we are loading the data with [[mw:Extension:Scribunto/Lua reference manual#mw.loadData|mw.loadData]].) — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 08:53, 25 March 2014 (UTC)
:::If this is true then you should be checking the returned value from <syntaxhighlight lang="lua" inline="1">require('Module:Check for unknown parameters')._check(parameters, parent_args)</syntaxhighlight> before you fiddle about with categories.
::Agree. Even more: it allows for unlimited parameter sub-specifications. Each whitelist parameter can have its own check-properties, like "is deprecated", to be used. Also, an "is blacklisted=yes" property can be added for notorious bad parameters).
:::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 22:22, 4 September 2024 (UTC)
::::Great, thanks. I'll look into that &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 08:55, 5 September 2024 (UTC)
::::Yes that works. Unfortunately it means that I need to call the module twice: the second time after deciding which category to use. But this will only happen if there are any unknown parameters so will not affect performance unduly. &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 09:06, 5 September 2024 (UTC)
:::::Add comments to your code. When you are crushed by a steamroller while jaywalking Main Street, whoever comes after you to maintain that module can then know why you did what you did.
:::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 11:48, 5 September 2024 (UTC)