xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Pod/Perldoc/ToPod.pm (revision 0:68f95e015346)
1*0Sstevel@tonic-gate
2*0Sstevel@tonic-gate# This class is just a hack to act as a "formatter" for
3*0Sstevel@tonic-gate# actually unformatted Pod.
4*0Sstevel@tonic-gate#
5*0Sstevel@tonic-gate# Note that this isn't the same as just passing thru whatever
6*0Sstevel@tonic-gate# we're given -- we pass thru only the pod source, and suppress
7*0Sstevel@tonic-gate# the Perl code (or whatever non-pod stuff is in the source file).
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gate
10*0Sstevel@tonic-gaterequire 5;
11*0Sstevel@tonic-gatepackage Pod::Perldoc::ToPod;
12*0Sstevel@tonic-gateuse strict;
13*0Sstevel@tonic-gateuse warnings;
14*0Sstevel@tonic-gate
15*0Sstevel@tonic-gateuse base qw(Pod::Perldoc::BaseTo);
16*0Sstevel@tonic-gatesub is_pageable        { 1 }
17*0Sstevel@tonic-gatesub write_with_binmode { 0 }
18*0Sstevel@tonic-gatesub output_extension   { 'pod' }
19*0Sstevel@tonic-gate
20*0Sstevel@tonic-gatesub new { return bless {}, ref($_[0]) || $_[0] }
21*0Sstevel@tonic-gate
22*0Sstevel@tonic-gatesub parse_from_file {
23*0Sstevel@tonic-gate  my( $self, $in, $outfh ) = @_;
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gate  open(IN, "<", $in) or die "Can't read-open $in: $!\nAborting";
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate  my $cut_mode = 1;
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate  # A hack for finding things between =foo and =cut, inclusive
30*0Sstevel@tonic-gate  local $_;
31*0Sstevel@tonic-gate  while (<IN>) {
32*0Sstevel@tonic-gate    if(  m/^=(\w+)/s ) {
33*0Sstevel@tonic-gate      if($cut_mode = ($1 eq 'cut')) {
34*0Sstevel@tonic-gate        print $outfh "\n=cut\n\n";
35*0Sstevel@tonic-gate         # Pass thru the =cut line with some harmless
36*0Sstevel@tonic-gate         #  (and occasionally helpful) padding
37*0Sstevel@tonic-gate      }
38*0Sstevel@tonic-gate    }
39*0Sstevel@tonic-gate    next if $cut_mode;
40*0Sstevel@tonic-gate    print $outfh $_ or die "Can't print to $outfh: $!";
41*0Sstevel@tonic-gate  }
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gate  close IN or die "Can't close $in: $!";
44*0Sstevel@tonic-gate  return;
45*0Sstevel@tonic-gate}
46*0Sstevel@tonic-gate
47*0Sstevel@tonic-gate1;
48*0Sstevel@tonic-gate__END__
49*0Sstevel@tonic-gate
50*0Sstevel@tonic-gate=head1 NAME
51*0Sstevel@tonic-gate
52*0Sstevel@tonic-gatePod::Perldoc::ToPod - let Perldoc render Pod as ... Pod!
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gate=head1 SYNOPSIS
55*0Sstevel@tonic-gate
56*0Sstevel@tonic-gate  perldoc -opod Some::Modulename
57*0Sstevel@tonic-gate
58*0Sstevel@tonic-gate(That's currently the same as the following:)
59*0Sstevel@tonic-gate
60*0Sstevel@tonic-gate  perldoc -u Some::Modulename
61*0Sstevel@tonic-gate
62*0Sstevel@tonic-gate=head1 DESCRIPTION
63*0Sstevel@tonic-gate
64*0Sstevel@tonic-gateThis is a "plug-in" class that allows Perldoc to display Pod source as
65*0Sstevel@tonic-gateitself!  Pretty Zen, huh?
66*0Sstevel@tonic-gate
67*0Sstevel@tonic-gateCurrently this class works by just filtering out the non-Pod stuff from
68*0Sstevel@tonic-gatea given input file.
69*0Sstevel@tonic-gate
70*0Sstevel@tonic-gate=head1 SEE ALSO
71*0Sstevel@tonic-gate
72*0Sstevel@tonic-gateL<Pod::Perldoc>
73*0Sstevel@tonic-gate
74*0Sstevel@tonic-gate=head1 COPYRIGHT AND DISCLAIMERS
75*0Sstevel@tonic-gate
76*0Sstevel@tonic-gateCopyright (c) 2002 Sean M. Burke.  All rights reserved.
77*0Sstevel@tonic-gate
78*0Sstevel@tonic-gateThis library is free software; you can redistribute it and/or modify it
79*0Sstevel@tonic-gateunder the same terms as Perl itself.
80*0Sstevel@tonic-gate
81*0Sstevel@tonic-gateThis program is distributed in the hope that it will be useful, but
82*0Sstevel@tonic-gatewithout any warranty; without even the implied warranty of
83*0Sstevel@tonic-gatemerchantability or fitness for a particular purpose.
84*0Sstevel@tonic-gate
85*0Sstevel@tonic-gate=head1 AUTHOR
86*0Sstevel@tonic-gate
87*0Sstevel@tonic-gateSean M. Burke C<sburke@cpan.org>
88*0Sstevel@tonic-gate
89*0Sstevel@tonic-gate=cut
90*0Sstevel@tonic-gate
91