Cleanup shebang lines of all maint/example scripts, remove from tests entirely
[dbsrgits/DBIx-Class.git] / maint / gen-pod-index.pl
CommitLineData
f54428ab 1#!/usr/bin/env perl
55a55d31 2
3# Originally by: Zbigniew Lukasiak, C<zz bb yy@gmail.com>
4# but refactored and modified to our nefarious purposes
5
6# XXX I'm not done refactoring this yet --blblack
7
8use strict;
9use warnings;
10
11use Pod::Coverage;
12use Data::Dumper;
13use File::Find::Rule;
14use File::Slurp;
15use Path::Class;
16use Template;
17
18# Convert filename to package name
19sub 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
28my @files = File::Find::Rule->file()->name('*.pm', '*.pod')->in('lib');
29
30my %docsyms;
31for 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
42my @lines;
43for my $sym (sort keys %docsyms){
44 for my $pac (sort keys %{$docsyms{$sym}}){
45 push @lines, {symbol => $sym, package => $pac};
46 }
47}
48
49my $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
60Method Index
61
62[% FOR line = lines %]
63L<[% line.symbol %] ([% line.package %])|[% line.package %]/[% line.symbol %]>
64[% END %]