mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-14 10:13:13 +02:00
4d3ecd5527
* Add styleguide * Encourage full luadoc * @param and @return in code blocks * Add multi-line table comma rule
1.4 KiB
1.4 KiB
RedMew style guide
Not strictly enforced, but we appreciate if you try to remain consistent with our standards.
-
Include at least a brief one-line summary in a LuaDoc (a comment with 3 dashes
---
) before each public-facing function -
A LuaDoc with extended summary,
@params
, and@return
is encouraged. (LuaDoc Manual) -
Tabs are 4 spaces
-
Keep each line of code to a readable length. Under 140 characters when reasonable.
-
Never leave trailing whitespace.
-
End each file with a newline.
-
Newlines are unix
\n
-
Strings should normally be encased in
'
single-quotes. For strings with single quotes inside them,"
double-quotes can be used. -
Use spaces around operators, after commas, colons, and semicolons.
sum = 1 + 2
a, b = 1, 2
if 1 < 2 then
game.print("Hi")
end
- No spaces after
(
,[
,{
or before]
,)
,}
.
table = {1, 2, 3}
table[1]
- Use empty lines between
functions
and to break up functions into logical paragraphs.
local function some_function()
local data = global.data
local format = global.string_format
local string = Utils.manipulate(data, format)
game.print(string)
end
local function say_hello()
game.print("Hello")
end
- When creating a table over multiple lines, include a trailing comma after the last item.
myTable ={
'item1',
'item2',
'item3',
}