Page MenuHomePhabricator

TemplateData: Be able to specify a "no parameters accepted" definition
Open, MediumPublic1 Estimated Story PointsFeature

Description

Some (many) templates do not use any parameters (e.g., hundreds of templates like https://en.wikipedia.org/wiki/Template:Stub). However, if you add those templates, VisualEditor will ask you for parameters, just like it does for any other template. It would be nice to have a TemplateData setting for "no parameters here, so don't bother asking".


Version: unspecified
Severity: enhancement

Details

Reference
bz62417

Event Timeline

• bzimport raised the priority of this task from to High.Nov 22 2014, 2:52 AM
• bzimport added a project: TemplateData.
• bzimport set Reference to bz62417.
  • This bug has been marked as a duplicate of bug 51429 ***

I think I wasn't quite clear earlier. T53429 is about saying (nicely) that no parameters have been listed in TemplateData. I'm glad that we made that improvement, but that's not what I want here. Instead of a nice message, I want to define, in TemplateData, that this template actually does not accept or use any parameters. This is "no parameters in the template", not "no parameters currently typed into the TemplateData".

When a template is so marked, I'd also like VisualEditor disable the 'field name' search box, so that people can't insert any made-up or invalid parameters. I want TemplateData to be able to stop editors from trying to add pointless parameters.

So maybe something like a "This TemplateData definition is complete, don't allow any undocumented parameters." (not necessarily restricted to an empty array of parameters).

I'm not sure this is a direction we want to go in though - IIRC we want to allow for TemplateData being wrong and therefore able to be overridden inside VE.

Maybe something like that, although I'd be happy to to restrict it to an empty array (=the case when it is least likely to be wrong).

Even a "warning" note would be an improvement. We could probably reduce confusion if we could have it display a sentence that says, "This template uses no parameters. It is technically possible to add parameters here, but they will be ignored by the template".

I don't think we should have a property specifically to indicate that there are no parameters. I agree there needs to be room for TemplateData being wrong or outdated and VisualEditor's advanced transclusion editor would always allow for parameters to be added.

However I think it'd be fine to remove the ability to add parameters from the simple editor that loads by default in VisualEditor - for cases where TemplateData data did exist but had no parameters specified.

But @Krinkle why shouldn't we have a way to signal that there are no parameters in the template?

Yes, it could be wrong. There could also be incorrectly incomplete TemplateData blocks added (probably far more common, actually).

I'm not saying that you'd have to prevent the addition of parameters. But could you just tell me that adding a parameter to {{France-university-stub}} is probably a bad idea? Just a friendly note, not something that's going to break the workflow if the TemplateData is wrong. Just a note that says something like "According to the template documentation, this template doesn't normally use any parameters."

Here's another example for the list of use cases: The sole contents of
{{userboxbottom}} is the table-closing wikitext code |}. There are
dozens of similar templates on enwiki. Adding parameters to these is
pointless at best.

• Deskana lowered the priority of this task from High to Medium.Oct 11 2017, 9:30 PM
• Deskana moved this task from TR0: Interrupt to Freezer on the VisualEditor board.
• Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 12:23 PM

As part of the WMDE-Templates-FocusArea we made the VisualEditor dialog say this when the TemplateData documentation has an empty list of "params": {}: "This template has no documented parameters and may be intended for use without them." The user can proceed as before, but the option to add what we now clearly mark as "undocumented" parameters is much less prominent, and explained as well. The relevant task was T300710: Improve no parameter dialog state.

We spend quite some time on this detail and are quite happy with the result and how it performed in user tests. I suggest to leave it like that and close this task.

The user can proceed as before, but the option to add what we now clearly mark as "undocumented" parameters is much less prominent, and explained as well.

How to proceed? For {{stub}} on en.wp, I don’t achieve to add any parameter (as requested by this task).

How to proceed? For {{stub}} on en.wp, I don’t achieve to add any parameter […]

Turns out this is an unrelated bug, see T333826. As long as this is not fixed you can use the keyboard shortcut Ctrl+Shift+D to add undocumented parameters to any template, no matter how it is documented.

On a template which is a navigation box only containing links (on an internal wiki), I documented it as params: {} and was surprised to see in the VisualEditor the button "Add a undocumented parameter": this template is documented and there are no parameters so it may mislead the user if they add an (ignored) parameter (an example is shown in T350092).

Probing on some templates the presence of the button "add undocumented parameter" with various TemplateData states, I see currently (MediaWiki 1.45.0-alpha (6af456b) on Beta Cluster, VisualEditor 0c6d639, TemplateData f3e85339c9443):

  1. the template U with TemplateData and 2 documented parameters: no button (ok, good)
  2. the template LQT post imported with supressed user with TemplateData and 0 documented parameters (there is no parameters): button present (why? it is documented there are no parameters)
  3. the template About without TemplateData and 0 parameters detected: button present (why no warning like just below?)
  4. the template Authority control without TemplateData and 1 parameter detected: no button (and a warning about missing TemplateData) (why no button like just above?)

I would personally have removed the button in the second case and would have put the button and the warning in the 3rd and 4th case.

If there is a TemplateData, I would assume it is correct (and it’s a wiki, advanced contributors should maintain the template documentation), and if there is no TemplateData I find it is justified to see a warning, the proposed parameters and a button to add an undocumented parameter (and this is a nudge to add a TemplateData).