AnnoCPAN-Perldoc

 view release on metacpan or  search on metacpan

lib/AnnoCPAN/Perldoc.pm  view on Meta::CPAN

require 5;
use 5.006;
package AnnoCPAN::Perldoc;
use strict;
use warnings;
use base 'Pod::Perldoc';

our $VERSION = '0.10';

sub maybe_generate_dynamic_pod {
    my($self, $found_things) = @_;

    if ($self->opt_f or $self->opt_q) {
        warn "Warning: -f and -q do not support annotations yet\n";
        return shift->SUPER::maybe_generate_dynamic_pod(@_);
    }

    my @dynamic_pod;
    
    $self->filter_pod($found_things, \@dynamic_pod);

    my ($buffd, $buffer) = $self->new_tempfile('pod', 'dyn');
    
    push @{ $self->{'temp_file_list'} }, $buffer;
     # I.e., it MIGHT be deleted at the end.
    
    print $buffd @dynamic_pod  or die "Can't print $buffer: $!";
    close $buffd        or die "Can't close $buffer: $!";
    
    @$found_things = $buffer;
      # Yes, so found_things never has more than one thing in
      #  it, by time we leave here
    
    $self->add_formatter_option('__filter_nroff' => 1);

    return;
}


sub filter_pod {
    my($self, $found_things, $pod) = @_;

    Pod::Perldoc::DEBUG > 2 and print "Search: @$found_things\n";

    my $file = shift @$found_things;
    open(F, "<", $file)               # "Funk is its own reward"
        or die("Can't open $file $!");

    Pod::Perldoc::DEBUG > 2 and
     print "Going to filter for $file\n";
    
    my $content = do { local $/; <F> };

    my ($filter_class) = 'AnnoCPAN::Perldoc::Filter';

    eval "require $filter_class";
    if($@) {
        die "Couldn't load filter class '$filter_class': $@\n";
    }

    my $filter = $filter_class->can('new')
        ? $filter_class->new
        : $filter_class
    ;

    @$pod = $filter->filter($content);

    close F  or die "Can't close $file $!";
    return;
}

1;

__END__



( run in 2.807 seconds using v1.01-cache-2.11-cpan-a49fcb8fa48 )