Manual talk:Coding conventions/Lua
Add topicAppearance
Latest comment: 9 months ago by Od1n in topic This doesn't match MediaWiki coding conventions
This doesn't match MediaWiki coding conventions
[edit]This was taken from enwiki's conventions for writing modules on that wiki, and does not match the coding conventions for Lua code in MediaWiki extensions such as Scribunto. I could fix it, which would change several things here, or this could be removed back to enwiki if they want their conventions to remain the same. Anomie (talk) 14:03, 25 November 2015 (UTC)
- Anomie, it's quite late, but could you perhaps do it? It would be good to at least have the convention in extensions documented, and it can act as a good global default. If the English Wikipedia wants to have something local, it's acceptable. --Amir E. Aharoni (talk) 07:07, 23 September 2018 (UTC)
- I just encountered the same problem. I got used to the MediaWiki coding convention on all file types, including Lua: spaces inside
( ),{ }, and even[ ]. I just formatted a Lua file as so, and was about to reference this page, when I noticed it was diverging from the usual convention. By looking at the Scribunto repository, Lua files have spaces inside( ),{ }, but not inside[ ]. Thus, here on mediawiki.org we should recommend spaces inside( ),{ }, but I'm not sure about the[ ](I think we should have spaces as well, but that's not what is done in the Scribunto repository). Od1n (talk) 07:09, 20 October 2023 (UTC)- +1 to adhering to MediaWiki conventions. — MusikAnimal talk 17:22, 20 October 2023 (UTC)
- MediaWiki PHP code doesn't usually spaces in
[ ](when used as array index) either. Tgr (WMF) (talk) 00:12, 22 October 2023 (UTC)- Another +1 for changing this to the MediaWiki convention. I've just randomly landed (again) on this page, and got immediately shocked that it was recommending the opposite of what is found absolutely everywhere in the Wikipedia/MediaWiki ecosystem.
- Also, I would suggest spaces in square brackets as well, including in indices such as
[ 0 ]: consistency beats saving some spaces in a specific case where they might look excessive. Actually, the whole "spaces in parentheses/brackets" convention seems too spaced at first glance, but once you get used to it, it's quite great. - Od1n (talk) 22:19, 14 January 2026 (UTC)
- I just encountered the same problem. I got used to the MediaWiki coding convention on all file types, including Lua: spaces inside