Commit | Line | Data |
---|---|---|
cb1a09d0 AD |
1 | #!/usr/bin/perl |
2 | ||
6ec7a3ca PP |
3 | use lib '../lib'; # If you haven't installed perl yet. |
4 | use Pod::Functions; | |
cb1a09d0 AD |
5 | |
6 | local $/ = ''; | |
7 | ||
8 | $cur = ''; | |
9 | while (<>) { | |
10 | ||
11 | next unless /^=(?!cut)/ .. /^=cut/; | |
12 | ||
5b3c99c0 SH |
13 | if (/=item (\S+)/ and $1 ne '*') { |
14 | s/=item //; | |
cb1a09d0 | 15 | #$cur = "POSIX::" . $1; |
40d50c58 | 16 | $next{$cur} = $1; |
cb1a09d0 AD |
17 | $cur = $1; |
18 | $syn{$cur} .= $_; | |
19 | next; | |
20 | } else { | |
21 | #s,L</,L<POSIX/,g; | |
22 | s,L</,L<perlfunc/,g; | |
40d50c58 | 23 | push @{$pod{$cur}}, $_ if $cur; |
cb1a09d0 AD |
24 | } |
25 | } | |
26 | ||
27 | for $f ( keys %syn ) { | |
40d50c58 | 28 | next unless $Type{$f}; |
cb1a09d0 AD |
29 | $flavor = $Flavor{$f}; |
30 | $orig = $f; | |
31 | ($name = $f) =~ s/\W//g; | |
40d50c58 TB |
32 | |
33 | # deal with several functions sharing a description | |
34 | $func = $orig; | |
35 | $func = $next{$func} until $pod{$func}; | |
36 | my $body = join "", @{$pod{$func}}; | |
37 | ||
3e3baf6d | 38 | # deal with unbalanced =over and =back cause by the split |
3e3baf6d TB |
39 | my $has_over = $body =~ /^=over/; |
40 | my $has_back = $body =~ /^=back/; | |
41 | $body =~ s/^=over\s*//m if $has_over and !$has_back; | |
42 | $body =~ s/^=back\s*//m if $has_back and !$has_over; | |
cb1a09d0 AD |
43 | open (POD, "> $name.pod") || die "can't open $name.pod: $!"; |
44 | print POD <<EOF; | |
45 | =head1 NAME | |
46 | ||
47 | $orig - $flavor | |
48 | ||
49 | =head1 SYNOPSIS | |
50 | ||
51 | $syn{$orig} | |
52 | ||
53 | =head1 DESCRIPTION | |
54 | ||
3e3baf6d | 55 | $body |
cb1a09d0 AD |
56 | |
57 | EOF | |
58 | ||
59 | close POD; | |
60 | ||
61 | } |