line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Doxygen::Lua; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24041
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1009
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Doxygen::Lua - Make Doxygen support Lua |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.04 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Doxygen::Lua; |
21
|
|
|
|
|
|
|
my $p = Doxygen::Lua->new; |
22
|
|
|
|
|
|
|
print $p->parse($input); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
A script named "lua2dox" will be installed. Then modify your Doxyfile as below: |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
FILTER_PATTERNS = *.lua=../bin/lua2dox |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
That's all! |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 new |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
This function will create a Doxygen::Lua object. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub new { |
41
|
0
|
|
|
0
|
1
|
|
my ($class, %args) = @_; |
42
|
0
|
|
|
|
|
|
my $self = bless \%args, $class; |
43
|
0
|
|
|
|
|
|
$self->_init; |
44
|
0
|
|
|
|
|
|
return $self; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _init { |
48
|
0
|
|
|
0
|
|
|
my $self = shift; |
49
|
0
|
|
|
|
|
|
$self->{mark} = '--!'; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 parse |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This function will parse the given input file and return the result. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub parse { |
59
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
60
|
0
|
|
|
|
|
|
my $input = shift; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $in_block = 0; |
63
|
0
|
|
|
|
|
|
my $in_function = 0; |
64
|
0
|
|
|
|
|
|
my $block_name = q{}; |
65
|
0
|
|
|
|
|
|
my $result = q{}; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $mark = $self->mark; |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
open FH, "<$input" |
70
|
|
|
|
|
|
|
or die "Can't open $input for reading: $!"; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
foreach my $line () { |
73
|
0
|
|
|
|
|
|
chomp $line; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# include empty lines |
76
|
0
|
0
|
|
|
|
|
if ($line =~ m{^\s*$}) { |
77
|
0
|
|
|
|
|
|
$result .= "\n" |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
# skip normal comments |
80
|
0
|
0
|
|
|
|
|
next if $line =~ /^\s*--[^!]/; |
81
|
|
|
|
|
|
|
# remove end of line comments |
82
|
0
|
|
|
|
|
|
$line =~ s/--[^!].*//; |
83
|
|
|
|
|
|
|
# skip comparison |
84
|
0
|
0
|
|
|
|
|
next if $line =~ /==/; |
85
|
|
|
|
|
|
|
# translate to doxygen mark |
86
|
0
|
|
|
|
|
|
$line =~ s{$mark}{///}; |
87
|
|
|
|
|
|
|
|
88
|
0
|
0
|
0
|
|
|
|
if ($line =~ m{^\s*///}) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
$result .= "$line\n"; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
# function start |
92
|
|
|
|
|
|
|
elsif ($line =~ /^function/) { |
93
|
0
|
|
|
|
|
|
$in_function = 1; |
94
|
0
|
|
|
|
|
|
$line .= q{;}; |
95
|
0
|
|
|
|
|
|
$line =~ s/:/-/; |
96
|
0
|
|
|
|
|
|
$result .= "$line\n"; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
#local function start |
99
|
|
|
|
|
|
|
elsif ($line =~ /^local.+function/) { |
100
|
0
|
|
|
|
|
|
$in_function = 1; |
101
|
0
|
|
|
|
|
|
$line .= q{;}; |
102
|
0
|
|
|
|
|
|
$line =~ s/function\s+/function-/; |
103
|
0
|
|
|
|
|
|
$result .= "$line\n"; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
# function end |
106
|
|
|
|
|
|
|
elsif ($in_function == 1 && $line =~ /^end/) { |
107
|
0
|
|
|
|
|
|
$in_function = 0; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
# block start |
110
|
|
|
|
|
|
|
elsif ($in_function == 0 && $line =~ /^(\S+)\s*=\s*{/ && $line !~ /}/) { |
111
|
0
|
|
|
|
|
|
$block_name = $1; |
112
|
0
|
|
|
|
|
|
$in_block = 1; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
# block end |
115
|
|
|
|
|
|
|
elsif ($in_function == 0 && $line =~ /^\s*}/ && $in_block == 1) { |
116
|
0
|
|
|
|
|
|
$block_name = q{}; |
117
|
0
|
|
|
|
|
|
$in_block = 0; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
# variables |
120
|
|
|
|
|
|
|
elsif ($in_function == 0 && $line =~ /=/) { |
121
|
0
|
0
|
|
|
|
|
$line =~ s/(?=\S)/$block_name./ if $block_name; |
122
|
0
|
|
|
|
|
|
$line =~ s{,?(\s*)(?=///|$)}{;$1}; |
123
|
0
|
|
|
|
|
|
$result .= "$line\n"; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
close FH; |
128
|
0
|
|
|
|
|
|
return $result; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 mark |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This function will set the mark style. The default value is "--!". |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub mark { |
138
|
0
|
|
|
0
|
1
|
|
my ($self, $value) = @_; |
139
|
0
|
0
|
|
|
|
|
$self->{mark} = $value if $value; |
140
|
0
|
|
|
|
|
|
return $self->{mark}; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 AUTHOR |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Alec Chen, C<< >> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 BUGS |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 SUPPORT |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
perldoc Doxygen::Lua |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
You can also look for information at: |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=over 4 |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * CPAN Ratings |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
L |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item * Search CPAN |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
L |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=back |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 REPOSITORY |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
See http://github.com/alecchen/doxygen-lua |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Copyright 2010 Alec Chen. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
190
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
191
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
1; # End of Doxygen::Lua |