Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Feb 2018 01:25:52 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329543 - head/share/man/man9
Message-ID:  <201802190125.w1J1PqSm015025@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Mon Feb 19 01:25:52 2018
New Revision: 329543
URL: https://svnweb.freebsd.org/changeset/base/329543

Log:
  Create style.lua(9)
  
  This covers the lua style guidelines we've generally agreed on so far. It
  will be revised as work continues and we run into more scenarios that need
  specified.
  
  Discussed with:	cem, jilles
  Differential Revision:	https://reviews.freebsd.org/D14423

Added:
  head/share/man/man9/style.lua.9   (contents, props changed)
Modified:
  head/share/man/man9/Makefile

Modified: head/share/man/man9/Makefile
==============================================================================
--- head/share/man/man9/Makefile	Mon Feb 19 00:54:08 2018	(r329542)
+++ head/share/man/man9/Makefile	Mon Feb 19 01:25:52 2018	(r329543)
@@ -284,6 +284,7 @@ MAN=	accept_filter.9 \
 	stack.9 \
 	store.9 \
 	style.9 \
+	style.lua.9 \
 	swi.9 \
 	sx.9 \
 	syscall_helper_register.9 \

Added: head/share/man/man9/style.lua.9
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/share/man/man9/style.lua.9	Mon Feb 19 01:25:52 2018	(r329543)
@@ -0,0 +1,105 @@
+.\"-
+.\" Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL [your name] OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd February 18, 2018
+.Dt STYLE.LUA 9
+.Os
+.Sh NAME
+.Nm style.lua
+.Nd
+.Fx
+lua file style guide
+.Sh DESCRIPTION
+This file specifies the preferred style for lua source files in the
+.Fx
+source tree.
+Many of the style rules are implicit in the examples.
+Be careful to check the examples before assuming that
+.Nm
+is silent on an issue.
+.Pp
+The copyright header should be a series of single-line comments.
+Use the single-line comment style for every line in a multi-line comment.
+.Pp
+After any copyright header, there is a blank line, and the
+.Li $\&FreeBSD$
+comment for non-C/C++ source files.
+.Pp
+The preferred method of including other files and modules is with
+.Fn require name ,
+such as:
+.Bd -literal
+-- $FreeBSD$
+
+config = require("config");
+menu = require("menu");
+password = require("password");
+-- One blank line following the module require block
+.Ed
+.Pp
+.Fn include
+is generally avoided.
+.Pp
+Indentation and wrapping should match the guidelines provided by
+.Xr style 9 .
+.Pp
+Statements should be terminated with a semicolon.
+.Ic end
+should not be terminated with a semicolon.
+.Pp
+Where possible,
+.Fn s:method ...
+is preferred to
+.Fn method s ... .
+This is applicable to objects with methods.
+String are a commonly-used example of objects with methods.
+.Pp
+Testing for
+.Va nil
+should be done explicitly, rather than as a boolean expression.
+Single-line conditional statements and loops should be avoided.
+.Pp
+.Ic local
+variables should be preferred to module scope variables.
+.Pp
+Multiple local variables should not be declared
+.Sy and
+initialized on a single line.
+Lines containing multiple variable declarations without initialization are ok.
+Lines containing multiple variable declarations initialized to a single function
+call returning a tuple with the same number of values is also ok.
+.Pp
+Initialization
+.Sy should
+be done at declaration time as appropriate.
+.Sh SEE ALSO
+.Xr style 9
+.Sh HISTORY
+This manual page is inspired from the same source as
+.Xr style 9
+manual page in
+.Fx .



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802190125.w1J1PqSm015025>