Wrap argument lists in perl{api,intern}.pod
authorFather Chrysostomos <sprout@cpan.org>
Sat, 16 Jul 2011 05:06:49 +0000 (22:06 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 16 Jul 2011 05:07:32 +0000 (22:07 -0700)
autodoc.pl
t/porting/known_pod_issues.dat

index 139c313..4c1d962 100644 (file)
@@ -186,14 +186,36 @@ removed without notice.\n\n" if $flags =~ /x/;
        print $fh "\t\t$name;\n\n";
     } elsif ($flags =~ /n/) { # no args
        print $fh "\t$ret\t$name\n\n";
-    } elsif ($flags =~ /o/) { # no #define foo Perl_foo
-        print $fh "\t$ret\tPerl_$name";
-        print $fh "(" . (@args ? "pTHX_ " : "pTHX");
-        print $fh join(", ", @args) . ")\n\n";
     } else { # full usage
-       print $fh "\t$ret\t$name";
-       print $fh "(" . join(", ", @args) . ")";
-       print $fh "\n\n";
+       my $p            = $flags =~ /o/; # no #define foo Perl_foo
+       my $n            = "Perl_"x$p . $name;
+       my $large_ret    = length $ret > 7;
+       my $indent_size  = 7+8 # nroff: 7 under =head + 8 under =item
+                         +8+($large_ret ? 1 + length $ret : 8)
+                         +length($n) + 1;
+       my $indent;
+       print $fh "\t$ret" . ($large_ret ? ' ' : "\t") . "$n(";
+       my $args = $p ? @args ? "pTHX_ " : "pTHX" : '';
+       my $first = 1;
+       while () {
+           if (!@args or
+                length $args
+                && $indent_size + 3 + length($args[0]) + length $args > 80
+           ) {
+               print $fh
+                 $first ? '' : (
+                   $indent //=
+                      "\t".($large_ret ? " " x (1+length $ret) : "\t")
+                     ." "x(1 + length $n)
+                 ),
+                 $args, (","x($args ne 'pTHX_ ') . "\n")x!!@args;
+               $args = $first = '';
+           }
+           @args or last;
+           $args .= ", "x!!(length $args && $args ne 'pTHX_ ')
+                  . shift @args;
+       }
+       print $fh ")\n\n";
     }
     print $fh "=for hackers\nFound in file $file\n\n";
 }
index 1c02a98..b480189 100644 (file)
@@ -211,7 +211,7 @@ os2/os2/os2-rexx/rexx.pm    Verbatim line length including indents exceeds 80 by    1
 pod/perl.pod   Verbatim line length including indents exceeds 80 by    9
 pod/perlaix.pod        Verbatim line length including indents exceeds 80 by    11
 pod/perlapi.pod        ? Should you be using L<...> instead of 86
-pod/perlapi.pod        Verbatim line length including indents exceeds 80 by    154
+pod/perlapi.pod        Verbatim line length including indents exceeds 80 by    24
 pod/perlapi.pod        unresolved internal link        3
 pod/perlapio.pod       Verbatim line length including indents exceeds 80 by    5
 pod/perlbeos.pod       ? Should you be using F<...> or maybe L<...> instead of 5
@@ -246,7 +246,7 @@ pod/perlhist.pod    Verbatim line length including indents exceeds 80 by    2
 pod/perlhpux.pod       Verbatim line length including indents exceeds 80 by    2
 pod/perlhurd.pod       Verbatim line length including indents exceeds 80 by    2
 pod/perlintern.pod     ? Should you be using L<...> instead of 5
-pod/perlintern.pod     Verbatim line length including indents exceeds 80 by    22
+pod/perlintern.pod     Verbatim line length including indents exceeds 80 by    17
 pod/perlinterp.pod     ? Should you be using L<...> instead of 1
 pod/perlinterp.pod     Verbatim line length including indents exceeds 80 by    1
 pod/perlintro.pod      Verbatim line length including indents exceeds 80 by    11