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