| 1 | package Apache2::Pod::Text; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Apache2::Pod::Text - mod_perl handler to convert Pod to plain text | ||
| 6 | |||
| 7 | =head1 VERSION | ||
| 8 | |||
| 9 | Version 0.27 | ||
| 10 | |||
| 11 | =cut | ||
| 12 | |||
| 13 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 3 | ▶ | use vars qw( $VERSION ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | |||
| 16 | $VERSION = '0.27'; | ||
| 17 | |||
| 18 | =head1 SYNOPSIS | ||
| 19 | |||
| 20 | A simple mod_perl handler to easily convert Pod to Text. | ||
| 21 | |||
| 22 | =head1 CONFIGURATION | ||
| 23 | |||
| 24 | You can replace Apache2::Pod::HTML with Apache2::Pod::Text as your | ||
| 25 | C<PerlHandler> in your apache configuration if you wish to use the | ||
| 26 | text rendering of your pod documentation instead of HTML. | ||
| 27 | See L<Apache2::Pod::HTML> for configuration details. | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | 3 | ▶ | use Apache2::Pod; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 32 | 0 | ▶ | use Apache2::Const -compile => qw( OK ); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 33 | use Pod::Simple::Text; | ||
| 34 | |||
| 35 | sub handler { | ||
| 36 | my $r = shift; | ||
| 37 | |||
| 38 | my $str; | ||
| 39 | my $file = Apache2::Pod::getpodfile( $r ); | ||
| 40 | my $fun = undef; | ||
| 41 | my $parser = Pod::Simple::Text->new; | ||
| 42 | $parser->complain_stderr(1); | ||
| 43 | $parser->output_string( \$str ); | ||
| 44 | if ( $file ) { | ||
| 45 | if ( $file =~ /^-f<([^>]*)>::(.*)$/ ) { | ||
| 46 | $fun = $1; | ||
| 47 | $file = $2; | ||
| 48 | } | ||
| 49 | if ( $fun ) { | ||
| 50 | my $document = Apache2::Pod::getpodfuncdoc( $file, $fun ); | ||
| 51 | $parser->parse_string_document( $document ); | ||
| 52 | } | ||
| 53 | else { | ||
| 54 | $parser->parse_file( $file ); | ||
| 55 | } | ||
| 56 | } | ||
| 57 | else { | ||
| 58 | my $modstr = Apache2::Pod::resolve_modname( $r ) || $r->filename || ''; | ||
| 59 | my $document = sprintf "=item %1\$s\n\nNo documentation found for \"%1\$s\".\n", $modstr; | ||
| 60 | $parser->parse_string_document( $document ); | ||
| 61 | } | ||
| 62 | $r->content_type('text/plain'); | ||
| 63 | $r->print( $str ); | ||
| 64 | |||
| 65 | return Apache2::Const::OK; | ||
| 66 | } | ||
| 67 | |||
| 68 | =head1 SEE ALSO | ||
| 69 | |||
| 70 | L<Apache2::Pod>, | ||
| 71 | L<Apache2::Pod::HTML> | ||
| 72 | |||
| 73 | =head1 AUTHOR | ||
| 74 | |||
| 75 | Theron Lewis C<< <theron at theronlewis dot com> >> | ||
| 76 | |||
| 77 | =head1 HISTORY | ||
| 78 | |||
| 79 | Adapteded from Andy Lester's C<< <andy at petdance dot com> >> Apache::Pod | ||
| 80 | package which was adapted from | ||
| 81 | Apache2::Perldoc by Rich Bowen C<< <rbowen@ApacheAdmin.com> >> | ||
| 82 | |||
| 83 | =head1 ACKNOWLEDGEMENTS | ||
| 84 | |||
| 85 | Thanks also to | ||
| 86 | Pete Krawczyk, | ||
| 87 | Kjetil Skotheim, | ||
| 88 | Kate Yoak | ||
| 89 | and | ||
| 90 | Chris Eade | ||
| 91 | for contributions. | ||
| 92 | |||
| 93 | =head1 LICENSE | ||
| 94 | |||
| 95 | This package is licensed under the same terms as Perl itself. | ||
| 96 | |||
| 97 | =cut | ||
| 98 | |||
| 99 | 1; | ||