File Coverage

lib/OODoc/Text/Section.pm
Criterion Covered Total %
statement 18 61 29.5
branch 0 16 0.0
condition 0 7 0.0
subroutine 6 16 37.5
pod 7 9 77.7
total 31 109 28.4


line stmt bran cond sub pod time code
1             # Copyrights 2003-2013 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.00.
5              
6             package OODoc::Text::Section;
7 1     1   1307 use vars '$VERSION';
  1         2  
  1         45  
8             $VERSION = '2.00';
9              
10 1     1   4 use base 'OODoc::Text::Structure';
  1         1  
  1         79  
11              
12 1     1   5 use strict;
  1         1  
  1         26  
13 1     1   5 use warnings;
  1         1  
  1         31  
14              
15 1     1   4 use Log::Report 'oodoc';
  1         2  
  1         5  
16 1     1   236 use List::Util 'first';
  1         2  
  1         574  
17              
18              
19              
20             sub init($)
21 0     0 0   { my ($self, $args) = @_;
22 0   0       $args->{type} ||= 'Section';
23 0   0       $args->{level} ||= 2;
24 0 0 0       $args->{container} ||= delete $args->{chapter} or panic;
25              
26 0 0         $self->SUPER::init($args) or return;
27              
28 0           $self->{OTS_subsections} = [];
29 0           $self;
30             }
31              
32             sub emptyExtension($)
33 0     0 1   { my ($self, $container) = @_;
34 0           my $empty = $self->SUPER::emptyExtension($container);
35 0           my @subsections = map {$_->emptyExtension($empty)} $self->subsections;
  0            
36 0           $empty->subsections(@subsections);
37 0           $empty;
38             }
39              
40             #-------------------------------------------
41              
42              
43 0     0 1   sub chapter() { shift->container }
44              
45             sub path()
46 0     0 1   { my $self = shift;
47 0           $self->chapter->path . '/' . $self->name;
48             }
49              
50             sub findSubroutine($)
51 0     0 0   { my ($self, $name) = @_;
52 0           my $sub = $self->SUPER::findSubroutine($name);
53 0 0         return $sub if defined $sub;
54              
55 0           foreach my $subsection ($self->subsections)
56 0           { my $sub = $subsection->findSubroutine($name);
57 0 0         return $sub if defined $sub;
58             }
59              
60 0           undef;
61             }
62              
63             sub findEntry($)
64 0     0 1   { my ($self, $name) = @_;
65 0 0         return $self if $self->name eq $name;
66 0           my $subsect = $self->subsection($name);
67 0 0         defined $subsect ? $subsect : ();
68             }
69              
70             sub all($@)
71 0     0 1   { my $self = shift;
72 0           ($self->SUPER::all(@_), map {$_->all(@_)} $self->subsections);
  0            
73             }
74              
75             #-------------------------------------------
76              
77              
78             sub subsection($)
79 0     0 1   { my ($self, $thing) = @_;
80 0 0         if(ref $thing)
81 0           { push @{$self->{OTS_subsections}}, $thing;
  0            
82 0           return $thing;
83             }
84              
85 0     0     first {$_->name eq $thing} $self->subsections;
  0            
86             }
87              
88              
89             sub subsections(;@)
90 0     0 1   { my $self = shift;
91 0 0         if(@_)
92 0           { $self->{OTS_subsections} = [ @_ ];
93 0           $_->container($self) for @_;
94             }
95              
96 0           @{$self->{OTS_subsections}};
  0            
97             }
98              
99              
100             1;