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 10require 5; 11package Pod::Perldoc::ToPod; 12use strict; 13use warnings; 14 15use base qw(Pod::Perldoc::BaseTo); 16sub is_pageable { 1 } 17sub write_with_binmode { 0 } 18sub output_extension { 'pod' } 19 20sub new { return bless {}, ref($_[0]) || $_[0] } 21 22sub 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 471; 48__END__ 49 50=head1 NAME 51 52Pod::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 64This is a "plug-in" class that allows Perldoc to display Pod source as 65itself! Pretty Zen, huh? 66 67Currently this class works by just filtering out the non-Pod stuff from 68a given input file. 69 70=head1 SEE ALSO 71 72L<Pod::Perldoc> 73 74=head1 COPYRIGHT AND DISCLAIMERS 75 76Copyright (c) 2002 Sean M. Burke. All rights reserved. 77 78This library is free software; you can redistribute it and/or modify it 79under the same terms as Perl itself. 80 81This program is distributed in the hope that it will be useful, but 82without any warranty; without even the implied warranty of 83merchantability or fitness for a particular purpose. 84 85=head1 AUTHOR 86 87Sean M. Burke C<sburke@cpan.org> 88 89=cut 90 91