Debian Codegraph @

maint/gen_pod_index

raw
1 #!/usr/bin/env perl
2
3 # Originally by: Zbigniew Lukasiak, C<zz bb [email protected]>
4 # but refactored and modified to our nefarious purposes
5
6 # XXX I'm not done refactoring this yet --blblack
7
8 use strict;
9 use warnings;
10
11 use Pod::Coverage;
12 use Data::Dumper;
13 use File::Find::Rule;
14 use File::Slurp;
15 use Path::Class;
16 use Template;
17
18 # Convert filename to package name
19 sub getpac {
20 my $file = shift;
21 my $filecont = read_file( $file );
22 $filecont =~ /package\s*(.*?);/s or return;
23 my $pac = $1;
24 $pac =~ /\s+(.*)$/;
25 return $1;
26 }
27
28 my @files = File::Find::Rule->file()->name('*.pm', '*.pod')->in('lib');
29
30 my %docsyms;
31 for my $file (@files){
32 my $package = getpac( $file ) or next;
33 my $pc = Pod::Coverage->new(package => $package);
34 my %allsyms = map {$_ => 1} $pc->_get_syms($package);
35 my $podarr = $pc->_get_pods();
36 next if !$podarr;
37 for my $sym (@{$podarr}){
38 $docsyms{$sym}{$package} = $file if $allsyms{$sym};
39 }
40 }
41
42 my @lines;
43 for my $sym (sort keys %docsyms){
44 for my $pac (sort keys %{$docsyms{$sym}}){
45 push @lines, {symbol => $sym, package => $pac};
46 }
47 }
48
49 my $tt = Template->new({})
50 || die Template->error(), "\n";
51
52 $tt->process(\*DATA, { lines => \@lines })
53 || die $tt->error(), "\n";
54
55
56 __DATA__
57
58 =head1 NAME
59
60 Method Index
61
62 [% FOR line = lines %]
63 L<[% line.symbol %] ([% line.package %])|[% line.package %]/[% line.symbol %]>
64 [% END %]