User:Ganaram inukshuk/Provisional style guide for Lua: Difference between revisions
Undo (some) unauthorized changes (this wasn't meant to be edited by others); updated with guides on TODO and comments |
No edit summary |
||
| Line 53: | Line 53: | ||
Only block comments <code> --[[ ]]-- </code> should only be used for commented-out code. This can be hard to do if a string contains a <code>]]</code>, so <code>--</code> may be used instead. | Only block comments <code> --[[ ]]-- </code> should only be used for commented-out code. This can be hard to do if a string contains a <code>]]</code>, so <code>--</code> may be used instead. | ||
== Mediawiki table formatting == | == Specific conventions == | ||
=== Boilerplate code === | |||
Alphabetize dependencies, except for p, which goes last and separated by a line. Equals signs may be lined up. Placement of comments to be determined. | |||
'''Preferred order'''<syntaxhighlight lang="lua" line="1"> | |||
local mos = require("Module:MOS") | |||
local rat = require("Module:Rational") | |||
local utils = require("Module:Utils") | |||
local et = require("Module:ET") | |||
local tip = require("Module:Template input parse") | |||
local tamnams = require("Module:TAMNAMS") | |||
local yesno = require("Module:Yesno") | |||
local p = {} | |||
</syntaxhighlight>'''Avoid'''<syntaxhighlight lang="lua" line="1"> | |||
local mos = require("Module:MOS") | |||
local rat = require("Module:Rational") | |||
local utils = require("Module:Utils") | |||
local et = require("Module:ET") | |||
local tip = require("Module:Template input parse") | |||
local tamnams = require("Module:TAMNAMS") | |||
local yesno = require("Module:Yesno") | |||
local p = {} | |||
</syntaxhighlight> | |||
=== Mediawiki table formatting === | |||
Wikitables should be written with one line per cell instead of one line per row. This is for ease-of-reading when debugging the output of a module-generated table. Add a space between pipes/exclamation points and table entries to avoid accidentally adding new rows, such as when inputting negative numbers. | Wikitables should be written with one line per cell instead of one line per row. This is for ease-of-reading when debugging the output of a module-generated table. Add a space between pipes/exclamation points and table entries to avoid accidentally adding new rows, such as when inputting negative numbers. | ||
| Line 74: | Line 100: | ||
|}</nowiki> | |}</nowiki> | ||
}} | }} | ||
'''Avoid''' | '''Avoid''' | ||
| Line 88: | Line 113: | ||
|}</nowiki> | |}</nowiki> | ||
}} | }} | ||
== Templates and modules == | == Templates and modules == | ||