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

Perl::Tidy::Sweetened::Keyword::Block3pm

Perl::tidy::sweetened filter plugin to define new subroutine and class keywords

Usage

    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)?' ],
        ) );

Version

version 1.20

Overview

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.

Source

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

Releases

2 releases since Debian 12 (Bookworm); the text changed 1 time.

  1. 12
  2. 13

Author

Mark Grimes <[email protected]>

Bugs

Please report any bugs or feature requests on the bugtracker website <https://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.

From perltidier 1.20-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.