| 1 | package App::Grok::Parser::Pod6; | ||||||||||
| 2 | 17 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 17 | $App::Grok::Parser::Pod6::AUTHORITY = 'cpan:HINRIK'; | |||||||||
| 4 | } | ||||||||||
| 5 | { | ||||||||||
| 6 | 17 | $App::Grok::Parser::Pod6::VERSION = '0.26'; | |||||||||
| 7 | } | ||||||||||
| 8 | |||||||||||
| 9 | # blows up if we use strict before this, damn source filter | ||||||||||
| 10 | 17 | ▶ | use Perl6::Perldoc::Parser; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 17 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 17 | ▶ | use warnings FATAL => 'all'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 16 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 16 | 16 | my ($package, %self) = @_; | |||||||||
| 17 | 16 | return bless \%self, $package; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 17 | ▶ | sub render_file { | ||||||||
|
Subroutine
render_file: called CC=3 SCAR=11.6
Pod
documented
| |||||||||||
| 21 | 17 | my ($self, $file, $format) = @_; | |||||||||
| 22 | |||||||||||
| 23 | 17 | ▶ | if ($format !~ /^(?:ansi|text|xhtml)$/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | die __PACKAGE__ . " doesn't support the '$format' format"; | |||||||||
| 25 | } | ||||||||||
| 26 | 17 | eval "require Perl6::Perldoc::To::\u$format"; | |||||||||
| 27 | 17 | ▶ | die $@ if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | |||||||||||
| 29 | 17 | my $method = "to_$format"; | |||||||||
| 30 | 17 | return Perl6::Perldoc::Parser->parse($file, {all_pod=>'auto'}) | |||||||||
| 31 | ->report_errors() | ||||||||||
| 32 | ->$method(); | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 15 | ▶ | sub render_string { | ||||||||
|
Subroutine
render_string: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 36 | 15 | my ($self, $string, $format) = @_; | |||||||||
| 37 | |||||||||||
| 38 | 15 | ▶ | open my $handle, '<', \$string or die "Can't open input filehandle: $!"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 15 | binmode $handle, ':utf8'; | |||||||||
| 40 | 15 | my $result = $self->render_file($handle, $format); | |||||||||
| 41 | 15 | close $handle; | |||||||||
| 42 | 15 | return $result; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 17 | 1; | |||||||||
| 46 | |||||||||||
| 47 | =encoding utf8 | ||||||||||
| 48 | |||||||||||
| 49 | =head1 NAME | ||||||||||
| 50 | |||||||||||
| 51 | App::Grok::Parser::Pod6 - A Pod 6 backend for grok | ||||||||||
| 52 | |||||||||||
| 53 | =head1 METHODS | ||||||||||
| 54 | |||||||||||
| 55 | =head2 C<new> | ||||||||||
| 56 | |||||||||||
| 57 | This is the constructor. It currently takes no arguments. | ||||||||||
| 58 | |||||||||||
| 59 | =head2 C<render_file> | ||||||||||
| 60 | |||||||||||
| 61 | Takes two arguments, a filename and the name of an output format. Returns | ||||||||||
| 62 | a string containing the rendered document. It will C<die> if there is an | ||||||||||
| 63 | error. | ||||||||||
| 64 | |||||||||||
| 65 | =head2 C<render_string> | ||||||||||
| 66 | |||||||||||
| 67 | Takes two arguments, a string and the name of an output format. Returns | ||||||||||
| 68 | a string containing the rendered document. It will C<die> if there is an | ||||||||||
| 69 | error. | ||||||||||
| 70 | |||||||||||
| 71 | =head1 AUTHOR | ||||||||||
| 72 | |||||||||||
| 73 | Hinrik Örn Sigurðsson, L<hinrik.sig@gmail.com> | ||||||||||
| 74 | |||||||||||
| 75 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 76 | |||||||||||
| 77 | Copyright 2009 Hinrik Örn Sigurðsson | ||||||||||
| 78 | |||||||||||
| 79 | C<grok> is distributed under the terms of the Artistic License 2.0. | ||||||||||
| 80 | For more details, see the full text of the license in the file F<LICENSE> | ||||||||||
| 81 | that came with this distribution. | ||||||||||
| 82 | |||||||||||
| 83 | =cut | ||||||||||