T107119 Provide a Lua method mw.templatedata.load() (original) (raw)
Kipod added a comment.EditedMay 4 2024, 12:47 AM
I notice the task description is currently prescribing a very specific solution, but lacks any description of a currently experienced problem ("bug") and also lacks any high-level outcome that it would enable ("feature"). It is not uncommon than once the reason for something is understood, the maintainers and other developers like yourself, might iterate on the idea and come up with a perhaps even better solution. This is currently not possible though, and is likely why it has little engagement and low priority. It's currently Yes/No situation without any apparent downside or invitation to help.
TLDR: Why do we want to load TemplatatData into Lua? What are some use cases for that? I can imagine some of course, but I'd like to hear yours.
saw this a bit late.
in general, scribuntu is tightly linked to templates, and access to templatedata enables better/more sophisticated handling of the parameters.
i described the real-world use case above, but i will repeat:
in hewiki, we use a "template parameter validator", which adds maintenance categories, and provides enough information to fix parameter errors: which template(s), which parameter, and what is the problem.
currently the validator is active for any use of some 1000+ templates, most importantly all the infobox templates in hewiki. it flags the following errors:
- undefined parameter
- missing "required" parameter
- use of obsolete parameter
- conflicting values to a parameter and its alias
- non-numeric value for parameter with "numeric" type (the tool can be easily expanded to support more type-checking, but we don't usually define other param types on hewiki)
- value outside of "suggested values"
there is an active ongoing "bugfix" effort using tracking cats, constantly resolving the errors, which positively improves the articles where templates are shown not as intended due to such errors.
this "linter" depends on templatedata, which it consumed in the super cumbersome way shown in the snippet in my message from March 27 2016.
to see it in action:
- go to hewiki and enable "הראה הודעות שגיאה ממערכת בדיקת הפרמטרים" gadget on hewiki,
- open any article in the tracking cat. (there are sub categories for each template under the system, and for each error type)
notice a red ugly button at the top, indicating the number of templates with errors in the article. clicking on it will show which template, and what are the errors (e.g., "missing required para meter "author" ").
hope this use case is real enough.
"feature" was described several times, but in a nutshell:
- provide mw.ext.TemplateData lib, which exports load(template name) function, returning templatedata as a lua table.
peace.