id: unsigned long is excessive for option bitmask
[oweals/busybox.git] / docs / autodocifier.pl
index 95c9f410f11f8aa83e50d739f149a2d081330057..576e31281c7d22845f780a381e73a79e831f9a67 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/perl -w
+# vi: set sw=4 ts=4:
 
 use strict;
 use Getopt::Long;
@@ -21,8 +22,13 @@ sub continuation {
 # regex && eval away unwanted strings from documentation
 sub beautify {
        my $text = shift;
-       $text =~ s/USAGE_NOT\w+\(.*?"\s*\)//sxg;
-       $text =~ s/USAGE_\w+\(\s*?(.*?)"\s*\)/$1"/sxg;
+       for (;;) {
+               my $text2 = $text;
+               $text =~ s/SKIP_\w+\(.*?"\s*\)//sxg;
+               $text =~ s/USE_\w+\(\s*?(.*?)"\s*\)/$1"/sxg;
+               $text =~ s/USAGE_\w+\(\s*?(.*?)"\s*\)/$1"/sxg;
+               last if ( $text2 eq $text );
+       }
        $text =~ s/"\s*"//sg;
        my @line = split("\n", $text);
        $text = join('',
@@ -31,6 +37,7 @@ sub beautify {
                        s/"\s*$//;
                        s/%/%%/g;
                        s/\$/\\\$/g;
+                       s/\@/\\\@/g;
                        eval qq[ sprintf(qq{$_}) ]
                } @line
        );
@@ -43,11 +50,13 @@ sub pod_for_usage {
        my $usage = shift;
 
        # Sigh.  Fixup the known odd-name applets.
+# Perhaps we can use some of APPLET_ODDNAME from include/applets.h ?
        $name =~ s/dpkg_deb/dpkg-deb/g;
        $name =~ s/fsck_minix/fsck.minix/g;
        $name =~ s/mkfs_minix/mkfs.minix/g;
        $name =~ s/run_parts/run-parts/g;
        $name =~ s/start_stop_daemon/start-stop-daemon/g;
+       $name =~ s/ether_wake/ether-wake/g;
 
        # make options bold
        my $trivial = $usage->{trivial};
@@ -87,6 +96,13 @@ sub pod_for_usage {
                        split("\n", $usage->{example})) . "\n\n"
                : "";
 
+       # Pad the name so that the applet name gets a line
+       # by itself in BusyBox.txt
+       my $spaces = 10 - length($name);
+       if ($spaces > 0) {
+               $name .= " " x $spaces;
+       }
+
        return
                "=item B<$name>".
                "\n\n$name $trivial\n\n".
@@ -155,14 +171,15 @@ foreach (@ARGV) {
 my $generator = \&pod_for_usage;
 
 my @names = sort keys %docs;
-print "\t[, [[, ";
+my $line = "\t[, [[, ";
 for (my $i = 0; $i < $#names; $i++) {
-       if (($i + 2) % 8 == 0) {
-               print "\n\t";
+       if (length ($line.$names[$i]) >= 65) {
+               print "$line\n\t";
+               $line = "";
        }
-       print "$names[$i], ";
+       $line .= "$names[$i], ";
 }
-print $names[-1];
+print $line . $names[-1];
 
 print "\n\n=head1 COMMAND DESCRIPTIONS\n";
 print "\n=over 4\n\n";
@@ -288,4 +305,3 @@ John BEPPU <b@ax9.org>
 
 =cut
 
-# $Id: autodocifier.pl,v 1.26 2004/04/06 15:26:25 andersen Exp $