]> git.donarmstrong.com Git - perltidy.git/blobdiff - docs/perltidy.1
* New upstream release
[perltidy.git] / docs / perltidy.1
index fe868c49a063518db245d5edd277ea9d0e49a190..746af7292200990a2cd84d0f15b5d635d1d6c9cf 100644 (file)
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05)
+.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.07)
 .\"
 .\" Standard preamble:
 .\" ========================================================================
 .\" ========================================================================
 .\"
 .IX Title "PERLTIDY 1"
-.TH PERLTIDY 1 "2010-12-13" "perl v5.10.0" "User Contributed Perl Documentation"
+.TH PERLTIDY 1 "2012-06-29" "perl v5.10.1" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -170,7 +170,7 @@ formatter which is described in \*(L"\s-1HTML\s0 \s-1OPTIONS\s0\*(R".
 .PP
 This will produce a file \fIsomefile.pl.tdy\fR containing the script reformatted
 using the default options, which approximate the style suggested in 
-\&\fIperlstyle\fR\|(1).  Perltidy never changes the input file.
+\&\fIperlstyle\fR\|(1).  The source file \fIsomefile.pl\fR is unchanged.
 .PP
 .Vb 1
 \&  perltidy *.pl
@@ -354,15 +354,40 @@ or if it is being specified explicitly with the \fB\-o=s\fR parameter.
 .IP "\fB\-b\fR,    \fB\-\-backup\-and\-modify\-in\-place\fR" 4
 .IX Item "-b,    --backup-and-modify-in-place"
 Modify the input file or files in-place and save the original with the
-extension \fI.bak\fR.  Any existing \fI.bak\fR file will be deleted.  See next item
-for changing the default backup extension.
+extension \fI.bak\fR.  Any existing \fI.bak\fR file will be deleted.  See next
+item for changing the default backup extension, and for eliminating the
+backup file altogether.
 .Sp
 A \fB\-b\fR flag will be ignored if input is from standard input, or
 if the \fB\-html\fR flag is set.
 .IP "\fB\-bext\fR=ext,    \fB\-\-backup\-file\-extension\fR=ext" 4
 .IX Item "-bext=ext,    --backup-file-extension=ext"
-Change the extension of the backup file to be something other than the
-default \fI.bak\fR.  See \*(L"Specifying File Extensions\*(R".
+This parameter serves two purposes: (1) to change the extension of the backup
+file to be something other than the default \fI.bak\fR, and (2) to indicate
+that no backup file should be saved.
+.Sp
+To change the default extension to something other than \fI.bak\fR see
+\&\*(L"Specifying File Extensions\*(R".
+.Sp
+A backup file of the source is always written, but you can request that it
+be deleted at the end of processing if there were no errors.  This is risky
+unless the source code is being maintained with a source code control
+system.
+.Sp
+To indicate that the backup should be deleted include one forward slash,
+\&\fB/\fR, in the extension.  If any text remains after the slash is removed
+it will be used to define the backup file extension (which is always
+created and only deleted if there were no errors).
+.Sp
+Here are some examples:
+.Sp
+.Vb 5
+\&  Parameter           Extension          Backup File Treatment
+\&  <\-bext=bak>         F<.bak>            Keep (same as the default behavior)
+\&  <\-bext=\*(Aq/\*(Aq>         F<.bak>            Delete if no errors
+\&  <\-bext=\*(Aq/backup\*(Aq>   F<.backup>         Delete if no errors
+\&  <\-bext=\*(Aqoriginal/\*(Aq> F<.original>       Delete if no errors
+.Ve
 .IP "\fB\-w\fR,    \fB\-\-warning\-output\fR" 4
 .IX Item "-w,    --warning-output"
 Setting \fB\-w\fR causes any non-critical warning
@@ -506,7 +531,7 @@ opinion\*(R".
 If perl reports errors in the input file, they will not be reported in
 the error output unless the \fB\-\-warning\-output\fR flag is given.
 .Sp
-The default is \fBnot\fR to do this type of syntax checking (although
+The default is \fB\s-1NOT\s0\fR to do this type of syntax checking (although
 perltidy will still do as much self-checking as possible).  The reason
 is that it causes all code in \s-1BEGIN\s0 blocks to be executed, for all
 modules being used, and this opens the door to security issues and
@@ -558,13 +583,16 @@ revert to the default behavior of using the line ending of the host system.
 .IP "\fB\-it=n\fR,   \fB\-\-iterations=n\fR" 4
 .IX Item "-it=n,   --iterations=n"
 This flag causes perltidy to do \fBn\fR complete iterations.  The reason for this
-flag is that code beautification is a somewhat iterative process and in some
+flag is that code beautification is an iterative process and in some
 cases the output from perltidy can be different if it is applied a second time.
 For most purposes the default of \fBn=1\fR should be satisfactory.  However \fBn=2\fR
 can be useful when a major style change is being made, or when code is being
-beautified on check-in to a source code control system.  The run time will be
-approximately proportional to \fBn\fR, and it should seldom be necessary to use a
-value greater than \fBn=2\fR.  This flag has no effect when perltidy is used to generate html.
+beautified on check-in to a source code control system.  It has been found to
+be extremely rare for the output to change after 2 iterations.  If a value
+\&\fBn\fR is greater than 2 is input then a convergence test will be used to stop
+the iterations as soon as possible, almost always after 2 iterations.
+.Sp
+This flag has no effect when perltidy is used to generate html.
 .SS "Code Indentation Control"
 .IX Subsection "Code Indentation Control"
 .IP "\fB\-ci=n\fR, \fB\-\-continuation\-indentation=n\fR" 4
@@ -595,8 +623,19 @@ spaces assigned to a full indentation level on the \fB\-i=n\fR command.
 .IX Item "-sil=n --starting-indentation-level=n"
 By default, perltidy examines the input file and tries to determine the
 starting indentation level.  While it is often zero, it may not be
-zero for a code snippet being sent from an editing session.  If the
-default method does not work correctly, or you want to change the
+zero for a code snippet being sent from an editing session.
+.Sp
+To guess the starting indentation level perltidy simply assumes that
+indentation scheme used to create the code snippet is the same as is being used
+for the current perltidy process.  This is the only sensible guess that can be
+made.  It should be correct if this is true, but otherwise it probably won't.
+For example, if the input script was written with \-i=2 and the current peltidy
+flags have \-i=4, the wrong initial indentation will be guessed for a code
+snippet which has non-zero initial indentation. Likewise, if an entabbing
+scheme is used in the input script and not in the current process then the
+guessed indentation will be wrong.
+.Sp
+If the default method does not work correctly, or you want to change the
 starting level, use \fB\-sil=n\fR, to force the starting level to be n.
 .IP "List indentation using \fB\-lp\fR, \fB\-\-line\-up\-parentheses\fR" 4
 .IX Item "List indentation using -lp, --line-up-parentheses"
@@ -954,6 +993,13 @@ where \fBs\fR is a list of keywords (in quotes if necessary).  For example,
 \&  my( $a, $b, $c ) = @_;     # \-nsak="my local our"
 .Ve
 .Sp
+The abbreviation \fB\-nsak='*'\fR is equivalent to including all of the
+keywords in the above list.
+.Sp
+When both \fB\-nsak=s\fR and \fB\-sak=s\fR commands are included, the \fB\-nsak=s\fR
+command is executed first.  For example, to have space after only the
+keywords (my, local, our) you could use \fB\-nsak=\*(L"*\*(R" \-sak=\*(L"my local our\*(R"\fR.
+.Sp
 To put a space after all keywords, see the next item.
 .IP "Space between all keywords and opening parens" 4
 .IX Item "Space between all keywords and opening parens"
@@ -2114,6 +2160,23 @@ retaining these breakpoints.
 By default, if a conditional (ternary) operator is broken at a \f(CW\*(C`:\*(C'\fR,
 then it will remain broken.  To prevent this, and thereby
 form longer lines, use \fB\-nbot\fR.
+.IP "\fB\-boa\fR,  \fB\-\-break\-at\-old\-attribute\-breakpoints\fR" 4
+.IX Item "-boa,  --break-at-old-attribute-breakpoints"
+By default, if an attribute list is broken at a \f(CW\*(C`:\*(C'\fR in the source file, then
+it will remain broken.  For example, given the following code, the line breaks
+at the ':'s will be retained:
+.Sp
+.Vb 4
+\&                    my @field
+\&                      : field
+\&                      : Default(1)
+\&                      : Get(\*(AqName\*(Aq => \*(Aqfoo\*(Aq) : Set(\*(AqName\*(Aq);
+.Ve
+.Sp
+If the attributes are on a single line in the source code then they will remain
+on a single line if possible.
+.Sp
+To prevent this, and thereby always form longer lines, use \fB\-nboa\fR.
 .IP "\fB\-iob\fR,  \fB\-\-ignore\-old\-breakpoints\fR" 4
 .IX Item "-iob,  --ignore-old-breakpoints"
 Use this flag to tell perltidy to ignore existing line breaks to the
@@ -2169,14 +2232,42 @@ is equivalent to setting \fB\-mbl=0\fR and \fB\-kbl=2\fR).
 A blank line will be introduced before a full-line comment.  This is the
 default.  Use \fB\-nbbc\fR or  \fB\-\-noblanks\-before\-comments\fR to prevent
 such blank lines from being introduced.
+.IP "\fB\-blbs=n\fR,  \fB\-\-blank\-lines\-before\-subs=n\fR" 4
+.IX Item "-blbs=n,  --blank-lines-before-subs=n"
+The parameter \fB\-blbs=n\fR requests that least \fBn\fR blank lines precede a sub
+definition which does not follow a comment and which is more than one-line
+long.  The default is <\-blbs=1>.  \fB\s-1BEGIN\s0\fR and \fB\s-1END\s0\fR blocks are included.
+.Sp
+The requested number of blanks statement will be inserted regardless of of the
+value of \fB\-\-maximum\-consecutive\-blank\-lines=n\fR (\fB\-mbl=n\fR) with the exception
+that if \fB\-mbl=0\fR then no blanks will be output.
+.Sp
+This parameter interacts with the value \fBk\fR of the parameter \fB\-\-maximum\-consecutive\-blank\-lines=k\fR (\fB\-mbl=k\fR) as follows:
+.Sp
+1. If \fB\-mbl=0\fR then no blanks will be output.  This allows all blanks to be suppressed with a single parameter.  Otherwise,
+.Sp
+2. If the number of old blank lines in the script is less than \fBn\fR then
+additional blanks will be inserted to make the total \fBn\fR regardless of the
+value of \fB\-mbl=k\fR.
+.Sp
+3. If the number of old blank lines in the script equals or exceeds \fBn\fR then
+this parameter has no effect, however the total will not exceed
+value specified on the \fB\-mbl=k\fR flag.
+.IP "\fB\-blbp=n\fR,  \fB\-\-blank\-lines\-before\-packages=n\fR" 4
+.IX Item "-blbp=n,  --blank-lines-before-packages=n"
+The parameter \fB\-blbp=n\fR requests that least \fBn\fR blank lines precede a package
+which does not follow a comment.  The default is <\-blbp=1>.
+.Sp
+This parameter interacts with the value \fBk\fR of the parameter
+\&\fB\-\-maximum\-consecutive\-blank\-lines=k\fR (\fB\-mbl=k\fR) in the same way as described
+for the previous item \fB\-blbs=n\fR.
 .IP "\fB\-bbs\fR,  \fB\-\-blanks\-before\-subs\fR" 4
 .IX Item "-bbs,  --blanks-before-subs"
-A blank line will be introduced before a \fBsub\fR definition, unless it is a
-one-liner or preceded by a comment.  A blank line will also be introduced
-before a \fBpackage\fR statement and a \fB\s-1BEGIN\s0\fR and \fB\s-1END\s0\fR block.  This is the
-default.  The intention is to help display the structure of a program by
-setting off certain key sections of code.  This is negated with \fB\-nbbs\fR or
-\&\fB\-\-noblanks\-before\-subs\fR.
+For compatability with previous versions, \fB\-bbs\fR or \fB\-\-blanks\-before\-subs\fR 
+is equivalent to \fI\-blbp=1\fR and \fI\-blbs=1\fR.
+.Sp
+Likewise, \fB\-nbbs\fR or \fB\-\-noblanks\-before\-subs\fR 
+is equivalent to \fI\-blbp=0\fR and \fI\-blbs=0\fR.
 .IP "\fB\-bbb\fR,  \fB\-\-blanks\-before\-blocks\fR" 4
 .IX Item "-bbb,  --blanks-before-blocks"
 A blank line will be introduced before blocks of coding delimited by
@@ -2204,13 +2295,12 @@ certain block types (see previous section).  The default is 8.  Entering
 a value of \fB0\fR is equivalent to entering a very large number.
 .IP "\fB\-mbl=n\fR \fB\-\-maximum\-consecutive\-blank\-lines=n\fR" 4
 .IX Item "-mbl=n --maximum-consecutive-blank-lines=n"
-This parameter specifies the maximum number of consecutive
-blank lines which will be output within code sections of a
-script.  The default is n=1.  If the input file has more
-than n consecutive blank lines, the number will be reduced
-to n.  If \fBn=0\fR then no blank lines will be output (unless
-all old blank lines are retained with the \fB\-kbl=2\fR flag of
-the next section).
+This parameter specifies the maximum number of consecutive blank lines which
+will be output within code sections of a script.  The default is n=1.  If the
+input file has more than n consecutive blank lines, the number will be reduced
+to n except as noted above for the \fB\-blbp\fR and \fB\-blbs\fR parameters.  If \fBn=0\fR
+then no blank lines will be output (unless all old blank lines are retained
+with the \fB\-kbl=2\fR flag of the next section).
 .Sp
 This flag obviously does not apply to pod sections,
 here-documents, and quotes.
@@ -2335,8 +2425,9 @@ Ex.  PERLTIDY=C:\eDocuments and Settings\eperltidy.ini
 The configuation file is free format, and simply a list of parameters, just as
 they would be entered on a command line.  Any number of lines may be used, with
 any number of parameters per line, although it may be easiest to read with one
-parameter per line.  Blank lines are ignored, and text after a '#' is ignored
-to the end of a line.
+parameter per line.  Comment text begins with a #, and there must
+also be a space before the # for side comments.  It is a good idea to
+put complex parameters in either single or double quotes.
 .Sp
 Here is an example of a \fI.perltidyrc\fR file:
 .Sp
@@ -2902,7 +2993,7 @@ purpose of this rule is to prevent generating confusing filenames such as
 \&\fIperlstyle\fR\|(1), \fIPerl::Tidy\fR\|(3)
 .SH "VERSION"
 .IX Header "VERSION"
-This man page documents perltidy version 20101217.
+This man page documents perltidy version 20120701.
 .SH "CREDITS"
 .IX Header "CREDITS"
 Michael Cartmell supplied code for adaptation to \s-1VMS\s0 and helped with