File: podindex

package info (click to toggle)
libpod-index-perl 0.14-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 156 kB
  • sloc: perl: 419; makefile: 6
file content (119 lines) | stat: -rwxr-xr-x 2,321 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/perl

use strict;
use warnings;
use Pod::Index;
use Pod::Index::Builder;
use Getopt::Long;

my ($package, $help, $version);
my $ret = GetOptions(
   'package=s' => \$package,
   'version'   => \$version,
   'help'      => \$help,
);

if ($version) {
    print "Pod::Index version ", Pod::Index->VERSION, "\n";
    exit;
} elsif (!$ret or $help or !@ARGV) {
    print usage();
    exit;
}

my $p = Pod::Index::Builder->new;

my @files = @ARGV;
if ($^O eq 'MSWin32') { # do our own globbing under Windows
    @files = map glob, @files;
}

for my $file (@files) {
    $p->parse_from_file($file);
}

if ($package) {
    print "package $package;\n1;\n__DATA__\n";
}
$p->print_index;

sub usage {
    <<USAGE;
$0 [options] <pod(s)>...

Reads pod(s) and prints an index to stdout. Options:

    --package=PACKAGE   precede the index by a perl package declaration
    --help              this help
    --version           print version number

USAGE
}

__END__


=head1 NAME

podindex - build index from pods

=head1 SYNOPSYS

podindex [options] <pod(s)>...

Reads pod(s) and prints an index to stdout. Options:

    --package=PACKAGE   precede the index by a perl package declaration
    --help              this help
    --version           print version number

=head1 DESCRIPTION

This is a simple wrapper script around L<Pod::Index::Builder>. It parses
the POD files given as arguments, finds all XE<lt>> entries, generates
an index and prints it to standard output.

=head1 OPTIONS

=over

=item package

If given, it will place the index in the __DATA__ section of a perl package.
For example, 

    podindex --package=perlindex perlop.pod

outputs something like this:

        package perlindex;
        1;
        __DATA__
        !	perlsyn	116	DESCRIPTION
        !	perlop	207	Symbolic Unary Operators
        !=	perlop	436	Equality Operators
        !~	perlop	242	DESCRIPTION

This is used so that an index can be placed in @INC and found easily (See
L<Pod::Index::Search>).

=back

=head1 SEE ALSO

L<Pod::Index>,
L<Pod::Index::Builder>,
L<perlpod>

=head1 AUTHOR

Ivan Tubert-Brohman E<lt>itub@cpan.orgE<gt>

=head1 COPYRIGHT

Copyright (c) 2005 Ivan Tubert-Brohman. All rights reserved. This program is
free software; you can redistribute it and/or modify it under the same terms as
Perl itself.

=cut