/usr/share/perl5/Pod/PseudoPod/Index.pm is in libpod-pseudopod-perl 0.18-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 120 121 122 123 124 125 126 127 128 129 130 131 132 | package Pod::PseudoPod::Index;
use strict;
use Carp ();
use base qw( Pod::PseudoPod );
use vars qw( $VERSION );
$VERSION = '0.18';
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sub new {
my $self = shift;
my $index = shift;
my $new = $self->SUPER::new(@_);
$new->{'output_fh'} ||= *STDOUT{IO};
$new->accept_targets_as_text( qw(author blockquote comment caution
editor epigraph example figure important note production
programlisting screen sidebar table tip warning) );
$new->nix_Z_codes(1);
$new->{'index'} = $index || {};
$new->{'scratch'} = '';
$new->{'Indent'} = 0;
$new->{'Indentstring'} = ' ';
return $new;
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sub start_X { $_[0]{'X'} = 1; }
sub end_X {
my $self = shift;
my $text = $self->{'scratch'};
$self->{'scratch'} = '';
my $cross_ref = $self->{'index_file'} || $self->set_filename;
&_build_index($self->{'index'},$cross_ref,split(';', $text));
$self->{'X'} = 0;
}
sub _build_index {
my ($node,$cross_ref,@elems) = @_;
foreach my $entry (@elems,undef) {
if (defined $entry) {
$node->{$entry} = {} unless (defined $node->{$entry});
$node = $node->{$entry};
} else {
$node->{'page'} = [] unless (defined $node->{'page'});
push @{$node->{'page'}}, $cross_ref;
}
}
}
sub handle_text { $_[0]{'scratch'} .= $_[1] if $_[0]{'X'}; }
sub get_index { return $_[0]{'index'} }
sub output_text {
my $self = shift;
$self->_print_index($self->{'index'},'');
print {$self->{'output_fh'}} $self->{'scratch'};
}
# recursively print out index tree structure
sub _print_index {
my ($self,$node,$indent) = @_;
foreach my $key (sort {lc($a) cmp lc($b)} keys %{$node}) {
if ($key eq 'page') {
$self->{'scratch'} .= ', '. join(", ", @{$node->{'page'}});
} else {
$self->{'scratch'} .= "\n". $indent. $key;
$self->_print_index($node->{$key}, $indent.' ');
}
}
}
sub set_filename {
my $self = shift;
my $file = $self->{'source_filename'} || '';
$file =~ /(\w+)\.pod$/;
$self->{'index_file'} = $1 || "0";
return $self->{'index_file'};
}
1;
__END__
=head1 NAME
Pod::PseudoPod::Index -- format PseudoPod index entries
=head1 SYNOPSIS
use Pod::PseudoPod::Index;
my $parser = Pod::PseudoPod::Index->new();
$parser->parse_file('path/to/file1.pod');
$parser->parse_file('path/to/file2.pod');
$parser->output_text;
=head1 DESCRIPTION
This class is a formatter that extracts index items from PseudoPod files
and renders them as plain text or html.
This is a subclass of L<Pod::PseudoPod> and inherits all its methods.
=head1 SEE ALSO
L<Pod::PseudoPod>
=head1 COPYRIGHT
Copyright (c) 2004 Allison Randal. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself. The full text of the license
can be found in the LICENSE file included with this module.
This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.
=head1 AUTHOR
Allison Randal <allison@perl.org>
=cut
|