Perl::Tidy::Sweetened::Keyword::Block(3pm)

NAME
Perl::Tidy::Sweetened::Keyword::Block - Perl::Tidy::Sweetened filter plugin to define new subroutine and class keywords

VERSION
version 1.18

SYNOPSIS
    our $plugins = Perl::Tidy::Sweetened::Pluggable->new();

    $plugins->add_filter(
        Perl::Tidy::Sweetened::Keyword::Block->new(
            keyword     => 'method',
            marker      => 'METHOD',
            replacement => '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.

AUTHOR
Mark Grimes <mgrimes@cpan.org>

SOURCE
Source repository is at <https://github.com/mvgrimes/Perl-Tidy-Sweetened>.

BUGS
Please report any bugs or feature requests on the bugtracker website <http://github.com/mvgrimes/Perl-Tidy-Sweetened/issues>

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

COPYRIGHT AND LICENSE
This software is copyright (c) 2021 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.