]> git.donarmstrong.com Git - perltidy.git/commitdiff
update man page: list of switches and -wn -vtc=2 example
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 7 Nov 2020 23:46:09 +0000 (15:46 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 7 Nov 2020 23:46:09 +0000 (15:46 -0800)
bin/perltidy
docs/perltidy.html
t/snippets/dump_negated_switches.pl [new file with mode: 0755]

index 3fc52778c9fccf85a7322e4797e9eaba3eae93ba..a9d9bf1084ba339085696bb9b1c3590e7fd01201 100755 (executable)
@@ -2420,6 +2420,16 @@ Here is an example illustrating a welded container within a welded containers:
             $m
         ) );
 
+The welded closing tokens are by default on a separate line but this can be
+modified with the B<-vtc=n> flag (described in the next section).  For example,
+the same example adding B<-vtc-2> is
+
+       # perltidy -wn -vtc=2
+        $x->badd( bmul(
+            $class->new( abs(
+                $sx * int( $xr->numify() ) & $sy * int( $yr->numify() ) ) ),
+            $m ) );
+
 This format option is quite general but there are some limitations.  
 
 One limitation is that any line length limit still applies and can cause long
@@ -4341,12 +4351,23 @@ dot is added, and the backup file will be F<somefile.pl~>  .
 The following list shows all short parameter names which allow a prefix
 'n' to produce the negated form:
 
- D    anl asc  aws  b    bbb bbc bbs  bl   bli  boc bok  bol  bot  ce
- csc  dac dbc  dcsc ddf  dln dnl dop  dp   dpro dsc dsm  dsn  dtt  dwls
- dwrs dws f    fll  frm  fs  hsc html ibc  icb  icp iob  isbc lal  log
- lp   lsl ohbr okw  ola  oll opr opt  osbr otr  ple  pod  pvl  q
- sbc  sbl schb scp  scsb sct se  sfp  sfs  skp  sob sohb sop  sosb sot
- ssc  st  sts  syn  t    tac tbc toc  tp   tqw  tsc w    x    bar  kis
+ D      anl    asbl   asc    ast    asu    aws    b      baa    baao   
+ bar    bbao   bbb    bbc    bbs    bl     bli    boa    boc    bok    
+ bol    bom    bos    bot    cblx   ce     conv   csc    cscb   cscw   
+ dac    dbc    dcbl   dcsc   ddf    dln    dnl    dop    dp     dpro   
+ dsc    dsm    dsn    dtt    dwls   dwrs   dws    f      fll    frm    
+ fs     fso    gcs    hbc    hbcm   hbco   hbh    hbhh   hbi    hbj    
+ hbk    hbm    hbn    hbp    hbpd   hbpu   hbq    hbs    hbsc   hbv    
+ hbw    hent   hic    hicm   hico   hih    hihh   hii    hij    hik    
+ him    hin    hip    hipd   hipu   hiq    his    hisc   hiv    hiw    
+ hsc    html   ibc    icb    icp    iob    isbc   iscl   kgb    kgbd   
+ kgbi   kis    lal    log    lop    lp     lsl    mem    nib    ohbr   
+ okw    ola    olc    oll    olq    opr    opt    osbc   osbr   otr    
+ ple    pod    pvl    q      sac    sbc    sbl    scbb   schb   scp    
+ scsb   sct    se     sfp    sfs    skp    sob    sobb   sohb   sop    
+ sosb   sot    ssc    st     sts    t      tac    tbc    toc    tp     
+ tqw    trp    ts     tsc    tso    vmll   w      wn     x      xci    
+ xs     
 
 Equivalently, the prefix 'no' or 'no-' on the corresponding long names may be
 used.
index 99f67b688ee87f6063740499097d92cc23e6052e..52c68cc32ca18ea81af2da4b627ffb9cc0865b9e 100644 (file)
             $m
         ) );</code></pre>
 
+<p>The welded closing tokens are by default on a separate line but this can be modified with the <b>-vtc=n</b> flag (described in the next section). For example, the same example adding <b>-vtc-2</b> is</p>
+
+<pre><code>        # perltidy -wn -vtc=2
+        $x-&gt;badd( bmul(
+            $class-&gt;new( abs(
+                $sx * int( $xr-&gt;numify() ) &amp; $sy * int( $yr-&gt;numify() ) ) ),
+            $m ) );</code></pre>
+
 <p>This format option is quite general but there are some limitations.</p>
 
 <p>One limitation is that any line length limit still applies and can cause long welded sections to be broken into multiple lines.</p>
 
 <p>The following list shows all short parameter names which allow a prefix &#39;n&#39; to produce the negated form:</p>
 
