/usr/share/perl5/Pod/Tree/PerlFunc.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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | package Pod::Tree::PerlFunc;
use strict;
use warnings;
use Pod::Tree;
use Pod::Tree::HTML;
use Pod::Tree::PerlUtil;
our $VERSION = '1.25';
use base qw(Pod::Tree::PerlUtil);
sub new {
my ( $class, $perl_dir, $html_dir, $link_map, %options ) = @_;
my %defaults = (
bgcolor => '#ffffff',
text => '#000000'
);
my $options = { %defaults, %options, link_map => $link_map };
my $perl_func = {
perl_dir => $perl_dir,
html_dir => $html_dir,
pod_dir => 'pod',
func_dir => 'func',
page => 'perlfunc',
options => $options
};
bless $perl_func, $class;
}
sub scan {
my $perl_func = shift;
$perl_func->report1("scan");
$perl_func->load_tree;
$perl_func->scan_tree;
}
sub load_tree {
my $perl_func = shift;
my $perl_dir = $perl_func->{perl_dir};
my $pod_dir = $perl_func->{pod_dir};
my $page = $perl_func->{page};
my $source = "$perl_dir/$pod_dir/$page.pod";
my $win_source = "$perl_dir/lib/$pod_dir/$page.pod";
my $tree = Pod::Tree->new;
$tree->load_file($source) or # for building the doc set from a Perl distribution
$tree->load_file($win_source) or # for building the doc set from a Windows installation
die "Pod::Tree::PerlFunc::scan: Can't find $source or $win_source\n";
my $node = $tree->pop;
my $funcs = $node->get_children;
$perl_func->{tree} = $tree;
$perl_func->{funcs} = $funcs;
}
sub scan_tree {
my $perl_func = shift;
my $funcs = $perl_func->{funcs};
my @funcs = @$funcs;
my $link_map = $perl_func->{options}{link_map};
while (@funcs) {
my @items = Shift_Items( \@funcs );
my ( $func0, $file0 ) = Parse_Name( $items[0] );
for my $item (@items) {
my ( $func, $file ) = Parse_Name($item);
$perl_func->report2($func);
$perl_func->{index}{$func} = $file0;
$link_map->add_func( $file, $file0 );
}
}
}
sub index {
my $perl_func = shift;
$perl_func->report1("index");
$perl_func->add_links;
$perl_func->add_index;
my $tree = $perl_func->{tree};
my $html_dir = $perl_func->{html_dir};
my $pod_dir = $perl_func->{pod_dir};
my $page = $perl_func->{page};
my $options = $perl_func->{options};
$perl_func->mkdir("$html_dir/$pod_dir/");
$options->{link_map}->set_depth(1);
my $dest = "$html_dir/$pod_dir/$page.html";
my $html = Pod::Tree::HTML->new( $tree, $dest, %$options );
$html->translate;
}
sub add_links {
my $perl_func = shift;
my $tree = $perl_func->{tree};
$tree->walk( sub { $perl_func->_add_links(shift) } );
}
sub _add_links {
my ( $perl_func, $node ) = @_;
is_sequence $node or return 1;
$node->get_letter eq 'C' or return 1;
my ($func) = Parse_Name($node);
my $file = $perl_func->{index}{$func};
$file or return 1;
# :TRICKY: *replaces* the node in the tree
my $page = $perl_func->{page};
$_[1] = Pod::Tree::Node->link( $node, $page, $file );
0;
}
sub add_index {
my $perl_func = shift;
my %funcs;
my $index = $perl_func->{index};
for my $func ( sort keys %$index ) {
my $file = $index->{$func};
my $letter = substr( $func, 0, 1 );
push @{ $funcs{$letter} }, [ $func, $file ];
}
my $page = $perl_func->{page};
my @lines;
for my $letter ( sort keys %funcs ) {
my $funcs = $funcs{$letter};
my @links = map {"L<C<$_->[0]>|$page/$_->[1]>"} @$funcs;
my $line = join ", ", @links;
push @lines, $line;
}
my $pod = join "\n\n", @lines;
my $tree = Pod::Tree->new;
$tree->load_string($pod);
my $children = $tree->get_root->get_children;
$perl_func->{tree}->push(@$children);
}
sub translate {
my $perl_func = shift;
$perl_func->report1("translate");
my $html_dir = $perl_func->{html_dir};
my $pod_dir = $perl_func->{pod_dir};
my $func_dir = $perl_func->{func_dir};
$perl_func->mkdir("$html_dir/$pod_dir/$func_dir");
my $perl_dir = $perl_func->{perl_dir};
my $funcs = $perl_func->{funcs};
my $options = $perl_func->{options};
my $link_map = $options->{link_map};
$link_map->set_depth(2);
$link_map->force_func(1);
$options->{toc} = 0;
while (@$funcs) {
my @items = Shift_Items($funcs);
my ( $func, $file ) = Parse_Name( $items[0] );
$perl_func->report2("func/$file");
my $tree = Pod::Tree->new;
$tree->load_string("=head1 $func\n\n=over 4\n\n=back");
my $list = $tree->get_root->get_children->[1];
$list->set_children( \@items );
$list->_set_list_type;
$options->{title} = $func;
my $dest = "$html_dir/$pod_dir/$func_dir/$file.html";
my $html = Pod::Tree::HTML->new( $tree, $dest, %$options );
$html->translate;
}
$link_map->force_func(0);
}
sub Shift_Items {
my $funcs = shift;
my @items;
while (@$funcs) {
my $item = shift @$funcs;
push @items, $item;
@$funcs or last;
my ($func0) = Parse_Name($item);
my ($func1) = Parse_Name( $funcs->[0] );
my $sibs0 = $item->get_siblings;
$func0 eq $func1 or @$sibs0 == 0 or last;
}
@items;
}
sub Parse_Name {
my $item = shift;
my $text = $item->get_deep_text;
my @words = split m([^\w\-]+), $text;
my $func = $words[0];
my $file = $func;
$file =~ tr(A-Za-z0-9_-)()cd;
( $func, $file );
}
1
__END__
=head1 NAME
Pod::Tree::PerlFunc - translate F<perlfunc.pod> to HTML
=head1 SYNOPSIS
$perl_map = Pod::Tree::PerlMap->new;
$perl_func = Pod::Tree::PerlFunc->new($perl_dir, $HTML_dir, $perl_map, %opts);
$perl_func->scan;
$perl_func->index;
$perl_func->translate;
=head1 DESCRIPTION
C<Pod::Tree::PerlFunc> translates F<perlfunc.pod> to HTML.
It creates a separate HTML page for each function description in
F<perlfunc.pod>. The pages for the individual descriptions are
named after the function and written to a F<func/> subdirectory.
F<perlfunc.html> is generated as an index to all the pages in
F<func/>.
C<Pod::Tree::PerlFunc> generates and uses an index of the functions
that it finds in F<perlfunc.pod> to construct HTML links.
Other modules can also use this index.
=head1 METHODS
=over 4
=item I<$perl_func> = C<new> C<Pod::Tree::PerlFunc> I<$perl_dir>,
I<$HTML_dir>, I<$perl_map>, I<%options>
Creates and returns a new C<Pod::Tree::PerlFunc> object.
I<$perl_dir> is the root of the Perl source tree.
I<$HTML_dir> is the directory where HTML files will be written.
I<$perl_map> maps function names to URLs.
I<%options> are passed through to C<Pod::Tree::HTML>.
=item I<$perl_func>->C<scan>
Reads F<perlfunc.pod> and identifies all the functions in it.
Each function that is identified is entered into I<$perl_map>.
=item I<$perl_func>->C<index>
Generates a top-level index of all the functions.
The index is written to I<HTML_dir>C</pod/perlfunc.html>.
=item I<$perl_func>->C<translate>
Translates each function found by C<scan> to HTML.
The HTML pages are written to I<HTML_dir>C</pod/func/>.
=back
=head1 LINKING
C<Pod::Tree::PerlFunc> indexes every C<=item> paragraph in
F<perlfunc.html>. To link, for example, to the C<abs> function, write
L<func/abs>
=head1 REQUIRES
5.005;
Pod::Tree;
Pod::Tree::HTML;
Pod::Tree::PerlUtil;
=head1 EXPORTS
Nothing.
=head1 SEE ALSO
L<C<Pod::Tree::HTML>>, L<C<Pod::Tree::PerlMap>>,
=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 itself.
|