man-page-conversion-20051208
[openafs.git] / doc / man-pages / generate-file-map
1 #!/usr/bin/perl
2 #
3 # From an AFS Administrative Reference HTML page, try to figure out what
4 # command or file it corresponds to and output the appropriate generate-pod
5 # command.  Intended to be run as follows:
6 #
7 #     generate-file-map *.htm > generate-pods.sh
8 #
9 # Each line of the output will be a generate-pod invocation, saving its output
10 # to the appropriate POD file.
11
12 my %except = map { $_ => 1 }
13     ('Table of Contents', 'Audience and Purpose', 'Organization',
14      'How to Use This Document', 'Related Documents',
15      'Typographical Conventions');
16
17 for my $file (@ARGV) {
18     my $command;
19     open (IN, '<', $file) or die "$0: cannot open $file: $!\n";
20     while (<IN>) {
21         s/<I>//g;
22         s%</I>%%g;
23         if (/<H2><A [^>]+>([^<]+)/) {
24             $command = $1;
25             last;
26         }
27     }
28     if ($command) {
29         next if $except{$command};
30         next if $command =~ /\(AFS version\)/;
31         $command =~ s/,.*//;
32         $command =~ s/ and.*//;
33         $command =~ s/\s/_/g;
34         $command =~ s/([\(\)])/\\$1/g;
35         print "../../man-pages/generate-pod $file >"
36             ." ../../man-pages/pod/$command.pod\n";
37     }
38 }