1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
|
.TH erl_tidy 3 "syntax_tools 1.5.5" "Ericsson AB" "ERLANG MODULE DEFINITION"
.SH MODULE
erl_tidy \- Tidies and pretty-prints Erlang source code, removing unused functions, updating obsolete constructs and function calls, etc\&.
.SH DESCRIPTION
.LP
Tidies and pretty-prints Erlang source code, removing unused functions, updating obsolete constructs and function calls, etc\&.
.LP
Caveats: It is possible that in some intricate uses of macros, the automatic addition or removal of parentheses around uses or arguments could cause the resulting program to be rejected by the compiler; however, we have found no such case in existing code\&. Programs defining strange macros can usually not be read by this program, and in those cases, no changes will be made\&.
.LP
If you really, really want to, you may call it "Inga"\&.
.LP
Disclaimer: The author accepts no responsibility for errors introduced in code that has been processed by the program\&. It has been reasonably well tested, but the possibility of errors remains\&. Keep backups of your original code safely stored, until you feel confident that the new, modified code can be trusted\&.
.SH EXPORTS
.LP
.B
dir() -> ok
.br
.RS
.LP
Equivalent to dir("")\&.
.RE
.LP
.B
dir(Dir) -> ok
.br
.RS
.LP
Equivalent to dir(Dir, [])\&.
.RE
.LP
.B
dir(Directory::filename(), Options::[term()]) -> ok
.br
.RS
.TP
Types
filename() (see module file)
.br
.RE
.RS
.LP
Tidies Erlang source files in a directory and its subdirectories\&.
.LP
Available options:
.RS 2
.TP 4
.B
{follow_links, bool()}:
If the value is \fItrue\fR, symbolic directory links will be followed\&. The default value is \fIfalse\fR\&.
.TP 4
.B
{recursive, bool()}:
If the value is \fItrue\fR, subdirectories will be visited recursively\&. The default value is \fItrue\fR\&.
.TP 4
.B
{regexp, string()}:
The value denotes a regular expression (see module \fIregexp\fR)\&. Tidying will only be applied to those regular files whose names match this pattern\&. The default value is \fI"\&.*\e\&.erl$"\fR, which matches normal Erlang source file names\&.
.TP 4
.B
{test, bool()}:
If the value is \fItrue\fR, no files will be modified\&. The default value is \fIfalse\fR\&.
.TP 4
.B
{verbose, bool()}:
If the value is \fItrue\fR, progress messages will be output while the program is running, unless the \fIquiet\fR option is \fItrue\fR\&. The default value when calling dir/2 is \fItrue\fR\&.
.RE
.LP
See the function file/2 for further options\&.
.LP
\fISee also:\fR regexp(3), file/2\&.
.RE
.LP
.B
file(Name) -> ok
.br
.RS
.LP
Equivalent to file(Name, [])\&.
.RE
.LP
.B
file(Name::filename(), Options::[term()]) -> ok
.br
.RS
.LP
Tidies an Erlang source code file\&.
.LP
Available options are:
.RS 2
.TP 4
.B
{backup_suffix, string()}:
Specifies the file name suffix to be used when a backup file is created; the default value is \fI"\&.bak"\fR (cf\&. the \fIbackups\fR option)\&.
.TP 4
.B
{backups, bool()}:
If the value is \fItrue\fR, existing files will be renamed before new files are opened for writing\&. The new names are formed by appending the string given by the \fIbackup_suffix\fR option to the original name\&. The default value is \fItrue\fR\&.
.TP 4
.B
{dir, filename()}:
Specifies the name of the directory in which the output file is to be written\&. By default, the current directory is used\&. If the value is an empty string, the current directory is used\&.
.TP 4
.B
{outfile, filename()}:
Specifies the name of the file (without suffix) to which the resulting source code is to be written\&. If this option is not specified, the \fIName\fR argument is used\&.
.TP 4
.B
{printer, Function}:
.RS 2
.TP 2
*
\fIFunction = (syntaxTree()) -> string()\fR
.RE
.RS 4
.LP
Specifies a function for prettyprinting Erlang syntax trees\&. This is used for outputting the resulting module definition\&. The function is assumed to return formatted text for the given syntax tree, and should raise an exception if an error occurs\&. The default formatting function calls \fIerl_prettypr:format/2\fR\&.
.RE
.TP 4
.B
{test, bool()}:
If the value is \fItrue\fR, no files will be modified; this is typically most useful if the \fIverbose\fR flag is enabled, to generate reports about the program files without affecting them\&. The default value is \fIfalse\fR\&.
.RE
.LP
See the function \fImodule/2\fR for further options\&.
.LP
\fISee also:\fR module/2, erl_prettypr:format/2\&.
.RE
.LP
.B
module(Forms) -> syntaxTree()
.br
.RS
.LP
Equivalent to module(Forms, [])\&.
.RE
.LP
.B
module(Forms, Options::[term()]) -> syntaxTree()
.br
.RS
.TP
Types
Forms = syntaxTree() | [syntaxTree()]
.br
syntaxTree() (see module erl_syntax)
.br
.RE
.RS
.LP
Tidies a syntax tree representation of a module definition\&. The given \fIForms\fR may be either a single syntax tree of type \fIform_list\fR, or a list of syntax trees representing "program forms"\&. In either case, \fIForms\fR must represents a single complete module definition\&. The returned syntax tree has type \fIform_list\fR and represents a tidied-up version of the same source code\&.
.LP
Available options are:
.RS 2
.TP 4
.B
{auto_export_vars, bool()}:
If the value is \fItrue\fR, all matches "\fI{V1, \&.\&.\&., Vn} = E\fR" where \fIE\fR is a case-, if- or receive-expression whose branches all return n-tuples (or explicitly throw exceptions) will be rewritten to bind and export the variables \fIV1\fR, \&.\&.\&., \fIVn\fR directly\&. The default value is \fIfalse\fR\&.
.RS 4
.LP
.LP
For example:
.nf
{X, Y} = case \&.\&.\&. of
\&.\&.\&. -> {17, foo()};
\&.\&.\&. -> {42, bar()}
end
.fi
.LP
will be rewritten to:
.nf
case \&.\&.\&. of
\&.\&.\&. -> X = 17, Y = foo(), {X, Y};
\&.\&.\&. -> X = 42, Y = bar(), {X, Y}
end
.fi
.RE
.TP 4
.B
{auto_list_comp, bool()}:
If the value is \fItrue\fR, calls to \fIlists:map/2\fR and \fIlists:filter/2\fR will be rewritten using list comprehensions\&. The default value is \fItrue\fR\&.
.TP 4
.B
{file, string()}:
Specifies the name of the file from which the source code was taken\&. This is only used for generation of error reports\&. The default value is the empty string\&.
.TP 4
.B
{idem, bool()}:
If the value is \fItrue\fR, all options that affect how the code is modified are set to "no changes"\&. For example, to only update guard tests, and nothing else, use the options \fI[new_guard_tests, idem]\fR\&. (Recall that options closer to the beginning of the list have higher precedence\&.)
.TP 4
.B
{keep_unused, bool()}:
If the value is \fItrue\fR, unused functions will not be removed from the code\&. The default value is \fIfalse\fR\&.
.TP 4
.B
{new_guard_tests, bool()}:
If the value is \fItrue\fR, guard tests will be updated to use the new names, e\&.g\&. "\fIis_integer(X)\fR" instead of "\fIinteger(X)\fR"\&. The default value is \fItrue\fR\&. See also \fIold_guard_tests\fR\&.
.TP 4
.B
{no_imports, bool()}:
If the value is \fItrue\fR, all import statements will be removed and calls to imported functions will be expanded to explicit remote calls\&. The default value is \fIfalse\fR\&.
.TP 4
.B
{old_guard_tests, bool()}:
If the value is \fItrue\fR, guard tests will be changed to use the old names instead of the new ones, e\&.g\&. "\fIinteger(X)\fR" instead of "\fIis_integer(X)\fR"\&. The default value is \fIfalse\fR\&. This option overrides the \fInew_guard_tests\fR option\&.
.TP 4
.B
{quiet, bool()}:
If the value is \fItrue\fR, all information messages and warning messages will be suppressed\&. The default value is \fIfalse\fR\&.
.TP 4
.B
{rename, [{{atom(), atom(), integer()}, {atom(), atom()}}]}:
The value is a list of pairs, associating tuples \fI{Module, Name, Arity}\fR with tuples \fI{NewModule, NewName}\fR, specifying renamings of calls to remote functions\&. By default, the value is the empty list\&.
.RS 4
.LP
.LP
The renaming affects only remote calls (also when disguised by import declarations); local calls within a module are not affected, and no function definitions are renamed\&. Since the arity cannot change, the new name is represented by \fI{NewModule, NewName}\fR only\&. Only calls matching the specified arity will match; multiple entries are necessary for renaming calls to functions that have the same module and function name, but different arities\&.
.LP
.LP
This option can also be used to override the default renaming of calls which use obsolete function names\&.
.RE
.TP 4
.B
{verbose, bool()}:
If the value is \fItrue\fR, progress messages will be output while the program is running, unless the \fIquiet\fR option is \fItrue\fR\&. The default value is \fIfalse\fR\&.
.RE
.RE
|