3 package Pod::Perldoc::ToMan;
7 # This class is unlike ToText.pm et al, because we're NOT paging thru
8 # the output in that our particular format -- we make the output and
9 # then we run nroff (or whatever) on it, and then page thru the
10 # (plaintext) output of THAT!
12 use base qw(Pod::Perldoc::BaseTo);
14 sub write_with_binmode { 0 }
15 sub output_extension { 'txt' }
17 sub __filter_nroff { shift->_perldoc_elem('__filter_nroff' , @_) }
18 sub __nroffer { shift->_perldoc_elem('__nroffer' , @_) }
19 sub __bindir { shift->_perldoc_elem('__bindir' , @_) }
20 sub __pod2man { shift->_perldoc_elem('__pod2man' , @_) }
21 sub __output_file { shift->_perldoc_elem('__output_file' , @_) }
23 sub center { shift->_perldoc_elem('center' , @_) }
24 sub date { shift->_perldoc_elem('date' , @_) }
25 sub fixed { shift->_perldoc_elem('fixed' , @_) }
26 sub fixedbold { shift->_perldoc_elem('fixedbold' , @_) }
27 sub fixeditalic { shift->_perldoc_elem('fixeditalic' , @_) }
28 sub fixedbolditalic { shift->_perldoc_elem('fixedbolditalic', @_) }
29 sub quotes { shift->_perldoc_elem('quotes' , @_) }
30 sub release { shift->_perldoc_elem('release' , @_) }
31 sub section { shift->_perldoc_elem('section' , @_) }
33 sub new { return bless {}, ref($_[0]) || $_[0] }
35 use File::Spec::Functions qw(catfile);
39 my($file, $outfh) = @_;
41 my $render = $self->{'__nroffer'} || die "no nroffer set!?";
43 # turn the switches into CLIs
44 my $switches = join ' ',
45 map qq{"--$_=$self->{$_}"},
52 ($self->{'__bindir'} || die "no bindir set?!" ),
53 ($self->{'__pod2man'} || die "no pod2man set?!" ),
55 . " $switches --lax $file | $render -man"
56 ; # no temp file, just a pipe!
58 $command .= " | col -x" if $^O =~ /hpux/;
60 defined(&Pod::Perldoc::DEBUG)
61 and Pod::Perldoc::DEBUG()
62 and print "About to run $command\n";
65 my $rslt = `$command`;
69 if( $self->{'__filter_nroff'} ) {
70 defined(&Pod::Perldoc::DEBUG)
71 and &Pod::Perldoc::DEBUG()
72 and print "filter_nroff is set, so filtering...\n";
73 $rslt = $self->___Do_filter_nroff($rslt);
75 defined(&Pod::Perldoc::DEBUG)
76 and Pod::Perldoc::DEBUG()
77 and print "filter_nroff isn't set, so not filtering.\n";
81 defined(&Pod::Perldoc::DEBUG)
82 and Pod::Perldoc::DEBUG()
83 and print "Nonzero exit ($?) while running $command.\n",
84 "Falling back to Pod::Perldoc::ToPod\n ",
86 # A desperate fallthru:
87 require Pod::Perldoc::ToPod;
88 return Pod::Perldoc::ToPod->new->parse_from_file(@_);
92 or die "Can't print to $$self{__output_file}: $!";
99 sub ___Do_filter_nroff {
101 my @data = split /\n{2,}/, shift;
103 shift @data while @data and $data[0] !~ /\S/; # Go to header
104 shift @data if @data and $data[0] =~ /Contributed\s+Perl/; # Skip header
105 pop @data if @data and $data[-1] =~ /^\w/; # Skip footer, like
106 # 28/Jan/99 perl 5.005, patch 53 1
116 Pod::Perldoc::ToMan - let Perldoc render Pod as man pages
120 perldoc -o man Some::Modulename
124 This is a "plug-in" class that allows Perldoc to use
125 Pod::Man and C<nroff> for reading Pod pages.
127 The following options are supported: center, date, fixed, fixedbold,
128 fixeditalic, fixedbolditalic, quotes, release, section
130 (Those options are explained in L<Pod::Man>.)
134 perldoc -o man -w center:Pod Some::Modulename
138 This module may change to use a different pod-to-nroff formatter class
139 in the future, and this may change what options are supported.
143 L<Pod::Man>, L<Pod::Perldoc>, L<Pod::Perldoc::ToNroff>
145 =head1 COPYRIGHT AND DISCLAIMERS
147 Copyright (c) 2002 Sean M. Burke. All rights reserved.
149 This library is free software; you can redistribute it and/or modify it
150 under the same terms as Perl itself.
152 This program is distributed in the hope that it will be useful, but
153 without any warranty; without even the implied warranty of
154 merchantability or fitness for a particular purpose.
158 Sean M. Burke C<sburke@cpan.org>