package Pod
::Perldoc
::ToMan
;
# This class is unlike ToText.pm et al, because we're NOT paging thru
# the output in our particular format -- we make the output and
# then we run nroff (or whatever) on it, and then page thru the
# (plaintext) output of THAT!
use base
qw(Pod::Perldoc::BaseTo);
sub write_with_binmode
{ 0 }
sub output_extension
{ 'txt' }
sub __filter_nroff
{ shift->_perldoc_elem('__filter_nroff' , @_) }
sub __nroffer
{ shift->_perldoc_elem('__nroffer' , @_) }
sub __bindir
{ shift->_perldoc_elem('__bindir' , @_) }
sub __pod2man
{ shift->_perldoc_elem('__pod2man' , @_) }
sub __output_file
{ shift->_perldoc_elem('__output_file' , @_) }
sub center
{ shift->_perldoc_elem('center' , @_) }
sub date
{ shift->_perldoc_elem('date' , @_) }
sub fixed
{ shift->_perldoc_elem('fixed' , @_) }
sub fixedbold
{ shift->_perldoc_elem('fixedbold' , @_) }
sub fixeditalic
{ shift->_perldoc_elem('fixeditalic' , @_) }
sub fixedbolditalic
{ shift->_perldoc_elem('fixedbolditalic', @_) }
sub quotes
{ shift->_perldoc_elem('quotes' , @_) }
sub release
{ shift->_perldoc_elem('release' , @_) }
sub section
{ shift->_perldoc_elem('section' , @_) }
sub new
{ return bless {}, ref($_[0]) || $_[0] }
use File
::Spec
::Functions
qw(catfile);
my $render = $self->{'__nroffer'} || die "no nroffer set!?";
# turn the switches into CLIs
map qq{"--$_=$self->{$_}"},
($self->{'__bindir'} || die "no bindir set?!" ),
($self->{'__pod2man'} || die "no pod2man set?!" ),
# This is rarely needed, I think.
$pod2man = $self->{'__pod2man'} || die "no pod2man set?!";
die "Can't find a pod2man?! (". $self->{'__pod2man'} .")\nAborting"
my $command = "$pod2man $switches --lax $file | $render -man";
# no temp file, just a pipe!
# Thanks to Brendan O'Dea for contributing the following block
if(Pod
::Perldoc
::IS_Linux
and -t STDOUT
and my ($cols) = `stty -a` =~ m/\bcolumns\s+(\d+)/
$cols = $c > $cols - 2 ?
$c : $cols -2;
$command .= ' -rLL=' . (int $c) . 'n' if $cols > 80;
if(Pod
::Perldoc
::IS_Cygwin
) {
# I hear persistent reports that adding a -c switch to $render
# solves many people's problems. But I also hear that some mans
# don't have a -c switch, so that unconditionally adding it here
# would presumably be a Bad Thing -- sburke@cpan.org
$command .= " | col -x" if Pod
::Perldoc
::IS_HPUX
;
defined(&Pod
::Perldoc
::DEBUG
)
and Pod
::Perldoc
::DEBUG
()
and print "About to run $command\n";
if( $self->{'__filter_nroff'} ) {
defined(&Pod
::Perldoc
::DEBUG
)
and &Pod
::Perldoc
::DEBUG
()
and print "filter_nroff is set, so filtering...\n";
$rslt = $self->___Do_filter_nroff($rslt);
defined(&Pod
::Perldoc
::DEBUG
)
and Pod
::Perldoc
::DEBUG
()
and print "filter_nroff isn't set, so not filtering.\n";
defined(&Pod
::Perldoc
::DEBUG
)
and Pod
::Perldoc
::DEBUG
()
and print "Nonzero exit ($?) while running $command.\n",
"Falling back to Pod::Perldoc::ToPod\n ",
require Pod
::Perldoc
::ToPod
;
return Pod
::Perldoc
::ToPod
->new->parse_from_file(@_);
or die "Can't print to $$self{__output_file}: $!";
my @data = split /\n{2,}/, shift;
shift @data while @data and $data[0] !~ /\S/; # Go to header
shift @data if @data and $data[0] =~ /Contributed\s+Perl/; # Skip header
pop @data if @data and $data[-1] =~ /^\w/; # Skip footer, like
# 28/Jan/99 perl 5.005, patch 53 1
Pod::Perldoc::ToMan - let Perldoc render Pod as man pages
perldoc -o man Some::Modulename
This is a "plug-in" class that allows Perldoc to use
Pod::Man and C<nroff> for reading Pod pages.
The following options are supported: center, date, fixed, fixedbold,
fixeditalic, fixedbolditalic, quotes, release, section
(Those options are explained in L<Pod::Man>.)
perldoc -o man -w center:Pod Some::Modulename
This module may change to use a different pod-to-nroff formatter class
in the future, and this may change what options are supported.
L<Pod::Man>, L<Pod::Perldoc>, L<Pod::Perldoc::ToNroff>
=head1 COPYRIGHT AND DISCLAIMERS
Copyright (c) 2002,3,4 Sean M. Burke. All rights reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.
Sean M. Burke C<sburke@cpan.org>