Wikipedia talk:Lua

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia


Do we have a Lua module that can read a JSON table, something equivalent to Module:Data? I found Module:Jf-JSON but it looks way more complicated than I need. — Martin (MSGJ · talk) 11:33, 19 July 2023 (UTC)Reply[reply]

mw.loadJsonData, mw.text.jsonDecode, and mw.text.jsonEncode. may also be relevant. Izno (talk) 16:25, 19 July 2023 (UTC)Reply[reply]
I'm thinking we could adapt Module:Data so that it can read JSON pages as well. There could be a parameter to switch between the modes or possibly it could be deduced using mw.title.contentModel — Martin (MSGJ · talk) 20:55, 19 July 2023 (UTC)Reply[reply]
Do you want to access the data on the JSON page from Lua, or from a template? (From your later post, I'm guessing from a template.) To provide access from a template, if it's just one JSON page, you could create a simple wrapper module that calls mw.loadJsonData on it, and returns the value from the call. This module can then be used as an argument to Module:Data. If the template is using a lot of data from the JSON page, converting the template to a Lua implementation may be worth considering. isaacl (talk) 17:58, 29 September 2023 (UTC)Reply[reply]
A module which I could invoke in a template would be just fine. Could an additional function be added to Module:Data to call mw.loadJsonData and then pass to its main function? I'm not familiar with metatables so don't want to touch that module! — Martin (MSGJ · talk) 14:47, 4 October 2023 (UTC)Reply[reply]
In a kind of kludgy manner. The syntax {{#invoke:Data|Module:''some module''|...}} maps to Scribunto taking the object returned by Module:Data and invoking a method called Module:some module on it, which means using Module:some module as a key to the underlying table in the object, and treating the return value as a function. Since Module:Data can't hardcode functions for every single possible module that might be used with it, it sets up a metatable with an __index() function that returns a function. This function uses the key value that was passed to __index() as the name of the module page to access. The essential logic of this function could be extracted into a helper function, and the __index() function could be modified to treat specific values differently: say, a key in the format of JSON:page name could return a new utility function that calls mw.loadJsonData() on the specified page and then passes its return value to the helper function. isaacl (talk) 16:43, 4 October 2023 (UTC)Reply[reply]
Not going to pretend I understood half of that! But if you would have time to sandbox some code I will gladly test it, and maybe other people would find this useful too — Martin (MSGJ · talk) 20:21, 4 October 2023 (UTC)Reply[reply]
Module:Data doesn't have any test cases, so I'd have to first figure out its use cases and create tests in order to do regression testing. Thus unfortunately it's a bigger project than I'm looking to do at present. If you could describe your intended use case, maybe a simpler solution could be found. isaacl (talk) 02:06, 5 October 2023 (UTC)Reply[reply]
My immediate needs were met by Module:Women in Green event (main function) which was certainly simple enough. Don't worry if you haven't got time, this is on my long-term wishlist. — Martin (MSGJ · talk) 08:00, 5 October 2023 (UTC)Reply[reply]

Module to sum table column[edit]

I am an absolute beginner in lua and wanted to develop a module Module:Sandbox/Miria~01 that automatically sums the values ​​of the columns in a wiki table like this one created in my sandbox User:Miria~01/sandbox.

Games Athletes Gold Silver Bronze Total Rank
2008 Beijing 92 0 1 2 3 61
2012 London 116 1 1 2 4 43
2016 Rio de Janeiro 103 2 4 2 8 32
2020 Tokyo 87 3 1 5 9 28
2024 Paris future events
2028 Los Angeles
2032 Brisbane
Total 6 7 11 24 67

edited table on 11 September 2023 to show no error, original in the revision history Wikipedia_talk:Lua&oldid=1174743806

last row (total) with invoke to load module:
!colspan=2| Total !! {{#invoke:Sandbox/Miria~01|calculateSum|Gold|User:Miria~01/sandbox}} !! {{#invoke:Sandbox/Miria~01|calculateSum|Silver|User:Miria~01/sandbox}} !! {{#invoke:Sandbox/Miria~01|calculateSum|Bronze|User:Miria~01/sandbox}} !! {{#invoke:Sandbox/Miria~01|calculateSum|Total|User:Miria~01/sandbox}} !! [[All-time Olympic Games medal table|67]]

However, only zeros are ever generated as a sum. I would be grateful for any small help.

local p = {}

function p.calculateSum(frame)
    local args = frame.args
    local column = args[1]
    local wikitext = args[2]
    local sum = 0

    -- Iterate through the rows of the table
    for row in mw.text.gsplit(wikitext, "\n") do
        -- Check if the row contains the specified column
        if mw.ustring.find(row, "|" .. column .. "|") then
            -- Extract the value from the specified column
            local value = mw.ustring.match(row, "||%s*([0-9]+)%s*||")
            if value then
                -- Attempt to convert the value to a number, or default to 0 if conversion fails
                local numValue = tonumber(value)
                if numValue then
                    sum = sum + numValue
    return tostring(sum)
return p

Miria~01 (talk) 11:28, 10 September 2023 (UTC)Reply[reply]

@Miria~01: It looks like you are trying to parse the contents of User:Miria~01/sandbox, but your code above instead tries to parse the literal string User:Miria~01/sandbox as a wikitable. Instead you want to fetch the content of the page using title:getContent(). So instead of this:
    local wikitext = args[2]
You can do this:
    local wikitext =[2]):getContent()
Best — Mr. Stradivarius ♪ talk ♪ 11:43, 10 September 2023 (UTC)Reply[reply]
Thanks for the quick reply. The suggestion with title:getContent() obviously makes sense. Unfortunately only zeros are still generated. But I'll take a look at the module Module:USN fleet totals from User:Trappist the monk, how he did it, to hopefully find a solution for my issue. Miria~01 (talk) 12:56, 10 September 2023 (UTC)Reply[reply]
Not going to work as you want it to work because args[2] is just the text string User:Miria~01/sandbox.
I wrote some code to render List of current ships of the United States Navy § Fleet totals by extracting the appropriate data from tables. See {{USN fleet totals}}, Module:USN fleet totals, and Module:USN fleet totals/data. You might want to look at that code to see how I did it.
I can imagine difficulties in the future because editors have varying beliefs regarding how wikitext should be formatted. It might be best to have your module create the whole table from data stored in a module's subpage. There would be no parsing required for that.
Seems odd to me that MediaWiki doesn't have Javascript to sum table contents. After all, MediaWiki does provide Javascript to sort columns so it would seem that they could also supply a script to sum columns and/or rows. That they don't suggests that there are difficulties that I am not aware of.
Trappist the monk (talk) 12:04, 10 September 2023 (UTC)Reply[reply]
Thanks for the suggestion, I'll definitely take a look at your modules and try to build on that with the previous save data in a module's subpage, summing the columns/rows in tables.
I'm actually also surprised that, if at all, calculations can only be made on Wiki using {{#expr:expression}}, but only explicitly numbers and not, for example, cells (cell_ID could be assigned) from tables. Miria~01 (talk) 12:59, 10 September 2023 (UTC)Reply[reply]
The line if mw.ustring.find(row, "|" .. column .. "|") then is searching for text "|Gold|" which never gets a result (hence sum=0). You want to find lines beginning with "|align=left|" or just "|" and then iterate the results of mw.ustring.match(row, "||%s*([0-9]+)%s*||"). You need some way of deciding which column to extract or output all the sums in a single call. —  Jts1882 | talk  14:01, 10 September 2023 (UTC)Reply[reply]
Which all complexity is why I suggested building the table on the fly from data in a ~/data module...
Trappist the monk (talk) 14:20, 10 September 2023 (UTC)Reply[reply]
Yes, data modules are much more flexible. I've used them before at Module:Goalscorers and Module:SportsRankings.
In the meantime, I made a quick and dirty version of Module:Sandbox/Miria~01 that automatically sums the values of the columns Gold, Silver, Bronze and Total and outputs the sums for the table in User:Miria~01/sandbox. —  Jts1882 | talk  14:58, 10 September 2023 (UTC)Reply[reply]
All added a column option "All" to output the sums as four table cells in one module call. —  Jts1882 | talk  15:07, 10 September 2023 (UTC)Reply[reply]
Thank you very much, I had a wrong thought how to recognize the correct line with the value. Also realize that data-modules is actually the best and cleanest solution.
In the end, the driving force was that the total sum of medals in the medal tables of the individual nations (by Olympic event, by sports, etc.) at the Olympic Games (e.g. Russia_at_the_Olympics#Medal_tables) at the Olympic Games is correct. Since in the case of stripped medals (stripped after several years due to doping), individual users change accordingly the entry for the event, but neglect the total sum or change the entry for the year, but neglect to change it also at the sport itself and so incorrect numbers arise. Miria~01 (talk) 16:18, 10 September 2023 (UTC)Reply[reply]
As a note, "align=left" is deprecated/obsolete HTML and is likely to be removed. In general, this whole endeavor is indeed brittle at best. Izno (talk) 16:24, 10 September 2023 (UTC)Reply[reply]
Just because I've not done much with the html library, this seemed like a useful learning opportunity so I have hacked Module:Sandbox/trappist the monk/html which creates a table along the lines of the table that Miria~01 posted in the OP. It ignores future events (I'm not sure that looks favorably on stuff that has not yet occurred). The experiment relies on two tables; one for the all-time ranking (bottom right table cell) and one containing all of the necessary row data. To test it add this to a sandbox:
Trappist the monk (talk) 16:46, 10 September 2023 (UTC)Reply[reply]

Just for completeness: I created for my request in Module:Sandbox/Miria~01/sumMedals, that after specifying a targetClass as args[1], the type of medals should be searched for. e.g. for summer class="summerMedals" and for winter class="winterMedals". For the existing medal tables of all countries ("xxx"_at_the_olympics, e.g. Croatia at the Olympics) class="summerMedals" or class="winterMedals" would then have to be inserted into the table rows. At the same time, the infbox for the individual countries can also be updated directly on the same page

| gold  =  {{#expr: {{#invoke:Sandbox/Miria~01/sumMedals|calculateSum|summerMedals|Gold|{{FULLPAGENAME}}}} + {{#invoke:Sandbox/Miria~01/sumMedals|calculateSum|winterMedals|Gold|{{FULLPAGENAME}}}}}}

In Wikipedia talk:WikiProject Olympics#Module to calculate sum in medal tables(+update of infobox) I explained this in more detail using an example. Of course it's not the cleanest solution, but I think it's okay temporarily. The goal, however, is a large-scale database that automatically creates the correct medal tables in the pages for the individual countries based on the data at the pages of the individual Olympics medal table e.g 2014 Winter Olympics medal table.
Miria~01 (talk) 11:44, 11 September 2023 (UTC)Reply[reply]

@Miria~01 I think that I have finish playing around. My module at Module:Sandbox/trappist the monk/html and Module:Sandbox/trappist the monk/html/data renders summer and winter tables for Serbia and Mexico. Expanding to support other countries should mostly be a matter of clerical drudgery though no doubt, an awb script could be written to extract the pertinent data from articles using plain wikitext tables. The module also has an exported function to calculate total numbers of gold/silver/bronze medals for use in infoboxen. See this version of my sandbox for example renderings.

The modules should be sufficiently documented to make expansion and maintenance of ~/data relatively easy.

Trappist the monk (talk) 16:42, 11 September 2023 (UTC)Reply[reply]

Conversion of Template:Marriage to Lua[edit]

I checked the source for Template:Marriage and it keeps on using so much code and parser functions. I suggest that the conversion should make the template more workable. RMXY (talk) 05:18, 20 September 2023 (UTC)Reply[reply]

I agree that a conversion would make a lot of sense. Do you fancy learning lua? — Martin (MSGJ · talk) 07:08, 20 September 2023 (UTC)Reply[reply]
I want to learn how to do Lua. RMXY (talk) 08:25, 22 September 2023 (UTC)Reply[reply]
This is a solution in search of a problem. The template's quest for omniscience and built-in opinions should be pared back, rather than entrenching them by creating a module. * Pppery * it has begun... 14:22, 22 September 2023 (UTC)Reply[reply]
What do you mean by "built-in opinions"? I'm looking at it and not seeing a problem. Looks like a template that provides considerable utility.  — SMcCandlish ¢ 😼  19:07, 22 September 2023 (UTC)Reply[reply]
See Template talk:Marriage/Archive 8#Use of circa for an example of what I mean. I may well hold a minority opinion here, though. * Pppery * it has begun... 22:19, 22 September 2023 (UTC)Reply[reply]
I see what you mean, but this seems like it should be reasonably easy to fix in the code, namely by no longer "helpfully" policing the input. At bare minimum, something like |circa=y parameter could turn those checks off?  — SMcCandlish ¢ 😼  22:34, 22 September 2023 (UTC)Reply[reply]
My point is that once you remove the input policing it will hopefully reach the point where it's no longer complicated enough to warrant a Lua module. * Pppery * it has begun... 00:05, 23 September 2023 (UTC)Reply[reply]

Help with understanding Lua module[edit]

I'm very new to Lua and am trying to understand how Module:Settlement short description uses the contents of the infobox to automatically generate a short description for the page if one does not exist already. I can tell this is all done in the p.main() function through usage of p.shortdesc(), but I don't understand where frame comes from. It looks like it would contain the specific contents of the page. How can I provide the module with Wikipedia article titles, such as Morning Glory, Texas or Stoneham-et-Tewkesbury for example, to see how the text parameter provided to p.shortdesc() is built in p.main()? Then once I am able to do so, how can I view the contents of variable like subdivision_names or location within p.main? BaduFerreira (talk) 15:38, 27 September 2023 (UTC)Reply[reply]

The frame object contains all the parameters/arguments that is passed to the module. There are only really two frames you need to know about: frame.args is a table of arguments from the template that calls #invoke, and frame:getParent().args is a table of arguments passed by the page that called that template. This particular module only uses the latter. I'm not familiar with the code but I believe it is mainly using the parameters that are defined in Template:Infobox settlement. The actual title of the article is only used once, rather obliquely, with mw.title.getCurrentTitle().text — Martin (MSGJ · talk) 20:29, 28 September 2023 (UTC)Reply[reply]
Okay, that makes sense. Thank you for the link, this looks like a very helpful resource. Is it possible to dump the table of arguments that any given page using this template passes to the module? I'd like to play around with the module and I think concentrating my efforts offline to a local copy would be more effective and less disruptive. BaduFerreira (talk) 22:10, 28 September 2023 (UTC)Reply[reply]
mw.dumpObject (frame.args) – dumping just frame is interesting too.
Results are available under the Lua logs dropdown in the Parser profiling data dropdown when you preview an article (or testcases page) that uses your module.
Trappist the monk (talk) 22:55, 28 September 2023 (UTC)Reply[reply]
What do you mean by results? Would that be the output of mw.dumpObject (frame.args)? I'm not sure where I would execute that function. Additionally, where would I find the Parser profiling data dropdown? I don't know what you mean by preview article (I thought maybe edit preview but I can't find anything there). Hope you don't mind all the questions 🙂 BaduFerreira (talk) 00:50, 29 September 2023 (UTC)Reply[reply]
You edit the module and add the line somewhere in the function where frame is passed as an argument. Do not save the edit (you will finish by abandoning it, leaving the module unchanged). Underneath the edited module, find "Preview page with this template" and paste the title of a page where the module is used. Click Show preview to see how that page would look if the edit to the module were saved. Then the stuff at the bottom of the page should show the dump. Johnuniq (talk) 01:02, 29 September 2023 (UTC)Reply[reply]
Ah okay, I see. I didn't realize I could do that. I'm able to preview a page that uses Module:Settlement short description after adding the mw.dumpObject(frame.args) function to p.main(), but I'm getting nil as the output so I'll keep poking around. Thank you everyone for all the help so far! BaduFerreira (talk) 01:55, 29 September 2023 (UTC)Reply[reply]
Sorry, it's mw.logObject(frame.args) (log, not dump; dump gives a string). However, I just tried it (using Anah as the preview page) and the output is just table#1 { metatable = table#2 }. That's because args is a magic table that doesn't do anything until you ask for a specific argument. You would need something like mw.logObject(frame:getParent().args.short_description) but that outputs nil because no parameters are passed to the template. Johnuniq (talk) 02:21, 29 September 2023 (UTC)Reply[reply]

The syntax for Template:Weather box is unnecessarily verbose as each data entry receives its own row. I have no prior knowledge of Lua and am trying to condense the template:

Example: Template:New York City weatherbox would be condensed to something like this:

{{Compact weather box
|location = New York City
|source 1 = [[NOAA]] (relative humidity and sun 1961–1990; dew point 1965–1984)<ref name = "New York City Weatherbox NOAA" >{{cite web |url= |title = NowData – NOAA Online Weather Data |publisher = [[National Oceanic and Atmospheric Administration]] |access-date = May 4, 2021}}</ref><ref name="New York City Weatherbox NOAA txt">{{cite web |archive-url= |archive-date=May 4, 2021 |url= |publisher=[[National Oceanic and Atmospheric Administration]] |title=Summary of Monthly Normals 1991–2020 |access-date=May 4, 2021}}</ref><ref name = noaasun>{{cite web|title=New York Central Park, NY Climate Normals 1961−1990|url=|publisher=[[National Oceanic and Atmospheric Administration]] |access-date=July 18, 2020}}</ref>
|source 2 = Weather Atlas<ref name="Weather Atlas NYC">{{cite web |url= |title=New York, New York, USA - Monthly weather forecast and Climate data |publisher=Weather Atlas |access-date=July 4, 2019 }}</ref>
|units = imperial |preferred units = imperial
|temp color = default |precip color = green |snow color = blue |humidity color = blue
<!-- month     Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec  Year-->
|record high   |72  |78  |86  |96  |99  |101 |106 |104 |102 |94  |84  |75
|monthly high  |60.4|60.7|70.3|82.9|88.5|92.1|95.7|93.4|89.0|79.7|70.7|62.9|97.0
|high          |39.5|42.2|49.9|61.8|71.4|79.7|84.9|83.3|76.2|64.5|54.0|44.3
|mean          |33.7|35.9|42.8|53.7|63.2|72.0|77.5|76.1|69.2|57.9|48.0|39.1
|low           |27.9|29.5|35.8|45.5|55.0|64.4|70.1|68.9|62.3|51.4|42.0|33.8
|monthly low   |9.8 |12.7|19.7|32.8|43.9|52.7|61.8|60.3|50.2|38.4|27.7|18.0|7.7
|record low    |-6  |-15 |3   |12  |32  |44  |52  |50  |39  |28  |5   |-13
|precip        |3.64|3.19|4.29|4.09|3.96|4.54|4.60|4.56|4.31|4.38|3.58|4.38
|snow          |8.8 |10.1|5.0 |0.4 |0.0 |0.0 |0.0 |0.0 |0.0 |0.1 |0.5 |4.9
|precip day threshold = 0.01 in
|precip days   |10.8|10.0|11.1|11.4|11.5|11.2|10.5|10.0|8.8 |9.5 |9.2 |11.4
|snowy day threshold = 0.1 in
|snowy days    |3.7 |3.2 |2.0 |0.2 |0.0 |0.0 |0.0 |0.0 |0.0 |0.0 |0.2 |2.1
|humidity      |61.5|60.2|58.5|55.3|62.7|65.2|64.2|66.0|67.8|65.6|64.6|64.1
|dew point     |18.0|19.0|25.9|34.0|47.3|57.4|61.9|62.1|55.6|44.1|34.0|24.6
|sun           |163 |163 |213 |226 |257 |257 |268 |268 |219 |211 |151 |139
|percent sun   |54  |55  |57  |57  |57  |57  |59  |63  |59  |61  |51  |48
|uv            |2   |3   |4   |6   |7   |8   |8   |8   |6   |4   |2   |1

In addition to having only one row for each monthly statistic, rather than 12-13 rows, the suggested configuration would resemble a table, allowing better readability and editing of data. Unlike Template:Weather box/concise C and Template:Weather box/concise F, this template would support all the data provided in Template:Weather box. For the rows with 12 values rather than 13 (everything except monthly high and monthly low), the yearly value would be automatically calculated. Crossover1370 (talk | contribs) 19:12, 30 September 2023 (UTC)Reply[reply]

I agree that would be a better procedure and is something I thought about that while implementing Module:Weather box but it was already a bit over human comprehension. Some delimiter other than pipe would be used so each row could be parsed. Module:Football manager history does something similar in that it extracts fields from text rows. Another to-do item is to use mw.html to generate the table rather than wikitext. Johnuniq (talk) 23:36, 30 September 2023 (UTC)Reply[reply]
Would the comma be an acceptable delimiter? (as in |high = 40, 42, 49, 62, 71, 80, 85, 83, 76, 65, 54, 44)? Would there have to be quotation marks, as in |high = "40, 42, 49, 62, 71, 80, 85, 83, 76, 65, 54, 44"? I'm trying to develop this myself but I know nothing about Lua or how it is used in Wikipedia. Crossover1370 (talk | contribs) 01:13, 1 October 2023 (UTC)Reply[reply]
I guess comma would never conflict with any of the parameters that weatherbox expects (if a value could ever contain a comma, you would want to pick a different delimiter). It might be ok to use spaces with a dash for missing items. Johnuniq (talk) 01:35, 1 October 2023 (UTC)Reply[reply]
Would there have to be quotation marks at the beginning and the end of the sequence of values? As in: |high = "40, 42, 49, 62, 71, 80, 85, 83, 76, 65, 54, 44"? Or would |high = 40, 42, 49, 62, 71, 80, 85, 83, 76, 65, 54, 44 (without quotes) be acceptable? Crossover1370 (talk | contribs) 01:55, 1 October 2023 (UTC)Reply[reply]
Quotes not needed. Everything in a template is a string (1.5 is three ASCII characters). Johnuniq (talk) 02:51, 1 October 2023 (UTC)Reply[reply]
Just use whitespace as delimiter instead of comma for even more readable template syntax: mw.text.split(datarow, '%s+') Dexxor (talk) 08:17, 1 October 2023 (UTC)Reply[reply]


I notice that string.upper(s) is equivalent to s:upper() - is that correct? Why is the "string" not needed in the second format? — Martin (MSGJ · talk) 13:28, 6 October 2023 (UTC)Reply[reply]

This is correct behaviour, and I believe is called a method call.
If you call a function of an object using : instead of ., the first argument will automatically become the object the call was made from. For example, t:xyz(...) is just an alternate way of typing, ...)
Since all strings have the string functions as methods (E.g. ("").upper is string.upper), this means s:upper() is functionally acting as string.upper(s).
You can see an example in mw:Extension:Scribunto/Lua reference manual § Function calls. There's also some special rules when using : to define a function, which you can read about at the bottom of this section on the lua manual. Aidan9382 (talk) 13:59, 6 October 2023 (UTC)Reply[reply]
Thank you, that's helpful. I had no idea you could replace the word "string" with any string. Is that part documented somewhere? — Martin (MSGJ · talk) 20:54, 6 October 2023 (UTC)Reply[reply]
This behavior is part of Lua but I forget where I saw it documented originally. Whether or not s:upper() works depends on what s is. It needs to be based on a table with a member called upper and that member has to be a function. Strings in Lua (but not mw.ustring) work like that. Johnuniq (talk) 23:06, 6 October 2023 (UTC)Reply[reply]
The reason this logic applies to string objects is because their metatable's __index is the string table.lua docs This means attempting to index (access a member of) a string object will actually index the string table for that object. Aidan9382 (talk) 06:32, 7 October 2023 (UTC)Reply[reply]

Adding line to Module:Interlinear[edit]

I want to add a parameter to {{fs interlinear}} to allow for a right-to-left gloss for Semitic languages. I tinkered a little bit with the HTML that the template produces, and it seems like all that's needed to do this is change line #44 of Module:Interlinear so that it can read float: right; rather than float: left; if a certain parameter (perhaps |RTL=yes) is set. I asked the person who usually edits that template, but their last edit was in April so I don't think I'm hearing back on that anytime soon. Can someone here help me figure out how to make this alteration? Eievie (talk) 01:57, 19 October 2023 (UTC)Reply[reply]

How to make multilangual parameters in Module:Navbox[edit]


I'm translated Navbox module into Kazakh Wikipedia, but have one issue. We've already have a kk:Module:Navbox, but I want to upgrade it. Additionally in the some templates we also used English version of Navbox (english parameters). So I need to add english versions of parameters (Aliases?) to new kk:Module:Шолғы exactly to kk:Module:Шолғы/configuration. I've already ask this question on talk page of Module:Navbox, but nobody replied, that's why I'm writing here Thanks--Amangeldi Mukhamejan (talk) 15:15, 27 October 2023 (UTC)Reply[reply]

What links here[edit]

Up until just now Template:WikiProject Cephalopods invoked Module:WikiProject banner with a parameter containing a template, i.e.

|HOOK_ASSESS = {{WPBannerMeta/hooks/bchecklist}}

Template:WikiProject Cephalopods was not listed at Special:WhatLinksHere/Template:WPBannerMeta/hooks/bchecklist, however, a page like Talk:Vampire squid which transcludes Template:WikiProject Cephalopods was listed in WhatLinksHere, which surprised me. Why was the page listed but not the template? — Martin (MSGJ · talk) 07:20, 10 November 2023 (UTC)Reply[reply]

The point of WhatLinksHere is so MediaWiki knows what pages need to be regenerated when a template or module is changed. The page Template:WikiProject Cephalopods did not contain anything that would change if the now deleted Template:WPBannerMeta/hooks/bchecklist were changed. However, Talk:Vampire squid transcluded {{WikiProject Cephalopods}} and its wikitext used to transclude {{WPBannerMeta/hooks/bchecklist}}, so Talk:Vampire squid needed to be regenerated when Template:WPBannerMeta/hooks/bchecklist changed. In conclusion, the WhatLinksHere feature is not very helpful for those maintaining templates/modules. Johnuniq (talk) 07:59, 10 November 2023 (UTC)Reply[reply]
This is the reason I quite regularly do insource searches when messing around with templates. This has the problem of not detecting redirects, but it is definitely useful in some circumstances. --Trialpears (talk) 08:28, 10 November 2023 (UTC)Reply[reply]