Skip to content

Commit

Permalink
add example and bin
Browse files Browse the repository at this point in the history
Signed-off-by: Alec Chen <alec@cpan.org>
  • Loading branch information
alecchen committed Jan 14, 2010
1 parent 90dd221 commit 46f01f9
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 28 deletions.
9 changes: 9 additions & 0 deletions bin/lua2dox
@@ -0,0 +1,9 @@
#!/bin/env perl

use strict;
use warnings;
use Doxygen::Lua;

my $input = $ARGV[0];
my $p = Doxygen::Lua->new;
print $p->parse($input);
30 changes: 30 additions & 0 deletions example/example.lua
@@ -0,0 +1,30 @@
---------------------------------
--! @file
--! @brief a Doxygen::Lua example
---------------------------------

--! table is supported

PARAMETER = {
a = 1,
b = 2,
c = 3,
}

--! my name
AUTHOR = 'Alec Chen'

--! my email
EMAIL = 'alec@cpan.org'

--! @brief The factorial is an example of a recursive function
--! @param n a positive integer
--! @return return the product of all positive integers less than or equal to n

function factorial(n)
if n == 0 then
return 1
else
return n * factorial(n - 1)
end
end
95 changes: 67 additions & 28 deletions lib/Doxygen/Lua.pm
Expand Up @@ -2,10 +2,11 @@ package Doxygen::Lua;

use warnings;
use strict;
use Moose;

=head1 NAME
Doxygen::Lua - The great new Doxygen::Lua!
Doxygen::Lua - A preprocessor to make doxygen support lua
=head1 VERSION
Expand All @@ -14,60 +15,101 @@ Version 0.01
=cut

our $VERSION = '0.01';

has 'mark' => ( is => 'rw', isa => 'Str', default => '--!' );

=head1 SYNOPSIS
Quick summary of what the module does.
Perhaps a little code snippet.
use Doxygen::Lua;
my $p = Doxygen::Lua->new;
print $p->parse($input);
my $foo = Doxygen::Lua->new();
...
=head1 SUBROUTINES/METHODS
=head1 EXPORT
=head2 new
A list of functions that can be exported. You can delete this section
if you don't export anything, such as for a purely object-oriented module.
This function will create a Doxygen::Lua object.
=head1 SUBROUTINES/METHODS
=cut

=head2 parse
=head2 function1
This function will parse the given input file and return the result.
=cut

sub function1 {
sub parse {
my $self = shift;
my $input = shift;
my $in_block = 0;
my $block_name = q{};
my $result = q{};
my $mark = $self->mark;

open FH, "<$input"
or die "Can't open $input for reading: $!";

foreach my $line (<FH>) {
chomp($line);

# comments
next if $line =~ /^\s*--[^!]/;
$line =~ s/--[^!].*//;

if ($line =~ s{$mark}{///}) {
}
elsif ($line =~ /==/) {
next;
}
# function
elsif ($line =~ /function/) {
$line .= q{;};
}
# block start
elsif ($line =~ /^(\S+)\s*=\s*{/ && $line !~ /}/) {
$block_name = $1; $in_block = 1;
next;
}
elsif ($line =~ /^\s*}/ && $in_block == 1) {
$block_name = q{};
$in_block = 0;
next;
}
elsif ($line =~ /=/) {
$line =~ s/,\s*$//;
$line =~ s/(?=\S)/$block_name./ if $block_name;
$line .= ";";
}
else {
next;
}

$result .= "$line\n";
}

close FH;
return $result;
}

=head2 function2
=head2 mark
=cut
This function will set the mark style. The default value is "--!".
sub function2 {
}
=cut

=head1 AUTHOR
Alec Chen, C<< <alec at cpan.org> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-doxygen-lua at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Doxygen-Lua>. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
Please report any bugs or feature requests to C<bug-doxygen-lua at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Doxygen-Lua>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Doxygen::Lua
You can also look for information at:
=over 4
Expand All @@ -90,10 +132,8 @@ L<http://search.cpan.org/dist/Doxygen-Lua/>
=back
=head1 ACKNOWLEDGEMENTS
=head1 LICENSE AND COPYRIGHT
Copyright 2010 Alec Chen.
Expand All @@ -104,7 +144,6 @@ by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
=cut

1; # End of Doxygen::Lua

0 comments on commit 46f01f9

Please sign in to comment.