File Coverage

blib/lib/Pod/Outline.pm
Criterion Covered Total %
statement 15 48 31.2
branch n/a
condition 0 2 0.0
subroutine 5 25 20.0
pod 0 19 0.0
total 20 94 21.2


line stmt bran cond sub pod time code
1             package Pod::Outline;
2              
3 1     1   18802 use strict;
  1         2  
  1         27  
4 1     1   758 use Pod::Simple::Text ();
  1         880419  
  1         23  
5 1     1   9 use Text::Wrap;
  1         8  
  1         72  
6             our @ISA = qw( Pod::Simple::Text );
7              
8             =head1 NAME
9              
10             Pod::Outline - For generating outlines of POD files
11              
12             =cut
13              
14 1     1   6 use warnings;
  1         1  
  1         37  
15 1     1   5 use strict;
  1         2  
  1         632  
16              
17             =head1 VERSION
18              
19             Version 0.10
20              
21             =cut
22              
23             our $VERSION = '0.10';
24              
25             =head1 SYNOPSIS
26              
27             Subclass of L designed for outlines.
28              
29             =cut
30              
31             our $INDENT = 4;
32              
33 0     0 0   sub handle_text { $_[0]{'Thispara'} .= $_[1] }
34              
35 0     0 0   sub start_Para { $_[0]{'Thispara'} = '' }
36 0     0 0   sub start_head1 { _start_head(1,@_) }
37 0     0 0   sub start_head2 { _start_head(2,@_) }
38 0     0 0   sub start_head3 { _start_head(3,@_) }
39 0     0 0   sub start_head4 { _start_head(4,@_) }
40             sub _start_head {
41 0     0     my $depth = shift;
42 0           my $self = shift;
43 0           $self->{Depth} = $depth;
44 0           $self->{Thispara} = " " x ($INDENT * ($depth-1));
45             }
46              
47 0     0 0   sub start_Verbatim { $_[0]{'Thispara'} = '' }
48 0     0 0   sub start_item_bullet { $_[0]{'Thispara'} = '* ' }
49 0     0 0   sub start_item_number { $_[0]{'Thispara'} = "$_[1]{'number'}. " }
50 0     0 0   sub start_item_text { $_[0]{'Thispara'} = '' }
51              
52             # . . . . . Now the actual formatters:
53              
54 0     0 0   sub end_head1 { $_[0]->emit_par(-1 * $INDENT) }
55 0     0 0   sub end_head2 { $_[0]->emit_par(-2 * $INDENT) }
56 0     0 0   sub end_head3 { $_[0]->emit_par(-3 * $INDENT) }
57 0     0 0   sub end_head4 { $_[0]->emit_par(-4 * $INDENT) }
58 0     0 0   sub end_Para { $_[0]->emit_par() }
59 0     0 0   sub end_item_bullet { $_[0]->emit_par() }
60 0     0 0   sub end_item_number { $_[0]->emit_par() }
61 0     0 0   sub end_item_text { $_[0]->emit_par(int(.5*$INDENT))}
62              
63             sub emit_par {
64 0     0 0   my $self = shift;
65 0           my $tweak_indent = shift;
66              
67 0   0       my $nspaces = ($INDENT * $self->{'Depth'}) + ($tweak_indent||0);
68              
69 0           my $indent = ' ' x $nspaces; # Yes, 'STRING' x NEGATIVE gives '', same as 'STRING' x 0
70              
71 0           $self->{'Thispara'} =~ tr{\xAD}{}d if Pod::Simple::ASCII;
72 0           my $out = Text::Wrap::wrap($indent, $indent, $self->{'Thispara'} .= "\n");
73 0           $out =~ tr{\xA0}{ } if Pod::Simple::ASCII;
74 0           print {$self->{'output_fh'}} $out, "\n";
  0            
75 0           $self->{'Thispara'} = '';
76              
77 0           return;
78             } # emit_par
79              
80             =head1 AUTHOR
81              
82             Andy Lester, C<< >>
83              
84             =head1 BUGS
85              
86             Please report any bugs or feature requests to
87             C, or through the web interface at
88             L. I will be notified, and then you'll automatically
89             be notified of progress on your bug as I make changes.
90              
91             =head1 COPYRIGHT & LICENSE
92              
93             Copyright 2004 Andy Lester, All Rights Reserved.
94              
95             This program is free software; you can redistribute it and/or modify it
96             under the same terms as Perl itself.
97              
98             =cut
99              
100             1; # End of Pod::Outline