| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Pod/Spell.pm |
| Statements | Executed 21 statements in 1.15ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 6.06ms | 839ms | Pod::Spell::BEGIN@10 |
| 1 | 1 | 1 | 906µs | 1.92ms | Pod::Spell::BEGIN@12 |
| 1 | 1 | 1 | 218µs | 295µs | Pod::Spell::BEGIN@17 |
| 1 | 1 | 1 | 18µs | 74µs | Pod::Spell::BEGIN@11 |
| 1 | 1 | 1 | 15µs | 15µs | Pod::Spell::BEGIN@2 |
| 1 | 1 | 1 | 10µs | 43µs | Pod::Spell::BEGIN@18 |
| 1 | 1 | 1 | 7µs | 11µs | Pod::Spell::BEGIN@4 |
| 1 | 1 | 1 | 7µs | 61µs | Pod::Spell::BEGIN@8 |
| 1 | 1 | 1 | 6µs | 18µs | Pod::Spell::BEGIN@3 |
| 0 | 0 | 0 | 0s | 0s | Pod::Spell::_is_debug |
| 0 | 0 | 0 | 0s | 0s | Pod::Spell::_treat_words |
| 0 | 0 | 0 | 0s | 0s | Pod::Spell::command |
| 0 | 0 | 0 | 0s | 0s | Pod::Spell::interior_sequence |
| 0 | 0 | 0 | 0s | 0s | Pod::Spell::new |
| 0 | 0 | 0 | 0s | 0s | Pod::Spell::stopwords |
| 0 | 0 | 0 | 0s | 0s | Pod::Spell::textblock |
| 0 | 0 | 0 | 0s | 0s | Pod::Spell::verbatim |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Pod::Spell; | ||||
| 2 | 2 | 37µs | 1 | 15µs | # spent 15µs within Pod::Spell::BEGIN@2 which was called:
# once (15µs+0s) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 2 # spent 15µs making 1 call to Pod::Spell::BEGIN@2 |
| 3 | 2 | 22µs | 2 | 29µs | # spent 18µs (6+12) within Pod::Spell::BEGIN@3 which was called:
# once (6µs+12µs) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 3 # spent 18µs making 1 call to Pod::Spell::BEGIN@3
# spent 12µs making 1 call to strict::import |
| 4 | 2 | 27µs | 2 | 15µs | # spent 11µs (7+4) within Pod::Spell::BEGIN@4 which was called:
# once (7µs+4µs) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 4 # spent 11µs making 1 call to Pod::Spell::BEGIN@4
# spent 4µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 1 | 700ns | our $VERSION = '1.15'; # VERSION | ||
| 7 | |||||
| 8 | 2 | 20µs | 2 | 115µs | # spent 61µs (7+54) within Pod::Spell::BEGIN@8 which was called:
# once (7µs+54µs) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 8 # spent 61µs making 1 call to Pod::Spell::BEGIN@8
# spent 54µs making 1 call to base::import |
| 9 | |||||
| 10 | 2 | 127µs | 1 | 839ms | # spent 839ms (6.06+833) within Pod::Spell::BEGIN@10 which was called:
# once (6.06ms+833ms) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 10 # spent 839ms making 1 call to Pod::Spell::BEGIN@10 |
| 11 | 2 | 32µs | 2 | 130µs | # spent 74µs (18+56) within Pod::Spell::BEGIN@11 which was called:
# once (18µs+56µs) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 11 # spent 74µs making 1 call to Pod::Spell::BEGIN@11
# spent 56µs making 1 call to Exporter::import |
| 12 | 2 | 135µs | 2 | 1.95ms | # spent 1.92ms (906µs+1.01) within Pod::Spell::BEGIN@12 which was called:
# once (906µs+1.01ms) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 12 # spent 1.92ms making 1 call to Pod::Spell::BEGIN@12
# spent 33µs making 1 call to Exporter::import |
| 13 | |||||
| 14 | # We don't need a very new version of Text::Wrap, altho they are nicer. | ||||
| 15 | 1 | 100ns | $Text::Wrap::huge = 'overflow'; ## no critic ( Variables::ProhibitPackageVars ) | ||
| 16 | |||||
| 17 | 2 | 92µs | 2 | 345µs | # spent 295µs (218+77) within Pod::Spell::BEGIN@17 which was called:
# once (218µs+77µs) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 17 # spent 295µs making 1 call to Pod::Spell::BEGIN@17
# spent 50µs making 1 call to locale::import |
| 18 | 2 | 652µs | 2 | 75µs | # spent 43µs (10+33) within Pod::Spell::BEGIN@18 which was called:
# once (10µs+33µs) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 18 # spent 43µs making 1 call to Pod::Spell::BEGIN@18
# spent 33µs making 1 call to Exporter::import |
| 19 | |||||
| 20 | #========================================================================== | ||||
| 21 | # | ||||
| 22 | # Override some methods | ||||
| 23 | # | ||||
| 24 | |||||
| 25 | sub new { | ||||
| 26 | my ( $class, %args ) = @_; | ||||
| 27 | |||||
| 28 | my $new = $class->SUPER::new( %args ); | ||||
| 29 | |||||
| 30 | $new->{'region'} = []; | ||||
| 31 | |||||
| 32 | $new->{no_wide_chars} = $args{no_wide_chars}; | ||||
| 33 | |||||
| 34 | $new->{debug} = $args{debug} || $ENV{PERL_POD_SPELL_DEBUG}; | ||||
| 35 | |||||
| 36 | $new->{stopwords} = $args{stopwords} || Pod::Wordlist->new( | ||||
| 37 | _is_debug => $new->{debug}, no_wide_chars => $args{no_wide_chars} | ||||
| 38 | ); | ||||
| 39 | |||||
| 40 | return $new; | ||||
| 41 | } | ||||
| 42 | |||||
| 43 | sub stopwords { my $self = shift; return $self->{stopwords} } | ||||
| 44 | |||||
| 45 | sub verbatim { return ''; } # totally ignore verbatim sections | ||||
| 46 | |||||
| 47 | #---------------------------------------------------------------------- | ||||
| 48 | |||||
| 49 | sub _is_debug { | ||||
| 50 | my $self = shift; | ||||
| 51 | |||||
| 52 | return $self->{debug} ? 1 : 0; | ||||
| 53 | } | ||||
| 54 | |||||
| 55 | #---------------------------------------------------------------------- | ||||
| 56 | |||||
| 57 | sub textblock { | ||||
| 58 | my ( $self, $paragraph ) = @_; | ||||
| 59 | |||||
| 60 | if ( @{ $self->{'region'} } ) { | ||||
| 61 | |||||
| 62 | my $last_region ## no critic ( ProhibitAmbiguousNames ) | ||||
| 63 | = $self->{'region'}[-1]; | ||||
| 64 | |||||
| 65 | if ( $last_region eq 'stopwords' ) { | ||||
| 66 | $self->stopwords->learn_stopwords($paragraph); | ||||
| 67 | return; | ||||
| 68 | } | ||||
| 69 | elsif ( $last_region eq ':stopwords' ) { | ||||
| 70 | $self->stopwords->learn_stopwords( $self->interpolate($paragraph) ); | ||||
| 71 | |||||
| 72 | # I guess that'd work. | ||||
| 73 | return; | ||||
| 74 | } | ||||
| 75 | elsif ( $last_region !~ m/^:/s ) { | ||||
| 76 | printf "Ignoring a textblock because inside a %s region.\n", | ||||
| 77 | $self->{'region'}[-1] if $self->_is_debug; | ||||
| 78 | return; | ||||
| 79 | } | ||||
| 80 | |||||
| 81 | # else fall thru, as with a :footnote region or something... | ||||
| 82 | } | ||||
| 83 | $self->_treat_words( $self->interpolate($paragraph) ); | ||||
| 84 | return; | ||||
| 85 | } | ||||
| 86 | |||||
| 87 | sub command { ## no critic ( ArgUnpacking) | ||||
| 88 | # why do I have to shift these? | ||||
| 89 | my ( $self, $command, $text ) = ( shift, shift, @_ ); | ||||
| 90 | |||||
| 91 | return if $command eq 'pod'; | ||||
| 92 | |||||
| 93 | if ( $command eq 'begin' ) | ||||
| 94 | { ## no critic ( ControlStructures::ProhibitCascadingIfElse ) | ||||
| 95 | my $region_name; | ||||
| 96 | |||||
| 97 | #print "BEGIN <$_[0]>\n"; | ||||
| 98 | if ( $text =~ m/^\s*(\S+)/s ) { | ||||
| 99 | $region_name = $1; | ||||
| 100 | } | ||||
| 101 | else { | ||||
| 102 | $region_name = 'WHATNAME'; | ||||
| 103 | } | ||||
| 104 | print "~~~~ Beginning region \"$region_name\" ~~~~\n" | ||||
| 105 | if $self->_is_debug; | ||||
| 106 | push @{ $self->{'region'} }, $region_name; | ||||
| 107 | |||||
| 108 | } | ||||
| 109 | elsif ( $command eq 'end' ) { | ||||
| 110 | pop @{ $self->{'region'} }; # doesn't bother to check | ||||
| 111 | |||||
| 112 | } | ||||
| 113 | elsif ( $command eq 'for' ) { | ||||
| 114 | if ( $text =~ s/^\s*(\:?)stopwords\s*(.*)//s ) { | ||||
| 115 | my $para = $2; | ||||
| 116 | $para = $self->interpolate($para) if $1; | ||||
| 117 | print "Stopword para: <$2>\n" if $self->_is_debug; | ||||
| 118 | $self->stopwords->learn_stopwords($para); | ||||
| 119 | } | ||||
| 120 | } | ||||
| 121 | elsif ( @{ $self->{'region'} } ) { # TODO: accept POD formatting | ||||
| 122 | # ignore | ||||
| 123 | } | ||||
| 124 | elsif ($command eq 'head1' | ||||
| 125 | or $command eq 'head2' | ||||
| 126 | or $command eq 'head2' | ||||
| 127 | or $command eq 'head3' | ||||
| 128 | or $command eq 'item' ) | ||||
| 129 | { | ||||
| 130 | my $out_fh = $self->output_handle(); | ||||
| 131 | print $out_fh "\n"; | ||||
| 132 | $self->_treat_words( $self->interpolate(shift) ); | ||||
| 133 | |||||
| 134 | #print $out_fh "\n"; | ||||
| 135 | } | ||||
| 136 | return; | ||||
| 137 | } | ||||
| 138 | |||||
| 139 | #-------------------------------------------------------------------------- | ||||
| 140 | |||||
| 141 | sub interior_sequence { ## no critic ( Subroutines::RequireFinalReturn ) | ||||
| 142 | my ( $self, $command, $seq_arg ) = @_; | ||||
| 143 | |||||
| 144 | return '' if $command eq 'X' or $command eq 'Z'; | ||||
| 145 | |||||
| 146 | # Expand escapes into the actual character now, carping if invalid. | ||||
| 147 | if ( $command eq 'E' ) { | ||||
| 148 | my $it = e2char( $seq_arg ); | ||||
| 149 | if ( defined $it ) { | ||||
| 150 | return $it; | ||||
| 151 | } | ||||
| 152 | else { | ||||
| 153 | carp "Unknown escape: E<$seq_arg>"; | ||||
| 154 | return "E<$seq_arg>"; | ||||
| 155 | } | ||||
| 156 | } | ||||
| 157 | |||||
| 158 | # For all the other sequences, empty content produces no output. | ||||
| 159 | return if $seq_arg eq ''; | ||||
| 160 | |||||
| 161 | if ( $command eq 'B' or $command eq 'I' or $command eq 'S' ) { | ||||
| 162 | $seq_arg; | ||||
| 163 | } | ||||
| 164 | elsif ( $command eq 'C' or $command eq 'F' ) { | ||||
| 165 | |||||
| 166 | # don't lose word-boundaries | ||||
| 167 | my $out = ''; | ||||
| 168 | $out .= ' ' if s/^\s+//s; | ||||
| 169 | my $append; | ||||
| 170 | $append = 1 if s/\s+$//s; | ||||
| 171 | $out .= '_' if length $seq_arg; | ||||
| 172 | |||||
| 173 | # which, if joined to another word, will set off the Perl-token alarm | ||||
| 174 | $out .= ' ' if $append; | ||||
| 175 | $out; | ||||
| 176 | } | ||||
| 177 | elsif ( $command eq 'L' ) { | ||||
| 178 | return $1 if m/^([^|]+)\|/s; | ||||
| 179 | ''; | ||||
| 180 | } | ||||
| 181 | else { | ||||
| 182 | carp "Unknown sequence $command<$seq_arg>"; | ||||
| 183 | } | ||||
| 184 | } | ||||
| 185 | |||||
| 186 | #-------------------------------------------------------------------------- | ||||
| 187 | |||||
| 188 | sub _treat_words { | ||||
| 189 | my ($self, $text) = @_; | ||||
| 190 | my $out = $self->stopwords->strip_stopwords( $text ); | ||||
| 191 | if ( length $out ) { | ||||
| 192 | my $out_fh = $self->output_handle(); | ||||
| 193 | print $out_fh wrap( '', '', $out ), "\n\n"; | ||||
| 194 | } | ||||
| 195 | return; | ||||
| 196 | } | ||||
| 197 | |||||
| 198 | #-------------------------------------------------------------------------- | ||||
| 199 | |||||
| 200 | 1 | 3µs | 1; | ||
| 201 | |||||
| 202 | # ABSTRACT: a formatter for spellchecking Pod | ||||
| 203 | |||||
| 204 | __END__ |