Skip to content

Commit 19939ea

Browse files
authored
Merge pull request #14 from albert-github/feature/bug_prototype
Small prototype support
2 parents 32bc13c + ac6a553 commit 19939ea

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

lib/Doxygen/Filter/Perl.pm

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,23 @@ sub _PrintMethodBlock
627627

628628
my $returntype = $methodDef->{'returntype'} || $type;
629629
my $parameters = $methodDef->{'parameters'} || "";
630+
my $prototype = $methodDef->{'prototype'} || "";
630631

631-
print "/** \@fn $state $returntype $method\($parameters\)\n";
632+
if ($parameters =~ /^ *$/)
633+
{
634+
if ($prototype =~ /^ *$/)
635+
{
636+
print "/** \@fn $state $returntype $method\(\)\n";
637+
}
638+
else
639+
{
640+
print "/** \@fn $state $returntype $method\($prototype\)\n";
641+
}
642+
}
643+
else
644+
{
645+
print "/** \@fn $state $returntype $method\($parameters\)\n";
646+
}
632647

633648
my $details = $methodDef->{'details'};
634649
if (defined $details) { print "$details\n"; }
@@ -653,7 +668,21 @@ sub _PrintMethodBlock
653668
print "</div>\n";
654669
print "\@endhtmlonly */\n";
655670

656-
print "$state $returntype $method\($parameters\)\;\n";
671+
if ($parameters =~ /^ *$/)
672+
{
673+
if ($prototype =~ /^ *$/)
674+
{
675+
print "$state $returntype $method\(\)\;\n";
676+
}
677+
else
678+
{
679+
print "$state $returntype $method\($prototype\)\;\n";
680+
}
681+
}
682+
else
683+
{
684+
print "$state $returntype $method\($parameters\)\;\n";
685+
}
657686
}
658687

659688
sub _ProcessPerlMethod
@@ -681,14 +710,23 @@ sub _ProcessPerlMethod
681710
$sName =~ s/\{.*\}?//;
682711
# Remove any leading or trailing whitespace from the name, just to be safe
683712
$sName =~ s/\s//g;
713+
# check if we have a prototype
714+
my ($method, $proto) = split /[()]/, $sName;
715+
$sName = $method || "";
716+
$sName =~ s/\s//g;
717+
if (defined($proto)) {$proto =~ s/\s//g;}
718+
my $sProtoType = $proto || "";
684719
$logger->debug("Method Name: $sName");
685720

686721
push (@{$self->{'_hData'}->{'class'}->{$sClassName}->{'subroutineorder'}}, $sName);
687722
$self->{'_sCurrentMethodName'} = $sName;
723+
$self->{'_sProtoType'} = $self->_ConvertParameters($sProtoType);
688724
}
689725
if (!defined($self->{'_sCurrentMethodName'})) {$self->{'_sCurrentMethodName'}='';}
726+
if (!defined($self->{'_sProtoType'})) {$self->{'_sProtoType'}='';}
690727

691728
my $sMethodName = $self->{'_sCurrentMethodName'};
729+
my $sProtoType = $self->{'_sProtoType'};
692730

693731
# Lets find out if this is a public or private method/function based on a naming standard
694732
if ($sMethodName =~ /^_/) { $self->{'_sCurrentMethodState'} = 'private'; }
@@ -777,6 +815,7 @@ sub _ProcessPerlMethod
777815
{
778816
$self->{'_hData'}->{'class'}->{$sClassName}->{'subroutines'}->{$sMethodName}->{'type'} = "method";
779817
}
818+
$self->{'_hData'}->{'class'}->{$sClassName}->{'subroutines'}->{$sMethodName}->{'prototype'} = $sProtoType;
780819
}
781820

782821
sub _ProcessPodCommentBlock
@@ -1090,6 +1129,7 @@ sub _ConvertTypeCode
10901129
$code =~ s/\@\$/array_ref/g;
10911130
$code =~ s/\%\$/hash_ref/g;
10921131
$code =~ s/\$/scalar/g;
1132+
$code =~ s/\&/subroutine/g;
10931133
$code =~ s/\@/array/g;
10941134
$code =~ s/\%/hash/g;
10951135

@@ -1112,6 +1152,7 @@ sub _ConvertParameters
11121152
$sParameters =~ s/\@\$/array_ref /g;
11131153
$sParameters =~ s/\%\$/hash_ref /g;
11141154
$sParameters =~ s/\$/scalar /g;
1155+
$sParameters =~ s/\&/subroutine /g;
11151156
$sParameters =~ s/\@/array /g;
11161157
$sParameters =~ s/\%/hash /g;
11171158

@@ -1287,6 +1328,7 @@ documented as $$foo, @$bar, %$foobar. An example would look this:
12871328
$self->{'_hData'}->{'class'}->{$class}->{'subroutines'}->{$method}->{'returntype'} = string (return type)
12881329
$self->{'_hData'}->{'class'}->{$class}->{'subroutines'}->{$method}->{'state'} = string (public / private)
12891330
$self->{'_hData'}->{'class'}->{$class}->{'subroutines'}->{$method}->{'parameters'} = string (method / function parameters)
1331+
$self->{'_hData'}->{'class'}->{$class}->{'subroutines'}->{$method}->{'prototype'} = string (method / function prototype parameters)
12901332
$self->{'_hData'}->{'class'}->{$class}->{'subroutines'}->{$method}->{'code'} = string
12911333
$self->{'_hData'}->{'class'}->{$class}->{'subroutines'}->{$method}->{'length'} = integer
12921334
$self->{'_hData'}->{'class'}->{$class}->{'subroutines'}->{$method}->{'details'} = string

0 commit comments

Comments
 (0)