2 .\" Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL [your name] OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 This file specifies the preferred style for lua source files in the
40 Many of the style rules are implicit in the examples.
41 Be careful to check the examples before assuming that
43 is silent on an issue.
45 The copyright header should be a series of single-line comments.
46 Use the single-line comment style for every line in a multi-line comment.
48 After any copyright header, there is a blank line, and the
50 comment for non-C/C++ source files.
52 The preferred method of including other files and modules is with
58 config = require("config");
59 menu = require("menu");
60 password = require("password");
61 -- One blank line following the module require block
67 Indentation and wrapping should match the guidelines provided by
69 Do note that it is ok to wrap much earlier than 80 columns if readability would
76 This is applicable to objects with methods.
77 String are a commonly-used example of objects with methods.
81 should be done explicitly, rather than as a boolean expression.
82 Single-line conditional statements and loops should be avoided.
85 variables should be preferred to global variables in module scope.
86 internal_underscores tend to be preferred for variable identifiers, while
87 camelCase tends to be preferred for function identifiers.
89 If a table definition spans multiple lines, then the final value in the table
90 should include the optional terminating comma.
93 -- No terminating comma needed for trivial table definitions
94 local trivial_table = {1, 2, 3, 4}
96 local complex_table = {
99 func = foo_function, -- Trailing comma preferred
104 }, -- Trailing comma preferred
108 This reduces the chance for errors to be introduced when modifying more complex
111 Multiple local variables should not be declared
113 initialized on a single line.
114 Lines containing multiple variable declarations without initialization are ok.
115 Lines containing multiple variable declarations initialized to a single function
116 call returning a tuple with the same number of values is also ok.
120 be done at declaration time as appropriate.
124 This manual page is inspired from the same source as