| 1 | package PPI::Transform::Doxygen; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | PPI::Transform::Doxygen - PPI::Transform class for generating Doxygen input | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | use PPI; | ||||||||||||||||||||||||||||||||||||||||||
| 12 | use PPI::Transform::Doxygen; | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | my $transform = PPI::Transform::Doxygen->new(); | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | # appends Doxygen Docs after __END__ (default when no output is given) | ||||||||||||||||||||||||||||||||||||||||||
| 17 | $transform->file('Module.pm'); | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | # prints Doxygen docs for use as a doxygen filter | ||||||||||||||||||||||||||||||||||||||||||
| 20 | $transform->file('Module.pm' => \*STDOUT); | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | This module is normally used by the script L<ppi_transform_doxygen> that is | ||||||||||||||||||||||||||||||||||||||||||
| 25 | part of this distribution and acts as a doxygen input filter (look for | ||||||||||||||||||||||||||||||||||||||||||
| 26 | B<INPUT_FILTER> in the Doxygen docs). | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | There is already L<Doxygen::Filter::Perl> doing roughly the same task, but it | ||||||||||||||||||||||||||||||||||||||||||
| 29 | uses special doxygen comments. | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | The goal of PPI::Transform::Doxygen is to use only POD documentation with a | ||||||||||||||||||||||||||||||||||||||||||
| 32 | minimal amount of special syntax, while still producing decent results with | ||||||||||||||||||||||||||||||||||||||||||
| 33 | doxygen. | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | As doxygen is not able to parse perl directly, the input filter will | ||||||||||||||||||||||||||||||||||||||||||
| 36 | convert the source so that it will look like C++. | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | =head1 CONVENTIONS | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | The only thing really needed, is documenting your methods and functions with | ||||||||||||||||||||||||||||||||||||||||||
| 41 | a POD tag B<=head2> that contains a function string with parentheses ( it has | ||||||||||||||||||||||||||||||||||||||||||
| 42 | to match the regular expression /[\w:]+\(.*\)/) like so: | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | =head2 do_things() | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | This function does things | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | sub do_things { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | print "Hi!\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | or so: | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | =head2 class_method $obj THINGY::new(%args) | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | Creates a new THINGY object | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | my($class, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 64 | return bless(\%args, $class); | ||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | All other POD documentation (including other =head2 tags) is added as HTML | ||||||||||||||||||||||||||||||||||||||||||
| 69 | (provided by Pod::POM::View::HTML) into the Doxygen section named | ||||||||||||||||||||||||||||||||||||||||||
| 70 | B<Detailed Description>. IMHO it looks better when this is at the top of the | ||||||||||||||||||||||||||||||||||||||||||
| 71 | doxygen docs. Look under L</DETAILS ON TOP> on how to do that. | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | =head1 FUNCTION HEADERS | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | The complete syntax of a =head2 function description is: | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | C<< =head2 [<category>] [<return_value>] <name>(<parameters>) >> | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | =item category (optional) | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | The category defines the type of the function definition. The values | ||||||||||||||||||||||||||||||||||||||||||
| 84 | C<function> and C<class_method> result in the function being tagged | ||||||||||||||||||||||||||||||||||||||||||
| 85 | as B<static> for Doxygen. Other values will be ignored, which will result | ||||||||||||||||||||||||||||||||||||||||||
| 86 | interpreting the function as method. | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | =item return_value (optional) | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | Since Doxygen expects C++ input, a return value is mandatory and will | ||||||||||||||||||||||||||||||||||||||||||
| 91 | default to B<void>. A given string will be passed to Doxygen as is, so be | ||||||||||||||||||||||||||||||||||||||||||
| 92 | careful with non word characters. | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | =item name | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | The function name with optional package name e.g. C<My::Module::test>. The | ||||||||||||||||||||||||||||||||||||||||||
| 97 | module will try to map the function name to the current package when none is | ||||||||||||||||||||||||||||||||||||||||||
| 98 | given. If your code is correctly parsable with PPI, then this should work. | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | If the corresponding subroutine is not found it will be tagged as B<virtual> | ||||||||||||||||||||||||||||||||||||||||||
| 101 | to Doxygen. This is useful for dynamically generated functions (e.g via | ||||||||||||||||||||||||||||||||||||||||||
| 102 | AUTOLOAD). Yes this has nothing to do with the C++ virtual keyword, but so | ||||||||||||||||||||||||||||||||||||||||||
| 103 | what? If you want to have the virtual subroutine mapped to the correct | ||||||||||||||||||||||||||||||||||||||||||
| 104 | namespace you will have to add it to the subs name | ||||||||||||||||||||||||||||||||||||||||||
| 105 | (e.g. C< MyClass::mysub() >) | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | Subroutine names with leading underscore will be tagged as B<private> | ||||||||||||||||||||||||||||||||||||||||||
| 108 | for Doxygen. | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | If there is no package declaration, the subroutine is created in the main | ||||||||||||||||||||||||||||||||||||||||||
| 111 | namespace, named C<< <script_or_module_name>_main >>. | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | =item parameters | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | The subroutine's comma separated parameter list. References are given in | ||||||||||||||||||||||||||||||||||||||||||
| 116 | dereference syntax so C<%$varname> specifies a hash reference. This will | ||||||||||||||||||||||||||||||||||||||||||
| 117 | be given as C<type name> to Doxygen e.g. C<subname(hash_ref varname)>. | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | =head1 SIGNATURES | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | If you are using subroutine signatures, they will be parsed for information | ||||||||||||||||||||||||||||||||||||||||||
| 124 | and you can put the pod after the sub declaration like so: | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | sub my_sig_sub ($self, $first = 'default', $second=[], %args) { | ||||||||||||||||||||||||||||||||||||||||||
| 127 | =for method $self | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | Sub documentation. | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | print join(' ', $first, @$second), "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 134 | return $self; | ||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | In that case there is no redundant information you'll have to synchronize on | ||||||||||||||||||||||||||||||||||||||||||
| 138 | each change. | ||||||||||||||||||||||||||||||||||||||||||
| 139 | In that case the first parameter behind the B<=for> has to be C<method>, | ||||||||||||||||||||||||||||||||||||||||||
| 140 | C<function> or C<class_method>. The second parameter specifies the return | ||||||||||||||||||||||||||||||||||||||||||
| 141 | value. Both parameters must be present because the =for tag requires them. | ||||||||||||||||||||||||||||||||||||||||||
| 142 | There are no defaults. | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | A conflicting B<=head2> declaration for the same subroutine will take | ||||||||||||||||||||||||||||||||||||||||||
| 145 | precedence. | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | =head1 DETAILS ON TOP | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | For having the non subroutine POD documentation at the top of the Doxygen | ||||||||||||||||||||||||||||||||||||||||||
| 150 | page do the following: | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | =item 1. | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | Create a doxygen layout XML file with C<doxygen -l> | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | =item 2. | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | Edit the XML file. Move C<< <detaileddescription title=""/> >> up to the | ||||||||||||||||||||||||||||||||||||||||||
| 161 | line directly behind C<< <briefdescription visible="yes"/> >> | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | =item 3. | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | Specify the file under C<LAYOUT_FILE> in your Doxyfile. | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | ▶ | use parent 'PPI::Transform'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | ▶ | use PPI; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | ▶ | use File::Basename qw(fileparse); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | ▶ | use Pod::POM; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | ▶ | use Pod::POM::View::Text; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | ▶ | use PPI::Transform::Doxygen::POD; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | ▶ | use Params::Util qw{_INSTANCE}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | our $VERSION = '0.33'; | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 2 | my %vtype = qw(% hash @ array $ scalar & func * glob); | |||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | my %defaults = ( | |||||||||||||||||||||||||||||||||||||||||
| 191 | rx_version => qr/our\s*\$VERSION\s*=\s*["']([\d\.]+)/, | ||||||||||||||||||||||||||||||||||||||||||
| 192 | rx_revision => qr/\$(?:Id|Rev|Revision|LastChangedRevision)\:\s*(\d+)\s*\$/, | ||||||||||||||||||||||||||||||||||||||||||
| 193 | rx_parent => qr/use\s+(?:base|parent|Mojo::Base)\s+["']?([\w:]+)["']?/, | ||||||||||||||||||||||||||||||||||||||||||
| 194 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | #================================================= | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | =head2 $obj new(%args) | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | B<Constructor> | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | There are 3 optional arguments for extracting a version number, a revision | ||||||||||||||||||||||||||||||||||||||||||
| 203 | number and the parent class. Their values have to consist of a regex with one | ||||||||||||||||||||||||||||||||||||||||||
| 204 | capture group. The key C<<overwrite>> defines the behaviour when there is no | ||||||||||||||||||||||||||||||||||||||||||
| 205 | output device on calling C<<file()>>. Default behaviour is to append the | ||||||||||||||||||||||||||||||||||||||||||
| 206 | doxygen docs after an __END__ Token. Setting overwrite to a true value will | ||||||||||||||||||||||||||||||||||||||||||
| 207 | overwrite the input file. | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | The defaults are: | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | rx_version => qr/our\s*\$VERSION\s*=\s*["']([\d\.]+)/, | ||||||||||||||||||||||||||||||||||||||||||
| 212 | rx_revision => qr/\$(?:Id|Rev|Revision|LastChangedRevision)\:\s*(\d+)\s*\$/, | ||||||||||||||||||||||||||||||||||||||||||
| 213 | rx_parent => qr/use\s+(?:base|parent|Mojo::Base)\s+["']?([\w:]+)["']?/, | ||||||||||||||||||||||||||||||||||||||||||
| 214 | overwrite => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | ▶ | my ( $class, %args ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | my $self = shift->SUPER::new(%defaults); | |||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 2 | @$self{ keys %args } = values %args; | |||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | #================================================= | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | =head2 file($in, $out) | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | Start the transformation reading from C<$in> and saving to C<$out>. C<$in> | ||||||||||||||||||||||||||||||||||||||||||
| 233 | has to be a filename and C<$out> can be a filename or a filehandle. | ||||||||||||||||||||||||||||||||||||||||||
| 234 | If C<$out> is not given, behaviour is defined by the parameter overwrite | ||||||||||||||||||||||||||||||||||||||||||
| 235 | (see C<new()>). | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | sub file { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 3 | ▶ | my ($self, $in, $out) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file: called CC=7 SCAR=22.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 3 | ▶ | return unless $in; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 3 | ▶ | my $preserve = !$out && !$self->{overwrite}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$out || $self->{'overwrite'}
MC/DC0%0/2
$out || $self->{'overwrite'}
$out
$self->{'overwrite'}
Truth table33%1/3
A || B
A= $outB= $self->{'overwrite'}
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 3 | ▶ | my $Document = PPI::Document->new($in) or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 3 | $Document->{_in_fn} = $in; | |||||||||||||||||||||||||||||||||||||||||
| 248 | 3 | ▶ | $self->document($Document, $preserve) or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 3 | ▶ | $out //= $in; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$out //= $in
MC/DC0%0/2
$out //= $in
$out
$in
Truth table33%1/3
A //= B
A= $outB= $in
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 3 | ▶ | if ( ref($out) eq 'GLOB' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 3 | print $out $Document->serialize(); | |||||||||||||||||||||||||||||||||||||||||
| 254 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $Document->save($out); | |||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | #================================================= | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | =head2 document($ppi_doc, $preserve) | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | This is normally called by C<file()> (see the docs for | ||||||||||||||||||||||||||||||||||||||||||
| 264 | L<PPI::Transform>). It will convert a PPI::Document object | ||||||||||||||||||||||||||||||||||||||||||
| 265 | in place. | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | sub document { | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 3 | ▶ | my ( $self, $doc, $preserve ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
document: called CC=10 SCAR=23.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 3 | ▶ | _INSTANCE( $doc, 'PPI::Document' ) or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 3 | my $pkg_subs = $self->_parse_packages_subs($doc); | |||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 3 | my($fname, $fdir, $fext) = fileparse( $doc->{_in_fn}, qr/\..*/ ); | |||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 3 | my($pod_txt, $sub_info) = $self->_parse_pod($doc, $fname); | |||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 3 | _integrate_sub_info($pkg_subs, $sub_info); | |||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 3 | my @packages = sort keys %$pkg_subs; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 3 | ▶ | my $file_pod = $pod_txt if @packages == 1 and $packages[0] eq '!main'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@packages == 1 and $packages[0] eq "!main"
MC/DC50%1/2
@packages == 1 and $packages[0] eq "!main"
@packages == 1
$packages[0] eq "!main"
Truth table66%2/3
A and B
A= @packages == 1B= $packages[0] eq "!main"
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 3 | my $dxout = _out_head($fname . $fext, $file_pod); | |||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 3 | for my $pname ( @packages ) { | |||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 3 | my @parts = split( /::/, $pname ); | |||||||||||||||||||||||||||||||||||||||||
| 290 | 3 | my $short = pop @parts; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 3 | ▶ | my $namespace = join( '::', @parts ) || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
join('::', @parts) || ''
MC/DC100%1/1
join('::', @parts) || ''
join('::', @parts)
Truth table100%2/2
A
A= join('::', @parts)
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | $dxout .= _out_class_begin( | ||||||||||||||||||||||||||||||||||||||||||
| 294 | $pname, $short, $namespace, $fname, | ||||||||||||||||||||||||||||||||||||||||||
| 295 | $pkg_subs->{$pname}{inherit}, | ||||||||||||||||||||||||||||||||||||||||||
| 296 | $pkg_subs->{$pname}{used}, | ||||||||||||||||||||||||||||||||||||||||||
| 297 | $pkg_subs->{$pname}{version}, | ||||||||||||||||||||||||||||||||||||||||||
| 298 | $pkg_subs->{$pname}{revision}, | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 3 | ▶ | $short eq $fname ? $pod_txt : '', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 3 | $dxout .= _out_process_subs( $pname, $pkg_subs, $sub_info ); | |||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 3 | $dxout .= _out_class_end($namespace); | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 3 | ▶ | unless ($preserve) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 3 | $_->delete for $doc->children(); | |||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 3 | ▶ | my $end_tok = $doc->find_first('PPI::Token::End') || PPI::Token::End->new(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$doc->find_first('PPI::Token::End') || 'PPI::Token::End'->new
MC/DC0%0/2
$doc->find_first('PPI::Token::End') || 'PPI::Token::End'->new
$doc->find_first('PPI::Token::End')
'PPI::Token::End'->new
Truth table33%1/3
A || B
A= $doc->find_first('PPI::Token::End')B= 'PPI::Token::End'->new
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 3 | $end_tok->add_content($dxout); | |||||||||||||||||||||||||||||||||||||||||
| 313 | 3 | $doc->add_element($end_tok); | |||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 49 | ▶ | sub _strip { my $str = shift; $str =~ s/^ +//mg; $str } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_strip: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | sub _out_head { | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 3 | ▶ | my($fn, $txt) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_out_head: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | 3 | ▶ | $txt //= ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$txt //= ""
MC/DC100%1/1
$txt //= ""
$txt
Truth table100%2/2
A
A= $txt
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 3 | my $out = _strip(qq( | |||||||||||||||||||||||||||||||||||||||||
| 325 | /** \@file $fn | ||||||||||||||||||||||||||||||||||||||||||
| 326 | $txt | ||||||||||||||||||||||||||||||||||||||||||
| 327 | */ | ||||||||||||||||||||||||||||||||||||||||||
| 328 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | 3 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | sub _get_used_modules { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 3 | ▶ | my($root) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_used_modules: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 3 | my %used; | |||||||||||||||||||||||||||||||||||||||||
| 338 | 3 | for my $chld ( $root->schildren() ) { | |||||||||||||||||||||||||||||||||||||||||
| 339 | 52 | ▶ | next unless $chld->isa('PPI::Statement::Include'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 10 | ▶ | next if $chld->pragma(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | 6 | $used{$chld->module()} = 1 | |||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||
| 343 | 3 | return \%used; | |||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 2 | my %modifier = ( | |||||||||||||||||||||||||||||||||||||||||
| 348 | has => '<b>Accessor Method</b>', | ||||||||||||||||||||||||||||||||||||||||||
| 349 | before => '<b>Method Modifier: <i>before</i></b>', | ||||||||||||||||||||||||||||||||||||||||||
| 350 | after => '<b>Method Modifier: <i>after</i></b>', | ||||||||||||||||||||||||||||||||||||||||||
| 351 | around => '<b>Method Modifier: <i>around</i></b>', | ||||||||||||||||||||||||||||||||||||||||||
| 352 | fresh => '<b>Method Modifier: <i>fresh</i></b>', | ||||||||||||||||||||||||||||||||||||||||||
| 353 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | sub _parse_packages_subs { | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 3 | ▶ | my($self, $doc) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_packages_subs: called CC=17 SCAR=28.3
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 3 | my %pkg_subs; | |||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | my @main_pkgs = grep { | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 3 | $_->isa('PPI::Statement::Package') | |||||||||||||||||||||||||||||||||||||||||
| 363 | } $doc->children(); | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | 3 | ▶ | unless (@main_pkgs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 2 | $pkg_subs{'!main'}{used} = _get_used_modules($doc); | |||||||||||||||||||||||||||||||||||||||||
| 367 | 2 | my($v, $r) = $self->_get_pkg_version($doc); | |||||||||||||||||||||||||||||||||||||||||
| 368 | 2 | $pkg_subs{'!main'}{version} = $v; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 2 | $pkg_subs{'!main'}{revision} = $r; | |||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 3 | ▶ | my $stmt_nodes = $doc->find('PPI::Statement') || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$doc->find('PPI::Statement') || []
MC/DC0%0/1
$doc->find('PPI::Statement') || []
$doc->find('PPI::Statement')
Truth table50%1/2
A
A= $doc->find('PPI::Statement')
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 3 | for my $stmt_node ( @$stmt_nodes ) { | |||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 148 | my $pkg = '!main'; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 148 | my $mod = $stmt_node->child(0); | |||||||||||||||||||||||||||||||||||||||||
| 377 | next unless $stmt_node->class() eq 'PPI::Statement::Sub' | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 148 | ▶ | or $modifier{$mod}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$stmt_node->class eq "PPI::Statement::Sub" or $modifier{$mod}
MC/DC100%2/2
$stmt_node->class eq "PPI::Statement::Sub" or $modifier{$mod}
$stmt_node->class eq "PPI::Statement::Sub"
$modifier{$mod}
Truth table100%3/3
A or B
A= $stmt_node->class eq "PPI::Statement::Sub"B= $modifier{$mod}
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 19 | my $node = $stmt_node; | |||||||||||||||||||||||||||||||||||||||||
| 381 | 19 | ▶ | while ($node) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 856 | ▶ | if ( $node->class() eq 'PPI::Statement::Package' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 13 | $pkg = $node->namespace(); | |||||||||||||||||||||||||||||||||||||||||
| 384 | 13 | ▶ | unless ( $pkg_subs{$pkg}{version} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 13 | my($v, $r) = $self->_get_pkg_version($node->parent()); | |||||||||||||||||||||||||||||||||||||||||
| 386 | 13 | $pkg_subs{$pkg}{version} = $v; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 13 | $pkg_subs{$pkg}{revision} = $r; | |||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | 13 | ▶ | unless ( defined $pkg_subs{$pkg}{inherit} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | my ($inherit) = _find_first_regex( | ||||||||||||||||||||||||||||||||||||||||||
| 391 | $node->parent(), | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 'PPI::Statement::Include', | ||||||||||||||||||||||||||||||||||||||||||
| 393 | $self->{rx_parent}, | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 395 | 1 | $pkg_subs{$pkg}{inherit} = $inherit; | |||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | 13 | ▶ | unless ( defined $pkg_subs{$pkg}{used} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | my $parent = $node->parent(); | |||||||||||||||||||||||||||||||||||||||||
| 399 | 1 | ▶ | $pkg_subs{$pkg}{used} = _get_used_modules($parent) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | if $parent; | ||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 403 | 856 | ▶ | $node = $node->previous_sibling() || $node->parent(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$node->previous_sibling || $node->parent
MC/DC100%2/2
$node->previous_sibling || $node->parent
$node->previous_sibling
$node->parent
Truth table100%3/3
A || B
A= $node->previous_siblingB= $node->parent
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | 19 | ▶ | my $sub_name = $stmt_node->class() eq 'PPI::Statement::Sub' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | ? $stmt_node->name | ||||||||||||||||||||||||||||||||||||||||||
| 408 | : $stmt_node->child(2)->content; | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | # split has sub_name => [qw(one two three)] | ||||||||||||||||||||||||||||||||||||||||||
| 411 | 19 | ▶ | for my $sn ( grep { /\w/ && $_ ne 'qw' } split(/\W+/, $sub_name) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | 22 | $pkg_subs{$pkg}{subs}{$sn} = $stmt_node; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 22 | ▶ | $pkg_subs{$pkg}{mtype}{$sn} = $modifier{$mod} if $modifier{$mod}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 3 | return \%pkg_subs; | |||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | sub _out_process_subs { | ||||||||||||||||||||||||||||||||||||||||||
| 422 | 3 | ▶ | my($class, $pkg_subs, $sub_info) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_out_process_subs: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 3 | my $sub_nodes = $pkg_subs->{$class}{subs}; | |||||||||||||||||||||||||||||||||||||||||
| 425 | 3 | my $mod_types = $pkg_subs->{$class}{mtype}; | |||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 3 | my $out = ''; | |||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 3 | my %types; | |||||||||||||||||||||||||||||||||||||||||
| 430 | 3 | for my $sname ( sort keys %$sub_nodes ) { | |||||||||||||||||||||||||||||||||||||||||
| 431 | 23 | ▶ | my $si = $sub_info->{$sname} || { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$sub_info->{$sname} || {'type', $sname =~ /^_/ ? 'private' : 'public', 'rv', 'void', 'params', [], 'name', $sname, 'static', 0, 'virtual', 0, 'class', $class, 'text', '<p>Undocumented Function</p>'}
MC/DC100%1/1
$sub_info->{$sname} || {'type', $sname =~ /^_/ ? 'private' : 'public', 'rv', 'void', 'params', [], 'name', $sname, 'static', 0, 'virtual', 0, 'class', $class, 'text', '<p>Undocumented Function</p>'}
$sub_info->{$sname}
Truth table100%2/2
A
A= $sub_info->{$sname}
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | type => $sname =~ /^_/ ? 'private' : 'public', | ||||||||||||||||||||||||||||||||||||||||||
| 433 | rv => 'void', | ||||||||||||||||||||||||||||||||||||||||||
| 434 | params => [], | ||||||||||||||||||||||||||||||||||||||||||
| 435 | name => $sname, | ||||||||||||||||||||||||||||||||||||||||||
| 436 | static => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 437 | virtual => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 438 | class => $class, | ||||||||||||||||||||||||||||||||||||||||||
| 439 | text => '<p>Undocumented Function</p>', | ||||||||||||||||||||||||||||||||||||||||||
| 440 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 441 | 23 | $types{ $si->{type} }{$sname} = $si; | |||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 3 | for my $type (qw/public private/) { | |||||||||||||||||||||||||||||||||||||||||
| 445 | 6 | $out .= "$type:\n"; | |||||||||||||||||||||||||||||||||||||||||
| 446 | 6 | for my $sname ( sort keys %{ $types{$type} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 447 | 23 | my $si = $types{$type}{$sname}; | |||||||||||||||||||||||||||||||||||||||||
| 448 | 23 | ▶ | my @static = $si->{static} ? 'static' : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 449 | 23 | ▶ | my @virtual = $si->{virtual} ? 'virtual' : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 23 | my $fstr = join( ' ', @static, @virtual, $si->{rv}, "$sname(" ); | |||||||||||||||||||||||||||||||||||||||||
| 452 | 23 | $fstr .= join( ', ', @{ $si->{params} } ); | |||||||||||||||||||||||||||||||||||||||||
| 453 | 23 | $fstr .= ')'; | |||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 23 | $out .= "/** \@fn $fstr\n"; | |||||||||||||||||||||||||||||||||||||||||
| 456 | 23 | ▶ | $out .= "$mod_types->{$sname}\n" if $mod_types->{$sname}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | 23 | $out .= $si->{text} . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 458 | 23 | $out .= _out_html_code( $sname, $sub_nodes->{$sname} ); | |||||||||||||||||||||||||||||||||||||||||
| 459 | 23 | $out .= "*/\n"; | |||||||||||||||||||||||||||||||||||||||||
| 460 | 23 | $out .= $fstr . ";\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | 3 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | sub _out_class_begin { | ||||||||||||||||||||||||||||||||||||||||||
| 469 | 3 | ▶ | my($pname, $pkg_short, $namespace, $fname, $inherit, $used, $ver, $rev, $pod_txt) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_out_class_begin: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 3 | ▶ | if ( $pname eq '!main' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 2 | $pkg_short = $pname = "${fname}_main"; | |||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | 3 | my $out = ''; | |||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 3 | ▶ | $out .= "namespace $namespace {\n" if $namespace; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | 3 | $out .= "\n/** \@class $pname\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 480 | 3 | ▶ | $out .= "\@version $ver" if $ver; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 481 | 3 | ▶ | $out .= " rev:$rev" if $rev; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 3 | $out .= "\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | 3 | ▶ | if ($used) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 3 | $out .= "\@section ${pkg_short}_USED_MODULES USED_MODULES\n"; | |||||||||||||||||||||||||||||||||||||||||
| 486 | 3 | $out .= "<ul>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 487 | 3 | for my $uname ( sort keys %$used ) { | |||||||||||||||||||||||||||||||||||||||||
| 488 | 6 | $out .= "<li>$uname</li>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 3 | $out .= "</ul>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | 3 | $out .= "$pod_txt\n*/\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | 3 | $out .= "class $pkg_short: public"; | |||||||||||||||||||||||||||||||||||||||||
| 496 | 3 | ▶ | $out .= " ::$inherit" if $inherit; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 3 | $out .= " {\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 3 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | sub _out_class_end { | ||||||||||||||||||||||||||||||||||||||||||
| 504 | 3 | ▶ | my($namespace) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_out_class_end: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | 3 | my $out = "};\n"; | |||||||||||||||||||||||||||||||||||||||||
| 507 | 3 | ▶ | $out .= "};\n" if $namespace; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 3 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | sub _parse_pod { | ||||||||||||||||||||||||||||||||||||||||||
| 514 | 3 | ▶ | my($self, $doc, $fname) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_pod: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | 3 | my $parser = Pod::POM->new(); | |||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | 3 | my $txt = ''; | |||||||||||||||||||||||||||||||||||||||||
| 519 | 3 | my %subs; | |||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | 3 | my $pod_tokens = $doc->find('PPI::Token::Pod'); | |||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | 3 | ▶ | return '', \%subs unless $pod_tokens; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | 2 | ▶ | no warnings qw(once); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 526 | 2 | $PPI::Transform::Doxygen::POD::PREFIX = $fname; | |||||||||||||||||||||||||||||||||||||||||
| 527 | 2 | for my $tok ( @$pod_tokens ) { | |||||||||||||||||||||||||||||||||||||||||
| 528 | 16 | ( my $quoted = $tok->content() ) =~ s/(\@|\\|\%|#)/\\$1/g; | |||||||||||||||||||||||||||||||||||||||||
| 529 | 16 | my $pom = $parser->parse_text($quoted); | |||||||||||||||||||||||||||||||||||||||||
| 530 | 16 | _filter_head2( $pom, \%subs ); | |||||||||||||||||||||||||||||||||||||||||
| 531 | 16 | $txt .= PPI::Transform::Doxygen::POD->print($pom); | |||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 2 | return $txt, \%subs; | |||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | sub _filter_head2 { | ||||||||||||||||||||||||||||||||||||||||||
| 539 | 35 | ▶ | my($pom, $sub_ref) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filter_head2: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | 35 | for my $sn ( @{ $pom->content() } ) { | |||||||||||||||||||||||||||||||||||||||||
| 541 | 27 | ▶ | if ( $sn->type() eq 'head2' and $sn->title() =~ /[\w:]+\s*\(.*\)/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$sn->type eq "head2" and $sn->title =~ /[\w:]+\s*\(.*\)/
MC/DC100%2/2
$sn->type eq "head2" and $sn->title =~ /[\w:]+\s*\(.*\)/
$sn->type eq "head2"
$sn->title =~ /[\w:]+\s*\(.*\)/
Truth table100%3/3
A and B
A= $sn->type eq "head2"B= $sn->title =~ /[\w:]+\s*\(.*\)/
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | 8 | my $sinfo = _sub_extract( $sn->title() ); | |||||||||||||||||||||||||||||||||||||||||
| 543 | 8 | ▶ | if ( $sinfo ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | 8 | ▶ | $sinfo->{text} = PPI::Transform::Doxygen::POD->print($sn) // ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
"PPI::Transform::Doxygen::POD"->print($sn) // ""
MC/DC0%0/1
"PPI::Transform::Doxygen::POD"->print($sn) // ""
"PPI::Transform::Doxygen::POD"->print($sn)
Truth table50%1/2
A
A= "PPI::Transform::Doxygen::POD"->print($sn)
| |||||||||||||||||||||||||||||||||||||||||||
| 545 | 8 | $sub_ref->{$sinfo->{name}} = $sinfo; | |||||||||||||||||||||||||||||||||||||||||
| 546 | 8 | $sn = ''; | |||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||
| 549 | 27 | ▶ | _filter_head2($sn, $sub_ref) if $sn; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | 2 | my $rx_name_parms = qr/\s*([\w:]+)\s*\(\s*([^\)]*)\s*\)$/; | |||||||||||||||||||||||||||||||||||||||||
| 555 | sub _sub_extract { | ||||||||||||||||||||||||||||||||||||||||||
| 556 | 8 | ▶ | my($str) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sub_extract: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | 8 | my($long, $params) = $str =~ /$rx_name_parms/; | |||||||||||||||||||||||||||||||||||||||||
| 560 | 8 | ▶ | return unless $long; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | 8 | $str =~ s/$rx_name_parms//; | |||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||
| 564 | 8 | my @parts = split(/\s+/, $str); | |||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | 8 | ▶ | my $rv = pop(@parts) || 'void'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
pop @parts || 'void'
MC/DC100%1/1
pop @parts || 'void'
pop @parts
Truth table100%2/2
A
A= pop @parts
| |||||||||||||||||||||||||||||||||||||||||||
| 567 | 8 | $rv =~ s/(\%|\@|\&)/\\$1/g; | |||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | 8 | ▶ | my $cat = pop(@parts) || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
pop @parts || ''
MC/DC100%1/1
pop @parts || ''
pop @parts
Truth table100%2/2
A
A= pop @parts
| |||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | 8 | my @params = _add_type($params); | |||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | 8 | my @nparts = split( /::/, $long ); | |||||||||||||||||||||||||||||||||||||||||
| 574 | 8 | my $name = pop @nparts; | |||||||||||||||||||||||||||||||||||||||||
| 575 | 8 | ▶ | my $class = join( '::', @nparts ) || '!main'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
join('::', @nparts) || '!main'
MC/DC0%0/1
join('::', @nparts) || '!main'
join('::', @nparts)
Truth table50%1/2
A
A= join('::', @nparts)
| |||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | 8 | ▶ | my $static = $cat eq 'function' || $cat eq 'class_method'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$cat eq 'function' || $cat eq 'class_method'
MC/DC100%2/2
$cat eq 'function' || $cat eq 'class_method'
$cat eq 'function'
$cat eq 'class_method'
Truth table100%3/3
A || B
A= $cat eq 'function'B= $cat eq 'class_method'
| |||||||||||||||||||||||||||||||||||||||||||
| 578 | 8 | ▶ | my $type = $name =~ /^_/ ? 'private' : 'public'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 581 | 8 | type => $type, | |||||||||||||||||||||||||||||||||||||||||
| 582 | rv => $rv, | ||||||||||||||||||||||||||||||||||||||||||
| 583 | params => \@params, | ||||||||||||||||||||||||||||||||||||||||||
| 584 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 585 | static => $static, | ||||||||||||||||||||||||||||||||||||||||||
| 586 | class => $class, | ||||||||||||||||||||||||||||||||||||||||||
| 587 | text => '', | ||||||||||||||||||||||||||||||||||||||||||
| 588 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||
| 592 | sub _add_type { | ||||||||||||||||||||||||||||||||||||||||||
| 593 | 15 | ▶ | return unless my $params = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_type: called CC=6 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | 14 | ▶ | unless ( ref($params) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 596 | 7 | $params =~ s/\s//g; | |||||||||||||||||||||||||||||||||||||||||
| 597 | 7 | $params = [ split(/,/, $params) ]; | |||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | return map { | ||||||||||||||||||||||||||||||||||||||||||
| 601 | 14 | my @sig = $_ =~ /^(.)(.)(.?)/; | |||||||||||||||||||||||||||||||||||||||||
| 602 | 25 | ▶ | if ( $sig[0] eq '\\' ) { shift @sig } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | 25 | my $ref; | |||||||||||||||||||||||||||||||||||||||||
| 604 | 25 | ▶ | if ( $sig[1] eq '$' ) { $ref = 1; splice(@sig, 1, 1) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 605 | 25 | my $typ = $vtype{ $sig[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 606 | 25 | ▶ | $typ .= '_ref' if $ref; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 607 | 25 | s/^\W*//; | |||||||||||||||||||||||||||||||||||||||||
| 608 | 25 | $_ = "$typ $_"; | |||||||||||||||||||||||||||||||||||||||||
| 609 | } @$params; | ||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | sub _find_first_regex { | ||||||||||||||||||||||||||||||||||||||||||
| 614 | 31 | ▶ | my($root, $name, $regex) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_first_regex: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 615 | 31 | for my $chld ( $root->schildren() ) { | |||||||||||||||||||||||||||||||||||||||||
| 616 | 479 | ▶ | next unless $chld->isa($name); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 617 | 15 | ▶ | if ( my @capture = $chld->content() =~ /$regex/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | return @capture; | |||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||
| 621 | 31 | return ''; | |||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | sub _get_pkg_version { | ||||||||||||||||||||||||||||||||||||||||||
| 626 | 15 | ▶ | my($self, $root) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_pkg_version: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 627 | my($version) = _find_first_regex( | ||||||||||||||||||||||||||||||||||||||||||
| 628 | $root, | ||||||||||||||||||||||||||||||||||||||||||
| 629 | 'PPI::Statement::Variable', | ||||||||||||||||||||||||||||||||||||||||||
| 630 | $self->{rx_version}, | ||||||||||||||||||||||||||||||||||||||||||
| 631 | 15 | ); | |||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||
| 633 | my($revision) = _find_first_regex( | ||||||||||||||||||||||||||||||||||||||||||
| 634 | $root, | ||||||||||||||||||||||||||||||||||||||||||
| 635 | 'PPI::Statement::Variable', | ||||||||||||||||||||||||||||||||||||||||||
| 636 | $self->{rx_revision}, | ||||||||||||||||||||||||||||||||||||||||||
| 637 | 15 | ); | |||||||||||||||||||||||||||||||||||||||||
| 638 | 15 | return $version, $revision; | |||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | sub _out_html_code { | ||||||||||||||||||||||||||||||||||||||||||
| 643 | 23 | ▶ | my($sname, $sub) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_out_html_code: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | 23 | my $html = _strip(qq( | |||||||||||||||||||||||||||||||||||||||||
| 646 | \@htmlonly | ||||||||||||||||||||||||||||||||||||||||||
| 647 | <div id='codesection-$sname' class='dynheader closed' style='cursor:pointer;' onclick='return toggleVisibility(this)'> | ||||||||||||||||||||||||||||||||||||||||||
| 648 | <img id='codesection-$sname-trigger' src='closed.png' style='display:inline'><b>Code:</b> | ||||||||||||||||||||||||||||||||||||||||||
| 649 | </div> | ||||||||||||||||||||||||||||||||||||||||||
| 650 | <div id='codesection-$sname-summary' class='dyncontent' style='display:block;font-size:small;'>click to view</div> | ||||||||||||||||||||||||||||||||||||||||||
| 651 | <div id='codesection-$sname-content' class='dyncontent' style='display: none;'> | ||||||||||||||||||||||||||||||||||||||||||
| 652 | \@endhtmlonly | ||||||||||||||||||||||||||||||||||||||||||
| 653 | \@code | ||||||||||||||||||||||||||||||||||||||||||
| 654 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | 23 | $html .= $sub; | |||||||||||||||||||||||||||||||||||||||||
| 657 | 23 | $html .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||
| 659 | 23 | $html .= _strip(q( | |||||||||||||||||||||||||||||||||||||||||
| 660 | @endcode | ||||||||||||||||||||||||||||||||||||||||||
| 661 | @htmlonly | ||||||||||||||||||||||||||||||||||||||||||
| 662 | </div> | ||||||||||||||||||||||||||||||||||||||||||
| 663 | @endhtmlonly | ||||||||||||||||||||||||||||||||||||||||||
| 664 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||
| 666 | 23 | return $html; | |||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | sub _sub_info_from_node { | ||||||||||||||||||||||||||||||||||||||||||
| 671 | 15 | ▶ | my($sname, $class, $node) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sub_info_from_node: called CC=15 SCAR=27.1
| |||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | 15 | ▶ | return undef unless $node->class eq 'PPI::Statement::Sub' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$node->class eq "PPI::Statement::Sub" or $node->children > 6 and $node->child(6)->content eq "sub"
$node->children > 6 and $node->child(6)->content eq "sub"
MC/DC66%2/3
$node->class eq "PPI::Statement::Sub" or $node->children > 6 and $node->child(6)->content eq "sub"
$node->class eq "PPI::Statement::Sub"
$node->children > 6
$node->child(6)->content eq "sub"
Truth table75%3/4
A or B and C
A= $node->class eq "PPI::Statement::Sub"B= $node->children > 6C= $node->child(6)->content eq "sub"
| |||||||||||||||||||||||||||||||||||||||||||
| 674 | or ($node->children > 6 and $node->child(6)->content eq 'sub'); | ||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||
| 676 | 9 | my $parser = Pod::POM->new(); | |||||||||||||||||||||||||||||||||||||||||
| 677 | 9 | my %si; | |||||||||||||||||||||||||||||||||||||||||
| 678 | 9 | my $txt = my $def = my $fmt = ''; | |||||||||||||||||||||||||||||||||||||||||
| 679 | 9 | my @params; | |||||||||||||||||||||||||||||||||||||||||
| 680 | 9 | my($rv, $static); | |||||||||||||||||||||||||||||||||||||||||
| 681 | 9 | ▶ | my $type = $sname =~ /^_/ ? 'private' : 'public'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | 9 | ▶ | my $pod = $node->find('PPI::Token::Pod') || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$node->find('PPI::Token::Pod') || []
MC/DC100%1/1
$node->find('PPI::Token::Pod') || []
$node->find('PPI::Token::Pod')
Truth table100%2/2
A
A= $node->find('PPI::Token::Pod')
| |||||||||||||||||||||||||||||||||||||||||||
| 684 | 9 | for my $tok ( @$pod ) { | |||||||||||||||||||||||||||||||||||||||||
| 685 | 4 | ( my $quoted = $tok ) =~ s/(\@|\\|\%|#)/\\$1/g; | |||||||||||||||||||||||||||||||||||||||||
| 686 | 4 | my $pom = $parser->parse_text($quoted); | |||||||||||||||||||||||||||||||||||||||||
| 687 | 4 | ▶ | next unless my $for = $pom->for->[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 688 | 4 | $rv = $for->text; | |||||||||||||||||||||||||||||||||||||||||
| 689 | 4 | $fmt = $for->format; | |||||||||||||||||||||||||||||||||||||||||
| 690 | 4 | ▶ | $static = $fmt eq 'function' || $fmt eq 'class_method'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$fmt eq 'function' || $fmt eq 'class_method'
MC/DC100%2/2
$fmt eq 'function' || $fmt eq 'class_method'
$fmt eq 'function'
$fmt eq 'class_method'
Truth table100%3/3
A || B
A= $fmt eq 'function'B= $fmt eq 'class_method'
| |||||||||||||||||||||||||||||||||||||||||||
| 691 | 4 | $txt .= PPI::Transform::Doxygen::POD->print($pom); | |||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||
| 693 | 9 | ▶ | my $proto = $node->find('PPI::Token::Prototype') || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$node->find('PPI::Token::Prototype') || []
MC/DC100%1/1
$node->find('PPI::Token::Prototype') || []
$node->find('PPI::Token::Prototype')
Truth table100%2/2
A
A= $node->find('PPI::Token::Prototype')
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | 9 | for my $tok ( @$proto ) { | |||||||||||||||||||||||||||||||||||||||||
| 695 | 7 | for my $pmt ( split(/,/, $tok->prototype) ) { | |||||||||||||||||||||||||||||||||||||||||
| 696 | 17 | my($attr, $default) = split(/=/, $pmt); | |||||||||||||||||||||||||||||||||||||||||
| 697 | 17 | push @params, $attr; | |||||||||||||||||||||||||||||||||||||||||
| 698 | 17 | ▶ | next unless $default; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 699 | 3 | $def .= "<p>Default value for $attr is $default.</p>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||
| 701 | 7 | @params = _add_type(\@params); | |||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | 9 | ▶ | return undef unless $txt; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||
| 706 | 4 | ▶ | $txt .= "\n$def" if $def; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||
| 708 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 709 | 4 | type => $type, | |||||||||||||||||||||||||||||||||||||||||
| 710 | rv => $rv, | ||||||||||||||||||||||||||||||||||||||||||
| 711 | params => \@params, | ||||||||||||||||||||||||||||||||||||||||||
| 712 | name => $sname, | ||||||||||||||||||||||||||||||||||||||||||
| 713 | static => $static, | ||||||||||||||||||||||||||||||||||||||||||
| 714 | class => $class, | ||||||||||||||||||||||||||||||||||||||||||
| 715 | text => $txt, | ||||||||||||||||||||||||||||||||||||||||||
| 716 | regex => qr/\r?\n=for\s+$fmt\s+\Q$rv\E.+?\r?\n=cut\n\n?/s, | ||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||
| 721 | sub _integrate_sub_info { | ||||||||||||||||||||||||||||||||||||||||||
| 722 | 3 | ▶ | my($pkg_subs, $sub_info) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_integrate_sub_info: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||
| 724 | 3 | my %look; | |||||||||||||||||||||||||||||||||||||||||
| 725 | 3 | for my $class ( keys %$pkg_subs ) { | |||||||||||||||||||||||||||||||||||||||||
| 726 | 3 | for my $subname ( keys %{ $pkg_subs->{$class}{subs} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 727 | 22 | ▶ | if ( $sub_info->{$subname} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 728 | # pod info exists | ||||||||||||||||||||||||||||||||||||||||||
| 729 | 7 | $sub_info->{$subname}{class} = $class; | |||||||||||||||||||||||||||||||||||||||||
| 730 | 7 | $look{$subname} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 731 | 7 | next; | |||||||||||||||||||||||||||||||||||||||||
| 732 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 733 | my $si = _sub_info_from_node( | ||||||||||||||||||||||||||||||||||||||||||
| 734 | $subname, | ||||||||||||||||||||||||||||||||||||||||||
| 735 | $class, | ||||||||||||||||||||||||||||||||||||||||||
| 736 | 15 | $pkg_subs->{$class}{subs}{$subname}, | |||||||||||||||||||||||||||||||||||||||||
| 737 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 738 | 15 | ▶ | if ( $si ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 739 | 4 | $sub_info->{$subname} = $si; | |||||||||||||||||||||||||||||||||||||||||
| 740 | 4 | $pkg_subs->{$class}{subs}{$subname} =~ s/$si->{regex}//; | |||||||||||||||||||||||||||||||||||||||||
| 741 | 4 | $look{$subname} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||
| 746 | 3 | for my $si ( values %$sub_info ) { | |||||||||||||||||||||||||||||||||||||||||
| 747 | 12 | ▶ | next if $look{ $si->{name} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 748 | 1 | $si->{virtual} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 749 | $pkg_subs->{$si->{class}}{subs}{$si->{name}} | ||||||||||||||||||||||||||||||||||||||||||
| 750 | 1 | = '<p>virtual function or method</p>'; | |||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||
| 756 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||
| 758 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||
| 760 | Thomas Kratz E<lt>tomk@cpan.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||
| 762 | =head1 REPOSITORY | ||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | L<https://github.com/tomk3003/ppi-transform-doxygen> | ||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||
| 766 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||
| 768 | Copyright 2016-2018 Thomas Kratz. | ||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||
| 770 | This program is free software; you can redistribute | ||||||||||||||||||||||||||||||||||||||||||
| 771 | it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||
| 773 | =cut | ||||||||||||||||||||||||||||||||||||||||||