File Coverage

lib/OODoc/Text/Chapter.pm
Criterion Covered Total %
statement 18 62 29.0
branch 0 16 0.0
condition 0 7 0.0
subroutine 6 16 37.5
pod 7 9 77.7
total 31 110 28.1


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