1Perl::Tidy::Sweetened::UKseeyrwoCrodn:t:rBilbouctkeP(de3rpPlme:)r:lTiDdoyc:u:mSewneteatteinoend::Keyword::Block(3pm)
2
3
4
6 Perl::Tidy::Sweetened::Keyword::Block - Perl::Tidy::Sweetened filter
7 plugin to define new subroutine and class keywords
8
10 version 1.18
11
13 our $plugins = Perl::Tidy::Sweetened::Pluggable->new();
14
15 $plugins->add_filter(
16 Perl::Tidy::Sweetened::Keyword::Block->new(
17 keyword => 'method',
18 marker => 'METHOD',
19 replacement => 'sub',
20 clauses => [ 'PAREN?', '(returns \s* PAREN)?' ],
21 ) );
22
24 This is a Perl::Tidy::Sweetened filter which enables the definition of
25 arbitrary keywords for subroutines with any number of potential
26 signature definitions. New accepts:
27
28 keyword
29 keyword => 'method'
30
31 Declares a new keyword (in this example the "method" keyword).
32
33 marker
34 marker => 'METHOD'
35
36 Provides a text marker to be used to flag the new keywords during
37 "prefilter". The source code will be filtered prior to formatting
38 by Perl::Tidy such that:
39
40 method foo {
41 }
42
43 is turned into:
44
45 sub foo { # __METHOD 1
46 }
47
48 replacement
49 replacement => 'sub'
50
51 Will convert the keyword to a "sub" as shown above.
52
53 clauses
54 clauses => [ 'PAREN?' ]
55
56 Provides a list of strings which will be turned into a regex to
57 capture additional clauses. The regex will include the 'xm' flags
58 (so be sure to escape spaces). The clause can be marked optional
59 with '?'. The special text "PAREN" can be used to capture a
60 balanced parenthetical.
61
62 This example will capture a parameter list enclosed by parenthesis,
63 ie:
64
65 method foo (Int $i) {
66 }
67
68 No formatting is done on the clauses at this time. The order of
69 declaration is significant.
70
72 Mark Grimes <mgrimes@cpan.org>
73
75 Source repository is at
76 <https://github.com/mvgrimes/Perl-Tidy-Sweetened>.
77
79 Please report any bugs or feature requests on the bugtracker website
80 <http://github.com/mvgrimes/Perl-Tidy-Sweetened/issues>
81
82 When submitting a bug or request, please include a test-file or a patch
83 to an existing test-file that illustrates the bug or desired feature.
84
86 This software is copyright (c) 2021 by Mark Grimes <mgrimes@cpan.org>.
87
88 This is free software; you can redistribute it and/or modify it under
89 the same terms as the Perl 5 programming language system itself.
90
91
92
93perl v5.34.0 202P2e-r0l1:-:2T1idy::Sweetened::Keyword::Block(3pm)