% if ($method) {
% } else {
% }
% if (!$method) {
% return; % } % if ($method eq 'TOC') {
<& SELF:TOC &> % } else {
<& SELF:Body &> % } <%METHOD Body> <%PERL> my $n = $m->request_args->{n} || ''; my $dirname = File::Basename::dirname($INC{'RT.pm'}); $n =~ s/::/\//g; $n = 'RT' unless -r "$dirname/$n.pm"; my $show = "$dirname/$n"; if (-r "$show.pm") { local $/; my ($fh, $filename) = File::Temp::tempfile(); close $fh; my ($src_fh, $src_file) = File::Temp::tempfile(); my $got_name = 0; foreach my $postfix ('', '_Overlay', '_Vendor', '_Local') { next unless -r "$show$postfix.pm"; open $fh, "$show$postfix.pm" or next; my $body = <$fh>; if ($body =~ s/.*Create takes a hash of values and creates a row in the database:([^=]+)//s) { # okay, reduce it... $body = "=head1 SCHEMA\n\n$1\n=head1 ACCESSORS\n\n\n=cut\n$body"; $body =~ s/=item/=head2/g; } elsif ($body =~ /^=item NewItem$/m and $n =~ /s$/) { my $pkg = $n; $pkg =~ s{/}{::}g; chop $pkg; $body = "=head1 NAME\n\n${pkg}s - Collection of $pkg objects\n\n=cut\n"; $got_name++; } else { $body =~ s/^=head1 NAME[^=]+//m if $got_name; } $body =~ s/^=head1\b(?! ACCESSORS).*\s*(?==(head1|cut))//mg; $body =~ s/^=head1 (?:AUTHOR|SEE ALSO|SYNOPSIS)\s*[^=]+//mg; $body =~ s/^=/\n=/mg; $body =~ s/^=begin testing\n/=begin testing\n\n/mg; # print FOO $body; print $src_fh $body; close $fh; } close $src_fh; Pod::Html::pod2html( "--infile=$src_file", "--outfile=$filename", "--cachedir=" . File::Spec->tmpdir, ); open $fh, $filename; my $body = <$fh>; $body =~ s{.*?
]+>}{}s; $body =~ s{
\s*
\s*$}{}; $n =~ s{/}{::}g; $m->print("

# $n

"); $body =~ s/(?$1<\/a>/g; $body =~ s{(?$1}g; $body =~ s!\n\t

!

!; $body =~ s!

!

!; $body =~ s!

!!; $body =~ s!print($body); } <%ARGS> $Target => '&method=Body' <%METHOD TOC> <%PERL> my $dirname = File::Basename::dirname($INC{'RT.pm'}); my @found; File::Find::find( { wanted => sub { return unless /(\w+)\.pm$/; return if $1 =~ /_/; my $name = $File::Find::name; $name =~ s/.*lib\b.//; $name =~ s!\.pm!!i; $name =~ s!\W!::!g; push @found, $name; }, follow => ($^O ne 'MSWin32') }, $dirname, ); my ($prev, $indent); foreach my $file (sort @found) { my ($parent, $name) = ($1, $2) if $file =~ /(?:(.*)::)?(\w+)$/; if ($file =~ /^$prev\::(.*)/) { my $foo = $1; while ($foo =~ s/(\w+):://) { $indent++; $m->print((' ' x $indent)); $m->print("$1
"); } $indent++; } elsif ($prev !~ /^$parent\::/) { while ($parent =~ s/(\w+)//) { next if $prev =~ s/\b$1:://; while ($prev =~ s/:://) { $indent--; } $m->print((' ' x $indent)); $m->print("$1
"); $indent++; } } elsif ($prev =~ /^$parent\::(.*::)/) { my $foo = $1; while ($foo =~ s/:://) { $indent--; } } $m->print((' ' x $indent)); $m->print('print("href='Perldoc.html?n=$file$Target'>$name
"); $prev = $file; } <%ARGS> $Target => '&method=Body'
<%INIT> require File::Basename; require File::Find; require File::Temp; require File::Spec; require Pod::Html; <%ARGS> $n => '' $method => ''