Pod-Parser
view release on metacpan or search on metacpan
t/pod/testp2pt.pl view on Meta::CPAN
package TestPodIncPlainText;
BEGIN {
use File::Basename;
use File::Spec;
use Cwd qw(abs_path);
push @INC, '..';
my $THISDIR = abs_path(dirname $0);
unshift @INC, $THISDIR;
require "testcmp.pl";
import TestCompare;
my $PARENTDIR = dirname $THISDIR;
push @INC, map { File::Spec->catfile($_, 'lib') } ($PARENTDIR, $THISDIR);
}
#use strict;
#use diagnostics;
use Carp;
use Exporter;
#use File::Compare;
#use Cwd qw(abs_path);
use vars qw($MYPKG @EXPORT @ISA);
$MYPKG = eval { (caller)[0] };
@EXPORT = qw(&testpodplaintext);
BEGIN {
require Pod::PlainText;
@ISA = qw( Pod::PlainText );
require VMS::Filespec if $^O eq 'VMS';
}
## Hardcode settings for TERMCAP and COLUMNS so we can try to get
## reproducible results between environments
@ENV{qw(TERMCAP COLUMNS)} = ('co=76:do=^J', 76);
sub catfile(@) { File::Spec->catfile(@_); }
my $INSTDIR = abs_path(dirname $0);
$INSTDIR = VMS::Filespec::unixpath($INSTDIR) if $^O eq 'VMS';
$INSTDIR =~ s#/$## if $^O eq 'VMS';
$INSTDIR =~ s#:$## if $^O eq 'MacOS';
$INSTDIR = (dirname $INSTDIR) if (basename($INSTDIR) eq 'pod');
$INSTDIR =~ s#:$## if $^O eq 'MacOS';
$INSTDIR = (dirname $INSTDIR) if (basename($INSTDIR) eq 't');
my @PODINCDIRS = ( catfile($INSTDIR, 'lib', 'Pod'),
catfile($INSTDIR, 'scripts'),
catfile($INSTDIR, 'pod'),
catfile($INSTDIR, 't', 'pod')
);
# FIXME - we should make the core capable of finding utilities built in
# locations in ext.
push @PODINCDIRS, catfile((File::Spec->updir()) x 2, 'pod') if $ENV{PERL_CORE};
## Find the path to the file to =include
sub findinclude {
my $self = shift;
my $incname = shift;
## See if its already found w/out any "searching;
return $incname if (-r $incname);
## Need to search for it. Look in the following directories ...
## 1. the directory containing this pod file
my $thispoddir = dirname $self->input_file;
## 2. the parent directory of the above
my $parentdir = dirname $thispoddir;
my @podincdirs = ($thispoddir, $parentdir, @PODINCDIRS);
for (@podincdirs) {
my $incfile = catfile($_, $incname);
return $incfile if (-r $incfile);
}
warn("*** Can't find =include file $incname in @podincdirs\n");
return "";
}
sub command {
my $self = shift;
my ($cmd, $text, $line_num, $pod_para) = @_;
$cmd = '' unless (defined $cmd);
local $_ = $text || '';
my $out_fh = $self->output_handle;
( run in 0.892 second using v1.01-cache-2.11-cpan-aadc1410aed )