File Coverage

lib/OODoc/Text/Chapter.pm
Criterion Covered Total %
statement 15 57 26.3
branch 0 16 0.0
condition 0 7 0.0
subroutine 5 15 33.3
pod 7 9 77.7
total 27 104 25.9


line stmt bran cond sub pod time code
1             # This code is part of Perl distribution OODoc version 3.05.
2             # The POD got stripped from this file by OODoc version 3.05.
3             # For contributors see file ChangeLog.
4              
5             # This software is copyright (c) 2003-2025 by Mark Overmeer.
6              
7             # This is free software; you can redistribute it and/or modify it under
8             # the same terms as the Perl 5 programming language system itself.
9             # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10              
11              
12             package OODoc::Text::Chapter;{
13             our $VERSION = '3.05';
14             }
15              
16 1     1   1533 use parent 'OODoc::Text::Structure';
  1         2  
  1         10  
17              
18 1     1   93 use strict;
  1         2  
  1         29  
19 1     1   6 use warnings;
  1         1  
  1         71  
20              
21 1     1   5 use Log::Report 'oodoc';
  1         3  
  1         9  
22              
23 1     1   421 use List::Util qw/first/;
  1         3  
  1         899  
24              
25             #--------------------
26              
27             sub init($)
28 0     0 0   { my ($self, $args) = @_;
29 0   0       $args->{type} ||= 'Chapter';
30 0 0 0       $args->{container} ||= delete $args->{manual} or panic;
31 0   0       $args->{level} ||= 1;
32 0 0         $self->SUPER::init($args) or return;
33 0           $self->{OTC_sections} = [];
34 0           $self;
35             }
36              
37             sub emptyExtension($)
38 0     0 1   { my ($self, $container) = @_;
39 0           my $empty = $self->SUPER::emptyExtension($container);
40 0           my @sections = map $_->emptyExtension($empty), $self->sections;
41 0           $empty->sections(@sections);
42 0           $empty;
43             }
44              
45 0     0 1   sub manual() { $_[0]->container }
46 0     0 1   sub path() { $_[0]->name }
47              
48             sub findSubroutine($)
49 0     0 0   { my ($self, $name) = @_;
50 0           my $sub = $self->SUPER::findSubroutine($name);
51 0 0         return $sub if defined $sub;
52              
53 0           foreach my $section ($self->sections)
54 0           { my $sub = $section->findSubroutine($name);
55 0 0         return $sub if defined $sub;
56             }
57              
58 0           undef;
59             }
60              
61             sub findEntry($)
62 0     0 1   { my ($self, $name) = @_;
63 0 0         return $self if $self->name eq $name;
64              
65 0           foreach my $section ($self->sections)
66 0           { my $entry = $section->findEntry($name);
67 0 0         return $entry if defined $entry;
68             }
69              
70 0           ();
71             }
72              
73             sub all($@)
74 0     0 1   { my $self = shift;
75 0           ( $self->SUPER::all(@_),
76             (map $_->all(@_), $self->sections),
77             );
78             }
79              
80             #--------------------
81              
82             sub section($)
83 0     0 1   { my ($self, $thing) = @_;
84              
85 0 0         if(ref $thing)
86 0           { push @{$self->{OTC_sections}}, $thing;
  0            
87 0           return $thing;
88             }
89              
90 0     0     first { $_->name eq $thing } $self->sections;
  0            
91             }
92              
93              
94             sub sections()
95 0     0 1   { my $self = shift;
96 0 0         if(@_)
97 0           { $self->{OTC_sections} = [ @_ ];
98 0           $_->container($self) for @_;
99             }
100 0           @{$self->{OTC_sections}};
  0            
101             }
102              
103             *nest = \*sections;
104              
105             1;