Filter/Perl/POD.pm

filter: Statementstmt 20.6% 19 / 92 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 31.2% 5 / 16 Podpod 63.6% 7 / 11 totaltotal 26.0% 31 / 119 CC 2 SCAR 7.8
CC
2
Cov
21%
view_verbatim
6.0
convertText
2.0
convertTitle
2.0
CRAP 2.2
« Filter/Perl.pm ↑ Summary Filter.pm »
1 #** @file POD.pm
2 # @verbatim
3 #####################################################################
4 # This program is not guaranteed to work at all, and by using this #
5 # program you release the author of any and all liability. #
6 # #
7 # You may use this code as long as you are in compliance with the #
8 # license (see the LICENSE file) and this notice, disclaimer and #
9 # comment box remain intact and unchanged. #
10 # #
11 # Package: Doxygen::Filter::Perl #
12 # Class: POD #
13 # Description: Methods for prefiltering Perl code for Doxygen #
14 # #
15 # Written by: Bret Jordan (jordan at open1x littledot org) #
16 # Created: 2011-10-13 #
17 #####################################################################
18 # @endverbatim
19 #
20 # @copy 2011, Bret Jordan (jordan2175@gmail.com, jordan@open1x.org)
21 #*
22 package Doxygen::Filter::Perl::POD;
23  
24 1 ▶use 5.8.8;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use parent qw(Pod::POM::View::HTML);
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶use Log::Log4perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 1 our $VERSION = '1.73';
31 1 $VERSION = eval $VERSION;
32 1 our $labelCnt = 0; # label counter to see to it that when e.g. twice a =head1 NAME in a file it is still an unique label
33 1 our $sectionLabel = 'x';
34  
35 sub convertText
36 0 ▶{
Subroutine convertText: not called CC=1 SCAR=6.9
Pod undocumented
37 # based on e.g. a file name try to create a doxygen label prefix
38 0 my $label = shift;
39 0 $label =~ s/_/__/g;
40 0 $label =~ s/:/_1/g;
41 0 $label =~ s/\//_2/g;
42 0 $label =~ s/</_3/g;
43 0 $label =~ s/>/_4/g;
44 0 $label =~ s/\*/_5/g;
45 0 $label =~ s/&/_6/g;
46 0 $label =~ s/\|/_7/g;
47 0 $label =~ s/\./_8/g;
48 0 $label =~ s/!/_9/g;
49 0 $label =~ s/,/_00/g;
50 0 $label =~ s/ /_01/g;
51 0 $label =~ s/{/_02/g;
52 0 $label =~ s/}/_03/g;
53 0 $label =~ s/\?/_04/g;
54 0 $label =~ s/\^/_05/g;
55 0 $label =~ s/%/_06/g;
56 0 $label =~ s/\(/_07/g;
57 0 $label =~ s/\)/_08/g;
58 0 $label =~ s/\+/_09/g;
59 0 $label =~ s/=/_0A/g;
60 0 $label =~ s/\$/_0B/g;
61 0 $label =~ s/\\/_0C/g;
62 0 $label =~ s/@/_0D/g;
63 0 $label =~ s/-/_0E/g;
64 0 $label =~ s/[^a-z0-9A-Z]/_/g;
65  
66 0 $label = "x$label"; # label should not start with a underscore
67 0 return $label;
68 }
69  
70 sub convertTitle
71 0 ▶{
Subroutine convertTitle: not called CC=1 SCAR=6.9
Pod undocumented
72 0 my $title = shift;
73 0 $title =~ s/\n/ /g;
74 0 return $title;
75 }
76  
77 sub setAsLabel
78 0 ▶{
Subroutine setAsLabel: not called CC=1 SCAR=6.9
Pod undocumented
79 # based on e.g. a file name try to create a doxygen label prefix
80 0 my $self = shift;
81 0 my $tmpLabel = shift;
82 0 $sectionLabel = convertText($tmpLabel);
83 }
84  
85 sub view_pod
86 0 ▶{
Subroutine view_pod: not called CC=1 SCAR=6.9
Pod documented
87 0 my ($self, $pod) = @_;
88 0 return $pod->content->present($self);
89 }
90  
91 sub view_head1
92 0 ▶{
Subroutine view_head1: not called CC=1 SCAR=6.9
Pod documented
93 0 my ($self, $head1) = @_;
94 0 my $title = $head1->title->present($self);
95 0 my $name = convertText($title);
96 0 $title = convertTitle($title);
97 0 $labelCnt += 1;
98 0 return "\n\@section $sectionLabel$name$labelCnt $title\n" . $head1->content->present($self);
99 }
100  
101 sub view_head2
102 0 ▶{
Subroutine view_head2: not called CC=1 SCAR=6.9
Pod documented
103 0 my ($self, $head2) = @_;
104 0 my $title = $head2->title->present($self);
105 0 my $name = convertText($title);
106 0 $title = convertTitle($title);
107 0 $labelCnt += 1;
108 0 return "\n\@subsection $sectionLabel$name$labelCnt $title\n" . $head2->content->present($self);
109 }
110  
111 sub view_head3
112 0 ▶{
Subroutine view_head3: not called CC=1 SCAR=6.9
Pod documented
113 0 my ($self, $head3) = @_;
114 0 my $title = $head3->title->present($self);
115 0 my $name = convertText($title);
116 0 $title = convertTitle($title);
117 0 $labelCnt += 1;
118 0 return "\n\@subsubsection $sectionLabel$name$labelCnt $title\n" . $head3->content->present($self);
119 }
120  
121 sub view_head4
122 0 ▶{
Subroutine view_head4: not called CC=1 SCAR=6.9
Pod documented
123 0 my ($self, $head4) = @_;
124 0 my $title = $head4->title->present($self);
125 0 my $name = convertText($title);
126 0 $title = convertTitle($title);
127 0 $labelCnt += 1;
128 0 return "\n\@paragraph $sectionLabel$name$labelCnt $title\n" . $head4->content->present($self);
129 }
130  
131  
132 sub view_seq_code
133 0 ▶{
Subroutine view_seq_code: not called CC=1 SCAR=6.9
Pod documented
134 0 my ($self, $text) = @_;
135 0 $text =~ s/"/\\"/g;
136 0 return "<code>$text</code>";
137 }
138  
139 0 ▶sub encode {
Subroutine encode: not called CC=1 SCAR=6.9
Pod undocumented
140 0 my($self,$text) = @_;
141 0 return $text;
142 }
143  
144  
145  
146 0 ▶sub view_verbatim {
Subroutine view_verbatim: not called CC=2 SCAR=17.9
Pod documented
147 0 my ($self, $text) = @_;
148 0 for ($text) {
149 0 s/&/&amp;/g;
150 0 s/</&lt;/g;
151 0 s/>/&gt;/g;
152 0 s/-/\\-/g;
153 }
154 0 return "<pre>$text</pre>\n\n";
155 }
156  
157  
158 =head1 NAME
159  
160 Doxygen::Filter::Perl::POD - A perl code pre-filter for Doxygen
161  
162 =head1 DESCRIPTION
163  
164 The Doxygen::Filter::Perl::POD is a helper module for use with Doxygen::Filter::Perl
165 and should not be called directly. This class actually overloads some of the methods
166 found in Pod::POM::View::HTML and converts their output to be in a Doxygen style that
167 Doxygen::Filter::Perl can use. The reason I went this route is Pod::POM appears to
168 be well established and pretty good at parsing POD. I thus did not want to reinvent
169 the wheel when it appears that this wheel works pretty well. Now this class should
170 probably find its way in to the Pod::POM::View tree at some point. But for now it
171 is here.
172  
173 =head1 AUTHOR
174  
175 Bret Jordan <jordan at open1x littledot org> or <jordan2175 at gmail littledot com>
176  
177 =head1 LICENSE
178  
179 This is free software, licensed under the Apache License, Version 2.0.
180 See the LICENSE file included with this package for license details.
181  
182 =cut
183  
184 1 return 1;
« Filter/Perl.pm ↑ Summary Filter.pm »