NAME
Perl::Tidy::Sweetened::Keyword::Block - Perl::Tidy::Sweetened filter plugin to define new subroutine and class keywords
VERSION
version 0.23
SYNOPSIS
our $plugins = Perl::Tidy::Sweetened::Pluggable->new();
$plugins->add_filter(
Perl::Tidy::Sweetened::Keyword::Block->new(
keyword => 'method',
marker => 'METHOD',
replacment => 'sub',
clauses => [ 'PAREN?', '(returns \s* PAREN)?' ],
) );
DESCRIPTION
This is a Perl::Tidy::Sweetened filter which enables the definition of arbitrary keywords for subroutines with any number of potential signature definitions. New accepts:
- keyword
-
keyword => 'method'
Declares a new keyword (in this example the "method" keyword).
- marker
-
marker => 'METHOD'
Provides a text marker to be used to flag the new keywords during
prefilter
. The source code will be filtered prior to formatting by Perl::Tidy such that:method foo { }
is turned into:
sub foo { # __METHOD 1 }
- replacement
-
replacement => 'sub'
Will convert the keyword to a
sub
as shown above. - clauses
-
clauses => [ 'PAREN?' ]
Provides a list of strings which will be turned into a regex to capture additional clauses. The regex will include the 'xm' flags (so be sure to escape spaces). The clause can be marked optional with '?'. The special text "PAREN" can be used to capture a balanced parenthetical.
This example will capture a parameter list enclosed by parenthesis, ie:
method foo (Int $i) { }
No formatting is done on the clauses at this time. The order of declaration is significant.
THANKS
BUGS
Please report any bugs or suggestions at http://rt.cpan.org/NoAuth/Bugs.html?Dist=Perl-Tidy-Sweetened
AUTHOR
Mark Grimes, <mgrimes@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Mark Grimes, <mgrimes@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.