Debian Codegraph @

podindex

raw
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use Pod::Index;
6 use Pod::Index::Builder;
7 use Getopt::Long;
8
9 my ($package, $help, $version);
10 my $ret = GetOptions(
11 'package=s' => \$package,
12 'version' => \$version,
13 'help' => \$help,
14 );
15
16 if ($version) {
17 print "Pod::Index version ", Pod::Index->VERSION, "\n";
18 exit;
19 } elsif (!$ret or $help or !@ARGV) {
20 print usage();
21 exit;
22 }
23
24 my $p = Pod::Index::Builder->new;
25
26 my @files = @ARGV;
27 if ($^O eq 'MSWin32') { # do our own globbing under Windows
28 @files = map glob, @files;
29 }
30
31 for my $file (@files) {
32 $p->parse_from_file($file);
33 }
34
35 if ($package) {
36 print "package $package;\n1;\n__DATA__\n";
37 }
38 $p->print_index;
39
40 sub usage {
41 <<USAGE;
42 $0 [options] <pod(s)>...
43
44 Reads pod(s) and prints an index to stdout. Options:
45
46 --package=PACKAGE precede the index by a perl package declaration
47 --help this help
48 --version print version number
49
50 USAGE
51 }
52
53 __END__
54
55
56 =head1 NAME
57
58 podindex - build index from pods
59
60 =head1 SYNOPSYS
61
62 podindex [options] <pod(s)>...
63
64 Reads pod(s) and prints an index to stdout. Options:
65
66 --package=PACKAGE precede the index by a perl package declaration
67 --help this help
68 --version print version number
69
70 =head1 DESCRIPTION
71
72 This is a simple wrapper script around L<Pod::Index::Builder>. It parses
73 the POD files given as arguments, finds all XE<lt>> entries, generates
74 an index and prints it to standard output.
75
76 =head1 OPTIONS
77
78 =over
79
80 =item package
81
82 If given, it will place the index in the __DATA__ section of a perl package.
83 For example,
84
85 podindex --package=perlindex perlop.pod
86
87 outputs something like this:
88
89 package perlindex;
90 1;
91 __DATA__
92 ! perlsyn 116 DESCRIPTION
93 ! perlop 207 Symbolic Unary Operators
94 != perlop 436 Equality Operators
95 !~ perlop 242 DESCRIPTION
96
97 This is used so that an index can be placed in @INC and found easily (See
98 L<Pod::Index::Search>).
99
100 =back
101
102 =head1 SEE ALSO
103
104 L<Pod::Index>,
105 L<Pod::Index::Builder>,
106 L<perlpod>
107
108 =head1 AUTHOR
109
110 Ivan Tubert-Brohman E<lt>[email protected]<gt>
111
112 =head1 COPYRIGHT
113
114 Copyright (c) 2005 Ivan Tubert-Brohman. All rights reserved. This program is
115 free software; you can redistribute it and/or modify it under the same terms as
116 Perl itself.
117
118 =cut
119