/usr/share/perl5/Pod/Tree/PerlMap.pm is in libpod-tree-perl 1.25-1.
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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | package Pod::Tree::PerlMap;
use strict;
use warnings;
our $VERSION = '1.25';
sub new {
my ($class) = @_;
my $perl_map = { prefix => '' };
bless $perl_map, $class;
}
sub set_depth {
my ( $perl_map, $depth ) = @_;
$perl_map->{prefix} = '../' x $depth;
}
sub add_page {
my ( $perl_map, $page, $file ) = @_;
$perl_map->{page}{$page} = $file;
}
sub add_func {
my ( $perl_map, $func, $file ) = @_;
$perl_map->{func}{$func} = $file;
}
sub force_func {
my ( $perl_map, $force_func ) = @_;
$perl_map->{force_func} = $force_func;
}
sub map {
my ( $perl_map, $base, $page, $section ) = @_;
# print "map $base, $page, $section ->";
my $prefix = $perl_map->{prefix};
my $force_func = $perl_map->{force_func};
my $func = ( split m(\s+), $section )[0]; # e.g. L<"eval BLOCK">
my $file = $perl_map->{func}{$func};
if ( ( $page eq 'perlfunc' or $page eq '' and $force_func ) and $file ) {
$page = $prefix . 'pod/func/' . $file;
$section = '';
}
elsif ( $perl_map->{page}{$page} ) {
$page = $prefix . $perl_map->{page}{$page};
}
# print "$base, $page, $section\n";
( $base, $page, $section );
}
1
__END__
=head1 NAME
Pod::Tree::PerlMap - map names to URLs
=head1 SYNOPSIS
$perl_map = new Pod::Tree::PerlMap;
$perl_map->add_page ($name, $file);
$perl_map->add_func ($func, $file);
$perl_map->force_func(0);
$perl_map->force_func(1);
$perl_map->set_depth ($depth);
($base, $page, $section) = $perl_map->map($base, $page, $section);
=head1 DESCRIPTION
C<Pod::Tree::PerlMap> maps LE<lt>E<gt> markups to URLs.
The C<Pod::Tree::Perl*> translators make entries in the map.
C<Pod::Tree::HTML> uses the map to translate links before it emits
them.
=head1 METHODS
=over 4
=item I<$perl_map>->C<add_page>(I<$name>, I<$file>)
Map I<$name> to I<$file>.
I<$name> is the name of a POD, as used in LE<lt>E<gt> markups.
I<$file> is the path to the HTML file that is the target of the link.
=item I<$perl_map>->C<add_func>(I<$func>, I<$file>)
Maps I<$func> to I<$file>.
I<$func> is the name of a function described in F<perlfunc.pod>.
I<$file> is the name of the HTML file where it is described.
=item I<$perl_map>->C<force_func>(I<$state>)
Controls interpretation of links of the form LE<lt>funcE<gt>.
If I<$state> is true, calls to C<map> will interpret
LE<lt>funcE<gt> as LE<lt>perlfunc/funcE<gt>.
If I<$state> is false, calls to C<map> will interpret
LE<lt>funcE<gt> normally.
=item I<$perl_map>->C<set_depth>(I<$depth>)
Informs I<$perl_map> of the depth of the referring page in the HTML
directory tree.
I<$perl_map> needs to know this so that it can construct
relative links.
=item (I<$base>, I<$page>, I<$section>) =
I<$perl_map>->C<map>(I<$base>, I<$page>, I<$section>)
Remaps a link.
I<$base> is the base URL for the HTML page, if any.
I<$page> is the page given in an LE<lt>E<gt> markup.
I<$section> is the section given in the LE<lt>E<gt> markup, if any.
C<map> returns a new I<$base>, I<$page>, and I<$section>
that can be used to construct a link to the HTML page.
=back
=head1 REQUIRES
Nothing.
=head1 EXPORTS
Nothing.
=head1 AUTHOR
Steven McDougall, swmcd@world.std.com
=head1 COPYRIGHT
Copyright (c) 2000 by Steven McDougall. This module is free software;
you can redistribute it and/or modify it under the same terms as Perl.
|