File Coverage

lib/OODoc/Text/Structure.pm
Criterion Covered Total %
statement 18 53 33.9
branch 0 18 0.0
condition 0 5 0.0
subroutine 6 19 31.5
pod 11 12 91.6
total 35 107 32.7


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::Structure;
7 1     1   13 use vars '$VERSION';
  1         1  
  1         38  
8             $VERSION = '2.00';
9              
10 1     1   3 use base 'OODoc::Text';
  1         1  
  1         337  
11              
12 1     1   5 use strict;
  1         1  
  1         25  
13 1     1   4 use warnings;
  1         2  
  1         21  
14              
15 1     1   4 use Log::Report 'oodoc';
  1         2  
  1         5  
16 1     1   243 use List::Util 'first';
  1         2  
  1         638  
17              
18              
19             sub init($)
20 0     0 0   { my ($self, $args) = @_;
21 0 0         $self->SUPER::init($args) or return;
22 0           $self->{OTS_subs} = [];
23 0 0         $self->{OTS_level} = delete $args->{level}
24             or panic "no level defined for structural component";
25              
26 0           $self;
27             }
28              
29              
30             sub emptyExtension($)
31 0     0 1   { my ($self, $container) = @_;
32              
33 0           my $new = ref($self)->new
34             ( name => $self->name
35             , linenr => -1
36             , level => $self->level
37             , container => $container
38             );
39 0           $new->extends($self);
40 0           $new;
41             }
42              
43             #-------------------------------------------
44              
45              
46 0     0 1   sub level() {shift->{OTS_level}}
47              
48              
49             sub niceName()
50 0     0 1   { my $name = shift->name;
51 0 0         $name =~ m/[a-z]/ ? $name : ucfirst(lc $name);
52             }
53              
54             #-------------------------------------------
55              
56              
57 0     0 1   sub path() { panic "Not implemented" }
58              
59              
60 0     0 1   sub findEntry($) { panic "Not implemented" }
61              
62             #-------------------------------------------
63              
64              
65             sub all($@)
66 0     0 1   { my ($self, $method) = (shift, shift);
67 0           $self->$method(@_);
68             }
69              
70              
71             sub isEmpty()
72 0     0 1   { my $self = shift;
73              
74 0 0         return 0 if $self->description !~ m/^\s*$/;
75 0 0 0       return 0 if $self->examples || $self->subroutines;
76              
77             my @nested
78 0 0         = $self->isa('OODoc::Text::Chapter') ? $self->sections
    0          
    0          
79             : $self->isa('OODoc::Text::Section') ? $self->subsections
80             : $self->isa('OODoc::Text::SubSection') ? $self->subsubsections
81             : return 1;
82              
83 0 0         foreach (@nested) { $_->isEmpty or return 0 }
  0            
84              
85 0           1;
86             }
87              
88             #-------------------
89              
90             sub addSubroutine(@)
91 0     0 1   { my $self = shift;
92 0           push @{$self->{OTS_subs}}, @_;
  0            
93 0           $_->container($self) for @_;
94 0           $self;
95             }
96              
97              
98 0     0 1   sub subroutines() { @{shift->{OTS_subs}} }
  0            
99              
100              
101             sub subroutine($)
102 0     0 1   { my ($self, $name) = @_;
103 0     0     first {$_->name eq $name} $self->subroutines;
  0            
104             }
105              
106              
107             sub setSubroutines($)
108 0     0 1   { my $self = shift;
109 0   0       $self->{OTS_subs} = shift || [];
110             }
111              
112             #-------------------------------------------
113              
114              
115              
116             1;