(Translated by https://www.hiragana.jp/)
⚓ T361930 Support splitting gadget definitions over multiple lines
Page MenuHomePhabricator

Support splitting gadget definitions over multiple lines
Open, Needs TriagePublicFeature

Description

Feature summary (what you would like to be able to do and where):

MediaWiki:Gadgets-definition should support splitting gadget definitions over multiple lines.

This could perhaps be done by treating any line starting with whitespace, |, [ or ] as part of the previous line.

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):

MediaWiki:Gadgets-definition now supports a lot of options for gadgets. These are useful, but using them makes the definitions hard to read and edit, because the entire definition has to be on the same line.

If the gadget maintainers don't add whitespace to the definitions, it can also cause the page to scroll horizontally (e.g. https://commons.wikimedia.org/wiki/MediaWiki:Gadgets-definition scrolls horizontally for me unless the window is at least 1600px wide).

Storing the definitions using a different format would be the best option, but that doesn't seem like it's going to happen soon.

Benefits (why should this be implemented?):

It would make gadget definitions easier to read and edit.

For example, one of the longest definitions on the Commons page is

* Twinkle[ResourceLoader|dependencies=ext.gadget.morebits,ext.gadget.select2,mediawiki.api,mediawiki.language|rights=autoconfirmed|type=general|peers=Twinkle-pagestyles|requiresES6]|Twinkle.js|Twinkle.css|twinklespeedy.js|twinkleimage.js|twinklediff.js|twinkleunlink.js|twinklefluff.js|twinklebatchdelete.js|twinklebatchprotect.js|twinklebatchundelete.js|twinkleconfig.js

If splitting a definition over multiple lines were supported, this could perhaps be written as

* Twinkle
[
	ResourceLoader
	| dependencies = ext.gadget.morebits, ext.gadget.select2, mediawiki.api, mediawiki.language
	| rights = autoconfirmed
	| type = general
	| peers = Twinkle-pagestyles
	| requiresES6
]
| Twinkle.js
| Twinkle.css
| twinklespeedy.js
| twinkleimage.js
| twinklediff.js
| twinkleunlink.js
| twinklefluff.js
| twinklebatchdelete.js
| twinklebatchprotect.js
| twinklebatchundelete.js
| twinkleconfig.js

Written like that, I think it's much easier to see which resource loader options are being used, which pages are included, whether they're CSS, JS or JSON, etc.

Event Timeline

Not ideal but there is a gadget that at least adds whitespace:

// [[MediaWiki:Gadgets-definition]] formatter (links and stuff)
if (mw.config.get("wgCanonicalNamespace") == "MediaWiki"
	&& mw.config.get("wgTitle") === "Gadgets-definition"
	&& document.querySelector(".mw-parser-output")
)
{
	mw.loader.load("https://meta.wikimedia.org/w/index.php?title=User:Nux/gadgets-definition-ux.js&action=raw&ctype=text/javascript");
}

You can add this in:
https://meta.wikimedia.org/wiki/Special:MyPage/global.js
and it will fix scrolling on:
https://commons.wikimedia.org/wiki/MediaWiki:Gadgets-definition