-<pre><code> D    anl asc  aws  b    bbb bbc bbs  bl   bli  boc bok  bol  bot  ce
- csc  dac dbc  dcsc ddf  dln dnl dop  dp   dpro dsc dsm  dsn  dtt  dwls
- dwrs dws f    fll  frm  fs  hsc html ibc  icb  icp iob  isbc lal  log
- lp   lsl ohbr okw  ola  oll opr opt  osbr otr  ple  pod  pvl  q
- sbc  sbl schb scp  scsb sct se  sfp  sfs  skp  sob sohb sop  sosb sot
- ssc  st  sts  syn  t    tac tbc toc  tp   tqw  tsc w    x    bar  kis</code></pre>
+<pre><code> D      anl    asbl   asc    ast    asu    aws    b      baa    baao   
+ bar    bbao   bbb    bbc    bbs    bl     bli    boa    boc    bok    
+ bol    bom    bos    bot    cblx   ce     conv   csc    cscb   cscw   
+ dac    dbc    dcbl   dcsc   ddf    dln    dnl    dop    dp     dpro   
+ dsc    dsm    dsn    dtt    dwls   dwrs   dws    f      fll    frm    
+ fs     fso    gcs    hbc    hbcm   hbco   hbh    hbhh   hbi    hbj    
+ hbk    hbm    hbn    hbp    hbpd   hbpu   hbq    hbs    hbsc   hbv    
+ hbw    hent   hic    hicm   hico   hih    hihh   hii    hij    hik    
+ him    hin    hip    hipd   hipu   hiq    his    hisc   hiv    hiw    
+ hsc    html   ibc    icb    icp    iob    isbc   iscl   kgb    kgbd   
+ kgbi   kis    lal    log    lop    lp     lsl    mem    nib    ohbr   
+ okw    ola    olc    oll    olq    opr    opt    osbc   osbr   otr    
+ ple    pod    pvl    q      sac    sbc    sbl    scbb   schb   scp    
+ scsb   sct    se     sfp    sfs    skp    sob    sobb   sohb   sop    
+ sosb   sot    ssc    st     sts    t      tac    tbc    toc    tp     
+ tqw    trp    ts     tsc    tso    vmll   w      wn     x      xci    
+ xs     </code></pre>
 
 <p>Equivalently, the prefix &#39;no&#39; or &#39;no-&#39; on the corresponding long names may be used.</p>
 
diff --git a/t/snippets/dump_negated_switches.pl b/t/snippets/dump_negated_switches.pl
new file mode 100755 (executable)
index 0000000..dbc8182
--- /dev/null
@@ -0,0 +1,125 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+
+# Dump a list of perltidy abbreviation flags which can be negated.
+# This list goes in the man page section near the bottom titled
+# SWITCHES WHICH MAY BE NEGATED
+
+# Get the long names which may be negated
+my $rlong_names = get_long_names();
+my @binary_long_names;
+foreach my $long_name ( @{$rlong_names} ) {
+    my ( $name, $flag, $type ) = ( "", "", "" );
+    $long_name =~ s/\s+$//;
+    if ( $long_name =~ /^([\w\-]+)([^\s]*)/ ) {
+        $name = $1;
+        $flag = $2;
+        $flag = "" unless $flag;
+        if ( $flag eq '!' ) { push @binary_long_names, $name }
+    }
+}
+
+# Get a list of all short names
+my $rshort_names = get_short_names();
+my %abbrev;
+foreach my $short_name ( @{$rshort_names} ) {
+    if ( $short_name =~ /^(\w+) --> ([\w\-]+)$/ ) {
+        my $short = $1;
+        my $long  = $2;
+        $abbrev{$long} = $short;
+    }
+}
+
+# delete these: -check-syntax or -syn is accepted but no longer does anything
+my @skip = qw(
+  check-syntax
+);
+foreach (@skip) {
+    if ( $abbrev{$_} ) { delete $abbrev{$_} }
+}
+
+
+# Select the short names which can be negated
+my @short_list;
+foreach my $long (@binary_long_names) {
+    my $short = $abbrev{$long};
+    if ( !defined($short) ) {
+        next;
+    }
+    push @short_list, $short;
+}
+
+# special aliases not obtained automatically
+my @special = qw(
+oll 
+dac
+tac
+html
+sob
+baa
+bbs
+kgb
+icp
+otr
+sot
+sct
+sac
+sobb
+conv
+);
+
+my $FIELD_WIDTH    = 6;
+my $WORDS_PER_LINE = 10;
+
+my $line  = " ";
+my $count = 0;
+foreach my $word ( sort (@short_list, @special) ) {
+    my $len = length($word);
+    my $nsp = $FIELD_WIDTH - $len + 1;
+    $word .= " " x $nsp;
+    $line .= $word;
+    $count++;
+    if ( $count == $WORDS_PER_LINE ) {
+        print "$line\n";
+        $count = 0;
+        $line  = " ";
+    }
+}
+print "$line\n";
+
+sub get_long_names {
+
+    # get latest parameters from perltidy
+    use File::Temp qw(tempfile);
+    my ( $fout, $tmpnam ) = File::Temp::tempfile();
+    if ( !$fout ) { die "cannot get tempfile\n" }
+    my @parameters;
+    system "perltidy --dump-long-names >$tmpnam";
+    open( IN, "<", $tmpnam ) || die "cannot open $tmpnam: $!\n";
+    while ( my $line = <IN> ) {
+        next if $line =~ /#/;
+        chomp $line, push @parameters, $line;
+    }
+    close IN;
+    unlink $tmpnam if ( -e $tmpnam );
+    return \@parameters;
+}
+
+sub get_short_names {
+
+    # get latest parameters from perltidy
+    use File::Temp qw(tempfile);
+    my ( $fout, $tmpnam ) = File::Temp::tempfile();
+    if ( !$fout ) { die "cannot get tempfile\n" }
+    my @parameters;
+    system "perltidy --dump-short-names >$tmpnam";
+    open( IN, "<", $tmpnam ) || die "cannot open $tmpnam: $!\n";
+    while ( my $line = <IN> ) {
+        next if $line =~ /#/;
+        chomp $line, push @parameters, $line;
+    }
+    close IN;
+    unlink $tmpnam if ( -e $tmpnam );
+    return \@parameters;
+}