-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathretrieval_code_info.pl
66 lines (59 loc) · 2.62 KB
/
retrieval_code_info.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl -w
#@description:
#@Author zhangyun<[email protected]>
#@date 2013/08/13
#@version id:0.1
use Text::SimpleTable::AutoWidth;
use File::Find::Node;
use strict;
use warnings;
#consturctor
my(%descriptions,%properties,%classnames,%functions,@filenames)=();
#$ARGV[0] is path name;
my $f = File::Find::Node->new( $ARGV[0] );
$f->process(sub{
my (@filedescription,@classname , @function , @property);
my $file=shift;
my $filename = $file->name;
push @filenames,$filename ;
open MYFILE , $file->path or die "open file failed\n" if $filename =~ /.*\.php/ && (-s $file->path)>0;
# open MYFILE , $file->path or die "open file failed\n" ;
while( <MYFILE> ){
push @filedescription,$1 if $_ =~ /\s*\*+\s*(@(Copyright|author|since|date|version|abstract){1}[^param|return].*)/g;
push @classname,$1 if $_ =~ /\s*class\s+(\w+)\s+{?$/g;
push @function,$3 if $_ =~ /\s*(private|public|protected){1}\s+(static\s+)?function\s+(\w+\s*\(.*\))\s*{?$/g;
push @property,$4 if $_ =~ /\s*(static\s+)?(public|protected|private|const){1}\s+(static\s+)?(\$\w+)\s*=?/g;
}
$descriptions{ $filename }="\t".(join "\n\t>> " ,@filedescription) ;
$properties{ $filename }="\t".(join "\n\t>> " ,@property );
$classnames{ $filename }="\t".(join "\n" ,@classname );
$functions{ $filename }="\t".(join "\n\t>> " ,@function );
#print @filenames;
});
#$f->filter(sub{sort @_ });
$f->find;
sub formatOutput{
my @filename=@_;
foreach(@filename){
# print Text::SimpleTable
# ->new( [10 ,'FileName'], [10,'ClassName'], [20,'Properties'], [50,'Description'], [120 ,'Functions'])
# ->row( $_ ,$classnames{$_},$properties{$_},$descriptions{$_}, $functions{$_})
# ->draw();
print "|--------------------------------------------------------------------------|\n";
print "|the filename: << $_ >>|\n";
print "|--------------------------------------------------------------------------|\n";
print "|the classname =>" , $classnames{$_},"|\n";
print "|--------------------------------------------------------------------------|\n";
print "|the properties =>|\n" , $properties{$_}, "\n";
print "|--------------------------------------------------------------------------|\n";
print "the description: =>|\n" ,$descriptions{$_}, "\n";
print "|--------------------------------------------------------------------------|\n";
print "|the functions => |\n" , $functions{$_}, "\n";
print "|--------------------------------------------------------------------------|\n";
}
}
&formatOutput( @filenames );
#while( (my $key, my $value)= each %descriptions){
# print "the filename: << $key >>\n";
# print "the description: =>\n" ,$descriptions{$key}, "\n";
#}