Page MenuHomePhabricator

Changing the default TemplateData formats (block & inline) for the entire project with MediaWiki message
Open, Needs TriagePublic

Description

In many projects, templates are not formatted in the same way as in English Wikipedia. And in those projects where this is not so, each edit made through a visual editor can change the design of several dozen lines (usually removing or adding spaces). But since the final format is not common, other tools can change it back.

Now the only way to fix this is to specify a custom format for each of the thousands of templates. Instead, it's more appropriate to create a message in the MediaWiki namespace with the standard values ​​for the block and inline formats and allow sysops to modify it.

Event Timeline

JTannerWMF added a subscriber: JTannerWMF.

The Editing-team doesn't have the capacity to work on this task at this present time due to our work for Talk Pages.

Supporting this, since all templates on Russian Wikipedia now use (or should use) custom formatting. As an intermediate or alternative, it would be useful to simply add a 4th type of formatting, based on block style, but where the number of spaces is set automatically by the number of characters of the longest parameter in the template.

I would like to add a few things to consider:

  • What this ticket currently suggests is the possibility to change the default format on a per-wiki basis. There are a few ways to achieve this. They all have the same problems:
    • It potentially makes it impossible for anybody to consume anything the TemplateData API provides without also checking the wiki's default format. One way to work around this is to add a normalization step that merges the default format into the templatedata API response for all templates that don't specify their own format. But this creates the next problem: It might be relevant for consumers to know if the format they see in an API response is per-wiki or per-template. That requires some new field in the TemplateData JSON. How should that look like?
    • What should happen when someone edits the default format? Do we need to invent some new process that invalidates the templatedata page property for all templates that don't specify their own format? Is this enough to make the API reflect the change in a timely manner?
    • We have the same problem the moment we add this feature. All templates need to be invalidated.
  • A format that adapts to "the longest parameter in the template" sounds like a good idea. Unfortunately it also comes with a few problems:
    • The moment a new, longer parameter is added the formatting would silently change. This would cause dirty diffs in all subsequent edits.
    • Should it be the longest parameter that's available per TemplateData documentation, even if that parameter is rarely used? That would create an unexpected, hard to explain indention.
    • An in my opinion better way to solve this is to set the number of underscores in the format string to a sensible upper bound, e.g. | __________ = _. This pads shorter parameter names but still allows longer ones. Both my Auto-Formatter (which was the inspiration for the format string feature) and TemplateData already behave like this.