blib/lib/Pod/POM/View/Pod.pm

filter: Statementstmt 87.6% 57 / 65 Branchbran 50.0% 11 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 94.7% 18 / 19 Podpod 100% 13 / 13 totaltotal 83.1% 99 / 119 CC 11 SCAR 20.1
CC
11
Cov
78%
view
19.4
view_item
2.0
view_meta
2.0
CRAP 7.4
« blib/lib/Pod/POM/View/HTML.pm ↑ Summary blib/lib/Pod/POM/Node.pm »
1 #============================================================= -*-Perl-*-
2 #
3 # Pod::POM::View::Pod
4 #
5 # DESCRIPTION
6 # Pod view of a Pod Object Model.
7 #
8 # AUTHOR
9 # Andy Wardley <abw@kfs.org>
10 #
11 # COPYRIGHT
12 # Copyright (C) 2000 Andy Wardley. All Rights Reserved.
13 #
14 # This module is free software; you can redistribute it and/or
15 # modify it under the same terms as Perl itself.
16 #
17 # REVISION
18 # $Id: Pod.pm 77 2009-08-20 20:44:14Z ford $
19 #
20 #========================================================================
21  
22 package Pod::POM::View::Pod;
23 18 $Pod::POM::View::Pod::VERSION = '2.01';
24 18 require 5.006;
25 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 18 ▶use Pod::POM::Nodes;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 18 ▶use Pod::POM::View;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 18 ▶use parent qw( Pod::POM::View );
Subroutine BEGIN: called CC=1 SCAR=0.0
31 18 ▶use vars qw( $DEBUG $ERROR $AUTOLOAD $MARKUP );
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 18 ▶$DEBUG = 0 unless defined $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $Pod::POM::View::Pod::DEBUG 18 0 18
34  
35 # create reverse lookup table mapping method name to original sequence
36 $MARKUP = {
37 18 map { ( $Pod::POM::Node::Sequence::NAME{ $_ } => $_ ) }
38 keys %Pod::POM::Node::Sequence::NAME,
39 };
40  
41  
42 318 ▶sub view {
Subroutine view: called CC=10 SCAR=29.6
Pod documented
43 318 my ($self, $type, $item) = @_;
44  
45 # my ($pkg, $file, $line) = caller;
46 # print STDERR "called view ($type) from $file line $line\n";
47  
48 318 ▶ if ($type =~ s/^seq_//) {
Branch: 3 branches
BranchTrueFalseTotal
if ($type =~ s/^seq_//) { } 317 1 318
elsif (ref $item eq 'HASH') { } 0 1 1
elsif (not ref $item) { } 1 0 1
49 317 ▶ if ($type eq 'text') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "text") 264 53 317
50 264 return "$item";
51 }
52 53 ▶ if ($type = $MARKUP->{ $type }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type = $Pod::POM::View::Pod::MARKUP->{$type}) 53 0 53
53 53 ▶ if ($item =~ /[<>]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item =~ /[<>]/) { } 10 43 53
54 10 return "$type<< $item >>";
55 }
56 else {
57 43 return "$type<$item>";
58 }
59 }
60 }
61 elsif (ref $item eq 'HASH') {
62 0 ▶ if (defined $item->{ content }) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $item->{'content'}) { } 0 0 0
elsif (defined $item->{'text'}) { } 0 0 0
63 0 return $item->{ content }->present($self);
64 }
65 elsif (defined $item->{ text }) {
66 0 my $text = $item->{ text };
67 0 ▶ return ref $text ? $text->present($self) : $text;
Branch: 1 branch
BranchTrueFalseTotal
ref $text ? : 0 0 0
68 }
69 else {
70 0 return '';
71 }
72 }
73 elsif (! ref $item) {
74 1 return $item;
75 }
76 else {
77 0 return '';
78 }
79 }
80  
81  
82 12 ▶sub view_pod {
Subroutine view_pod: called CC=1 SCAR=0.0
Pod documented
83 12 my ($self, $pod) = @_;
84 # return "=pod\n\n" . $pod->content->present($self) . "=cut\n\n";
85 12 return $pod->content->present($self);
86 }
87  
88  
89 34 ▶sub view_head1 {
Subroutine view_head1: called CC=1 SCAR=0.0
Pod documented
90 34 my ($self, $head1) = @_;
91 34 return '=head1 '
92 . $head1->title->present($self)
93 . "\n\n"
94 . $head1->content->present($self);
95 }
96  
97  
98 8 ▶sub view_head2 {
Subroutine view_head2: called CC=1 SCAR=0.0
Pod documented
99 8 my ($self, $head2) = @_;
100 8 return '=head2 '
101 . $head2->title->present($self)
102 . "\n\n"
103 . $head2->content->present($self);
104 }
105  
106  
107 5 ▶sub view_head3 {
Subroutine view_head3: called CC=1 SCAR=0.0
Pod documented
108 5 my ($self, $head3) = @_;
109 5 return '=head3 '
110 . $head3->title->present($self)
111 . "\n\n"
112 . $head3->content->present($self);
113 }
114  
115  
116 7 ▶sub view_head4 {
Subroutine view_head4: called CC=1 SCAR=0.0
Pod documented
117 7 my ($self, $head4) = @_;
118 7 return '=head4 '
119 . $head4->title->present($self)
120 . "\n\n"
121 . $head4->content->present($self);
122 }
123  
124  
125 10 ▶sub view_over {
Subroutine view_over: called CC=1 SCAR=0.0
Pod documented
126 10 my ($self, $over) = @_;
127 10 return '=over '
128 . $over->indent()
129 . "\n\n"
130 . $over->content->present($self)
131 . "=back\n\n";
132 }
133  
134  
135 16 ▶sub view_item {
Subroutine view_item: called CC=2 SCAR=7.0
Pod documented
136 16 my ($self, $item) = @_;
137  
138 16 my $title = $item->title();
139 16 ▶ $title = $title->present($self) if ref $title;
Branch: 1 branch
BranchTrueFalseTotal
if ref $title 16 0 16
140 16 return "=item $title\n\n"
141 . $item->content->present($self);
142 }
143  
144  
145 1 ▶sub view_for {
Subroutine view_for: called CC=1 SCAR=0.0
Pod documented
146 1 my ($self, $for) = @_;
147 1 return '=for '
148 . $for->format . ' '
149 . $for->text()
150 . "\n\n"
151 . $for->content->present($self);
152 }
153
154  
155 4 ▶sub view_begin {
Subroutine view_begin: called CC=1 SCAR=0.0
Pod documented
156 4 my ($self, $begin) = @_;
157 4 return '=begin '
158 . $begin->format()
159 . "\n\n"
160 . $begin->content->present($self)
161 . "=end "
162 . $begin->format()
163 . "\n\n";
164 }
165
166  
167 92 ▶sub view_textblock {
Subroutine view_textblock: called CC=1 SCAR=0.0
Pod documented
168 92 my ($self, $text) = @_;
169 92 return "$text\n\n";
170 }
171  
172  
173 6 ▶sub view_verbatim {
Subroutine view_verbatim: called CC=1 SCAR=0.0
Pod documented
174 6 my ($self, $text) = @_;
175 6 return "$text\n\n";
176 }
177  
178  
179 0 ▶sub view_meta {
Subroutine view_meta: not called CC=1 SCAR=6.9
Pod documented
180 0 my ($self, $meta) = @_;
181 0 return '=meta '
182 . $meta->name()
183 . "\n\n"
184 . $meta->content->present($self)
185 . "=end\n\n";
186 }
187  
188  
189 18 1;
190  
191 =head1 NAME
192  
193 Pod::POM::View::Pod - create a Pod view of a POM object
194  
195 =head1 DESCRIPTION
196  
197 Pod view of a Pod Object Model.
198  
199 =head1 METHODS
200  
201 =over 4
202  
203 =item C<view($self, $type, $item)>
204  
205 =item C<view_pod($self, $pod)>
206  
207 =item C<view_head1($self, $head1)>
208  
209 =item C<view_head2($self, $head2)>
210  
211 =item C<view_head3($self, $head3)>
212  
213 =item C<view_head4($self, $head4)>
214  
215 =item C<view_over($self, $over)>
216  
217 =item C<view_item($self, $item)>
218  
219 =item C<view_for($self, $for)>
220  
221 =item C<view_begin($self, $begin)>
222  
223 =item C<view_textblock($self, $textblock)>
224  
225 =item C<view_verbatim($self, $verbatim)>
226  
227 =item C<view_meta($self, $meta)>
228  
229 =back
230  
231 =head1 AUTHOR
232  
233 Andy Wardley E<lt>abw@kfs.orgE<gt>
234  
235 =head1 COPYRIGHT AND LICENSE
236  
237 Copyright (C) 2000 Andy Wardley. All Rights Reserved.
238  
239 This module is free software; you can redistribute it and/or
240 modify it under the same terms as Perl itself.
241  
242 =cut
« blib/lib/Pod/POM/View/HTML.pm ↑ Summary blib/lib/Pod/POM/Node.pm »