File Coverage

lib/OODoc/Text/SubSection.pm
Criterion Covered Total %
statement 15 48 31.2
branch 0 12 0.0
condition 0 7 0.0
subroutine 5 14 35.7
pod 7 8 87.5
total 27 89 30.3


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::SubSection;{
13             our $VERSION = '3.05';
14             }
15              
16 1     1   1728 use parent 'OODoc::Text::Structure';
  1         1  
  1         10  
17              
18 1     1   83 use strict;
  1         2  
  1         26  
19 1     1   5 use warnings;
  1         2  
  1         63  
20              
21 1     1   5 use Log::Report 'oodoc';
  1         4  
  1         5  
22              
23 1     1   374 use List::Util qw/first/;
  1         2  
  1         701  
24              
25             #--------------------
26              
27             sub init($)
28 0     0 0   { my ($self, $args) = @_;
29 0   0       $args->{type} ||= 'Subsection';
30 0 0 0       $args->{container} ||= delete $args->{section} or panic;
31 0   0       $args->{level} ||= 3;
32              
33 0 0         $self->SUPER::init($args) or return;
34 0           $self->{OTS_subsubsections} = [];
35 0           $self;
36             }
37              
38             sub emptyExtension($)
39 0     0 1   { my ($self, $container) = @_;
40 0           my $empty = $self->SUPER::emptyExtension($container);
41 0           my @subsub = map $_->emptyExtension($empty), $self->subsubsections;
42 0           $empty->subsubsections(@subsub);
43 0           $empty;
44             }
45              
46             sub findEntry($)
47 0     0 1   { my ($self, $name) = @_;
48 0 0         return $self if $self->name eq $name;
49 0           my $subsubsect = $self->subsubsection($name);
50 0 0         defined $subsubsect ? $subsubsect : ();
51             }
52              
53             #--------------------
54              
55 0     0 1   sub section() { $_[0]->container }
56              
57              
58 0     0 1   sub chapter() { $_[0]->section->chapter }
59              
60             sub path()
61 0     0 1   { my $self = shift;
62 0           $self->section->path . '/' . $self->name;
63             }
64              
65             #--------------------
66              
67             sub subsubsection($)
68 0     0 1   { my ($self, $thing) = @_;
69              
70 0 0         if(ref $thing)
71 0           { push @{$self->{OTS_subsubsections}}, $thing;
  0            
72 0           return $thing;
73             }
74              
75 0     0     first { $_->name eq $thing } $self->subsubsections;
  0            
76             }
77              
78              
79             sub subsubsections(;@)
80 0     0 1   { my $self = shift;
81 0 0         if(@_)
82 0           { $self->{OTS_subsubsections} = [ @_ ];
83 0           $_->container($self) for @_;
84             }
85              
86 0           @{$self->{OTS_subsubsections}};
  0            
87             }
88              
89             *nest = \*subsubsections;
90              
91             1;