Modified source files and compiled any and armel versions of packages
[pkg-perl] / deb-src / libperl-critic-perl / libperl-critic-perl-1.088 / lib / Perl / Critic / Policy / Documentation / RequirePodAtEnd.pm
1 ##############################################################################
2 #      $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/Documentation/RequirePodAtEnd.pm $
3 #     $Date: 2008-07-03 10:19:10 -0500 (Thu, 03 Jul 2008) $
4 #   $Author: clonezone $
5 # $Revision: 2489 $
6 ##############################################################################
7
8 package Perl::Critic::Policy::Documentation::RequirePodAtEnd;
9
10 use 5.006001;
11 use strict;
12 use warnings;
13 use Readonly;
14
15 use List::Util qw(first);
16
17 use Perl::Critic::Utils qw{ :severities };
18 use base 'Perl::Critic::Policy';
19
20 our $VERSION = '1.088';
21
22 #-----------------------------------------------------------------------------
23
24 Readonly::Scalar my $POD_RX => qr{\A = (?: for|begin|end ) }mx;
25 Readonly::Scalar my $DESC => q{POD before __END__};
26 Readonly::Scalar my $EXPL => [139, 140];
27
28 #-----------------------------------------------------------------------------
29
30 sub supported_parameters { return ()                      }
31 sub default_severity     { return $SEVERITY_LOWEST        }
32 sub default_themes       { return qw( core cosmetic pbp ) }
33 sub applies_to           { return 'PPI::Document'         }
34
35 #-----------------------------------------------------------------------------
36
37 sub violates {
38     my ( $self, $elem, $doc ) = @_;
39
40     # No POD means no violation
41     my $pods_ref = $doc->find('PPI::Token::Pod');
42     return if !$pods_ref;
43
44     # Look for first POD tag that isn't =for, =begin, or =end
45     my $pod = first { $_ !~ $POD_RX} @{ $pods_ref };
46     return if !$pod;
47
48     my $end = $doc->find_first('PPI::Statement::End');
49     if ($end) {  # No __END__ means definite violation
50         my $pod_loc = $pod->location();
51         my $end_loc = $end->location();
52         if ( $pod_loc->[0] > $end_loc->[0] ) {
53             # POD is after __END__, or relative position couldn't be determined
54             return;
55         }
56     }
57
58     return $self->violation( $DESC, $EXPL, $pod );
59 }
60
61 1;
62
63 __END__
64
65 #-----------------------------------------------------------------------------
66
67 =pod
68
69 =head1 NAME
70
71 Perl::Critic::Policy::Documentation::RequirePodAtEnd - All POD should be after C<__END__>.
72
73 =head1 AFFILIATION
74
75 This Policy is part of the core L<Perl::Critic> distribution.
76
77
78 =head1 DESCRIPTION
79
80 Perl stops processing code when it sees an C<__END__> statement.  So,
81 to save processing time, it's faster to put
82 documentation after the C<__END__>.  Also, writing all the POD in one
83 place usually leads to a more cohesive document, rather than being
84 forced to follow the layout of your code.  This policy issues
85 violations if any POD is found before an C<__END__>.
86
87
88 =head1 CONFIGURATION
89
90 This Policy is not configurable except for the standard options.
91
92
93 =head1 NOTES
94
95 Some folks like to use C<=for>, and C<=begin>, and C<=end> tags to
96 create block comments in-line with their code.  Since those tags aren't
97 usually part of the documentation, this Policy does allows them to
98 appear before the C<__END__> statement.
99
100   =begin comments
101
102   frobulate()
103   Accepts:  A list of things to frobulate
104   Returns:  True if succesful
105
106   =end comments
107
108   sub frobulate { ... }
109
110 =head1 AUTHOR
111
112 Chris Dolan <cdolan@cpan.org>
113
114 =head1 COPYRIGHT
115
116 Copyright (c) 2006-2008 Chris Dolan.  All rights reserved.
117
118 This program is free software; you can redistribute it and/or modify
119 it under the same terms as Perl itself.  The full text of this license
120 can be found in the LICENSE file included with this module
121
122 =cut
123
124 # Local Variables:
125 #   mode: cperl
126 #   cperl-indent-level: 4
127 #   fill-column: 78
128 #   indent-tabs-mode: nil
129 #   c-indentation-style: bsd
130 # End:
131 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :