Add "Examples" lines to fix markdown
This commit is contained in:
parent
c47d3b6b04
commit
0d0cac409a
1 changed files with 14 additions and 0 deletions
14
lua-style.md
14
lua-style.md
|
@ -9,6 +9,8 @@
|
||||||
2. Or neither of them
|
2. Or neither of them
|
||||||
3. Put spaces *after* the separator (if at all), never before
|
3. Put spaces *after* the separator (if at all), never before
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
local outer = { {"inner",1}, {"inner",2}, }
|
local outer = { {"inner",1}, {"inner",2}, }
|
||||||
|
|
||||||
<!-- multiline -->
|
<!-- multiline -->
|
||||||
|
@ -16,6 +18,8 @@
|
||||||
2. Or don't put any items on the same line as the curly braces.
|
2. Or don't put any items on the same line as the curly braces.
|
||||||
3. Indent the items of the table
|
3. Indent the items of the table
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
local oneline = {'hello', 'world',}
|
local oneline = {'hello', 'world',}
|
||||||
lcoal multiline = {
|
lcoal multiline = {
|
||||||
'hello',
|
'hello',
|
||||||
|
@ -28,6 +32,8 @@
|
||||||
1. Use commas (`,`) to separate order-dependant items (list)
|
1. Use commas (`,`) to separate order-dependant items (list)
|
||||||
2. Use semicolons (`;`) to separate order-independant items (set)
|
2. Use semicolons (`;`) to separate order-independant items (set)
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
local ingredients = { "eggs"; "flour"; "milk"; }
|
local ingredients = { "eggs"; "flour"; "milk"; }
|
||||||
local steps = { "mix", "fry", }
|
local steps = { "mix", "fry", }
|
||||||
|
|
||||||
|
@ -37,6 +43,8 @@
|
||||||
3. Put no separator after the last element if external conditions must change
|
3. Put no separator after the last element if external conditions must change
|
||||||
for an additional item to be inserted.
|
for an additional item to be inserted.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
local color = { 0xff, 0x20, 0x40 }
|
local color = { 0xff, 0x20, 0x40 }
|
||||||
local line = { {0, 0}, {0, 20}, {20, 20}, }
|
local line = { {0, 0}, {0, 20}, {20, 20}, }
|
||||||
|
|
||||||
|
@ -48,6 +56,8 @@
|
||||||
open-ended sequences
|
open-ended sequences
|
||||||
3. Or use a different separator to signal that no items should be added
|
3. Or use a different separator to signal that no items should be added
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
local pancakes = {
|
local pancakes = {
|
||||||
'mix', 'fry';
|
'mix', 'fry';
|
||||||
ingredients = { 'milk'; 'eggs'; 'flour' };
|
ingredients = { 'milk'; 'eggs'; 'flour' };
|
||||||
|
@ -68,6 +78,8 @@
|
||||||
2. Use semicolons otherwise
|
2. Use semicolons otherwise
|
||||||
3. Apply same rules as with sequnces for separator after last element
|
3. Apply same rules as with sequnces for separator after last element
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
local point = {x=20, y=30}
|
local point = {x=20, y=30}
|
||||||
local tasks = { monday = {'call steve'}, tuesday = {'fix kitchen door'}, }
|
local tasks = { monday = {'call steve'}, tuesday = {'fix kitchen door'}, }
|
||||||
local person = { name="John Doe"; age="Unknown" }
|
local person = { name="John Doe"; age="Unknown" }
|
||||||
|
@ -77,5 +89,7 @@
|
||||||
2. Use square brackets for numbers acting as keys in a map
|
2. Use square brackets for numbers acting as keys in a map
|
||||||
3. Judge based on semantic meaning, not on technicalities
|
3. Judge based on semantic meaning, not on technicalities
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
local ages = { [20]="John, Henry"; [21]="William"; }
|
local ages = { [20]="John, Henry"; [21]="William"; }
|
||||||
local errors = { [1]="File not Found"; [2]="Permission Denied" }
|
local errors = { [1]="File not Found"; [2]="Permission Denied" }
|
||||||
|
|
Loading…
Reference in a new issue