File Coverage

lib/OODoc/Text/Structure.pm
Criterion Covered Total %
statement 18 54 33.3
branch 0 16 0.0
condition 0 2 0.0
subroutine 6 21 28.5
pod 11 12 91.6
total 35 105 33.3


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