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