blib/lib/OODoc/Format/Pod2.pm untested

filter: Statementstmt 0.0% 0 / 67 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 10 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 99 CC 3 SCAR 13.9
CC
3
Cov
0%
templateChapter
12.0
createManual
2.0
formatManual
2.0
CRAP 4.0
1 # Copyrights 2003-2015 by [Mark Overmeer].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.01.
5  
6 package OODoc::Format::Pod2;
7 use vars '$VERSION';
8 $VERSION = '2.01';
9  
10 use base qw/OODoc::Format::Pod OODoc::Format::TemplateMagic/;
11  
12 use strict;
13 use warnings;
14  
15 use Log::Report 'oodoc';
16 use Template::Magic;
17  
18 use File::Spec;
19 use IO::Scalar;
20  
21  
22 my $default_template;
23 { local $/;
24 $default_template = <DATA>;
25 close DATA;
26 }
27  
28 sub createManual(@)
29 { my ($self, %args) = @_;
30 $self->{O_template} = delete $args{template} || \$default_template;
31 $self->SUPER::createManual(%args) or return;
32 }
33  
34 sub formatManual(@)
35 { my ($self, %args) = @_;
36 my $output = delete $args{output};
37  
38 my %permitted =
39 ( chapter => sub {$self->templateChapter(shift, \%args) }
40 , diagnostics => sub {$self->templateDiagnostics(shift, \%args) }
41 , append => sub {$self->templateAppend(shift, \%args) }
42 , comment => sub { '' }
43 );
44  
45 my $template = Template::Magic->new
46 ( { -lookups => \%permitted }
47 );
48  
49 my $layout = ${$self->{O_template}}; # Copy needed by template!
50 my $created = $template->output(\$layout);
51 $output->print($$created);
52 }
53  
54  
55 sub templateChapter($$)
56 { my ($self, $zone, $args) = @_;
57 my $contained = $zone->content;
58 defined $contained && length $contained
59 or warning __x"no meaning for container {c} in chapter block"
60 , c => $contained;
61  
62 my $attrs = $zone->attributes;
63 my $name = $attrs =~ s/^\s*(\w+)\s*\,?// ? $1 : undef;
64  
65 unless(defined $name)
66 { error __x"chapter without name in template.";
67 return '';
68 }
69  
70 my @attrs = $self->zoneGetParameters($attrs);
71 my $out = '';
72  
73 $self->showOptionalChapter($name, %$args
74 , output => IO::Scalar->new(\$out), @attrs);
75  
76 $out;
77 }
78  
79 sub templateDiagnostics($$)
80 { my ($self, $zone, $args) = @_;
81 my $out = '';
82 $self->chapterDiagnostics(%$args, output => IO::Scalar->new(\$out));
83 $out;
84 }
85  
86 sub templateAppend($$)
87 { my ($self, $zone, $args) = @_;
88 my $out = '';
89 $self->showAppend(%$args, output => IO::Scalar->new(\$out));
90 $out;
91 }
92  
93  
94 1;
95  
96 __DATA__