| 1 | package Perl6::Perldoc::To::Text; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | package Perl6::Perldoc::Parser::ReturnVal; | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=4 SCAR=30.0
| |||||||||||||||||||||
| 9 | 0 | my ($self, $internal_state) = @_; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 0 | ▶ | $internal_state ||= {}; | ||||||||||||||||||
|
Condition0%0/2
$internal_state ||= {}
MC/DC0%0/1
$internal_state ||= {}
$internal_state
Truth table0%0/2
A
A= $internal_state
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 0 | my $text_rep = $self->{tree}->to_text($internal_state); | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 0 | ▶ | if (($internal_state->{note_count}||0) > 0) { | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$internal_state->{'note_count'} || 0
MC/DC0%0/1
$internal_state->{'note_count'} || 0
$internal_state->{'note_count'}
Truth table0%0/2
A
A= $internal_state->{'note_count'}
| |||||||||||||||||||||
| 16 | 0 | $text_rep .= "\nNotes\n\n$internal_state->{notes}"; | |||||||||||||||||||
| 17 | } | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 0 | return $text_rep; | |||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | package Perl6::Perldoc::Root; | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 1 | my $INDENT = 4; | |||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | ▶ | sub add_text_nesting { | ||||||||||||||||||
|
Subroutine
add_text_nesting: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 27 | 0 | my ($self, $text, $depth) = @_; | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | # Nest according to the specified nestedness of the block... | ||||||||||||||||||||
| 30 | 0 | ▶ | if (my $nesting = $self->option('nested')) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 31 | 0 | $depth = $nesting * $INDENT; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | # Or else default to one indent... | ||||||||||||||||||||
| 35 | elsif (!defined $depth) { | ||||||||||||||||||||
| 36 | 0 | $depth = $INDENT; | |||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | my $indent = q{ } x $depth; | |||||||||||||||||||
| 40 | 0 | $text =~ s{^}{$indent}gxms; | |||||||||||||||||||
| 41 | 0 | return $text; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | ▶ | sub _list_to_text { | ||||||||||||||||||
|
Subroutine
_list_to_text: not called CC=4 SCAR=30.0
| |||||||||||||||||||||
| 45 | 0 | my ($list_ref, $state_ref) = @_; | |||||||||||||||||||
| 46 | 0 | my $text = q{}; | |||||||||||||||||||
| 47 | 0 | for my $content ( @{$list_ref} ) { | |||||||||||||||||||
| 48 | 0 | ▶ | next if ! defined $content; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | 0 | ▶ | if (ref $content) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 50 | 0 | $text .= $content->to_text($state_ref); | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | else { | ||||||||||||||||||||
| 53 | 0 | $text .= $content; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | 0 | $text =~ s{\A \n+}{}xms; | |||||||||||||||||||
| 57 | 0 | $text =~ s{\n+ \z}{\n}xms; | |||||||||||||||||||
| 58 | 0 | return $text; | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 62 | 0 | my $self = shift; | |||||||||||||||||||
| 63 | 0 | return $self->add_text_nesting(_list_to_text([$self->content], @_),0); | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | # Representation of file itself... | ||||||||||||||||||||
| 67 | package Perl6::Perldoc::Document; | ||||||||||||||||||||
| 68 | 1 | ▶ | use base 'Perl6::Perldoc::Root'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | # Ambient text around the Pod... | ||||||||||||||||||||
| 71 | package Perl6::Perldoc::Ambient; | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 74 | 0 | return q{}; | |||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | # Pod blocks... | ||||||||||||||||||||
| 78 | package Perl6::Perldoc::Block; | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | # Standard =pod block... | ||||||||||||||||||||
| 81 | package Perl6::Perldoc::Block::pod; | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | # Standard =para block (may be implicit)... | ||||||||||||||||||||
| 84 | package Perl6::Perldoc::Block::para; | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 87 | 0 | my $self = shift; | |||||||||||||||||||
| 88 | 0 | return "\n" . $self->SUPER::to_text(@_); | |||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | # Standard =code block (may be implicit)... | ||||||||||||||||||||
| 92 | package Perl6::Perldoc::Block::code; | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | 0 | ▶ | sub min { | ||||||||||||||||||
|
Subroutine
min: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 95 | 0 | my $min = shift; | |||||||||||||||||||
| 96 | 0 | for my $next (@_) { | |||||||||||||||||||
| 97 | 0 | ▶ | $min = $next if $next < $min; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 98 | } | ||||||||||||||||||||
| 99 | 0 | return $min; | |||||||||||||||||||
| 100 | } | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 103 | 0 | my $self = shift; | |||||||||||||||||||
| 104 | 0 | my $text = Perl6::Perldoc::Root::_list_to_text([$self->content],@_); | |||||||||||||||||||
| 105 | 0 | my $left_space = min map { length } $text =~ m{^ [^\S\n]* (?= \S) }gxms; | |||||||||||||||||||
| 106 | 0 | $text =~ s{^ [^\S\n]{$left_space} }{}gxms; | |||||||||||||||||||
| 107 | 0 | return "\n" . $self->add_text_nesting($text, $INDENT); | |||||||||||||||||||
| 108 | } | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | # Standard =input block | ||||||||||||||||||||
| 112 | package Perl6::Perldoc::Block::input; | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 115 | 0 | my $self = shift; | |||||||||||||||||||
| 116 | 0 | my $text = Perl6::Perldoc::Root::_list_to_text([$self->content],@_); | |||||||||||||||||||
| 117 | 0 | return "\n" . $self->add_text_nesting($text, $INDENT); | |||||||||||||||||||
| 118 | } | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | # Standard =output block | ||||||||||||||||||||
| 122 | package Perl6::Perldoc::Block::output; | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 125 | 0 | my $self = shift; | |||||||||||||||||||
| 126 | 0 | my $text = Perl6::Perldoc::Root::_list_to_text([$self->content],@_); | |||||||||||||||||||
| 127 | 0 | return "\n" . $self->add_text_nesting($text, $INDENT); | |||||||||||||||||||
| 128 | } | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | # Standard =config block... | ||||||||||||||||||||
| 131 | package Perl6::Perldoc::Config; | ||||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 134 | 0 | return q{}; | |||||||||||||||||||
| 135 | } | ||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | # Standard =table block... | ||||||||||||||||||||
| 138 | package Perl6::Perldoc::Block::table; | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 141 | 0 | my $self = shift; | |||||||||||||||||||
| 142 | 0 | my ($text) = $self->content; | |||||||||||||||||||
| 143 | 0 | return "\n" . $self->add_text_nesting($text, $INDENT); | |||||||||||||||||||
| 144 | } | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | |||||||||||||||||||||
| 147 | # Standard =head1 block... | ||||||||||||||||||||
| 148 | package Perl6::Perldoc::Block::head1; | ||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 151 | 0 | my $self = shift; | |||||||||||||||||||
| 152 | 0 | my $title = $self->SUPER::to_text(@_); | |||||||||||||||||||
| 153 | 0 | $title =~ s{\A\s+|\s+\Z}{}gxms; | |||||||||||||||||||
| 154 | 0 | $title =~ s{\s+}{ }gxms; | |||||||||||||||||||
| 155 | 0 | my $number = $self->number; | |||||||||||||||||||
| 156 | 0 | ▶ | if (defined $number) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 157 | 0 | $title = "$number. $title"; | |||||||||||||||||||
| 158 | } | ||||||||||||||||||||
| 159 | 0 | return "\n\n$title\n"; | |||||||||||||||||||
| 160 | } | ||||||||||||||||||||
| 161 | |||||||||||||||||||||
| 162 | # Standard =head2 block... | ||||||||||||||||||||
| 163 | package Perl6::Perldoc::Block::head2; | ||||||||||||||||||||
| 164 | |||||||||||||||||||||
| 165 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 166 | 0 | my $self = shift; | |||||||||||||||||||
| 167 | 0 | my $title = $self->SUPER::to_text(@_); | |||||||||||||||||||
| 168 | 0 | $title =~ s{\A\s+|\s+\Z}{}gxms; | |||||||||||||||||||
| 169 | 0 | $title =~ s{\s+}{ }gxms; | |||||||||||||||||||
| 170 | 0 | my $number = $self->number; | |||||||||||||||||||
| 171 | 0 | ▶ | if (defined $number) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 172 | 0 | $title = "$number. $title"; | |||||||||||||||||||
| 173 | } | ||||||||||||||||||||
| 174 | 0 | return "\n\n$title\n"; | |||||||||||||||||||
| 175 | } | ||||||||||||||||||||
| 176 | |||||||||||||||||||||
| 177 | # Standard =head3 block... | ||||||||||||||||||||
| 178 | package Perl6::Perldoc::Block::head3; | ||||||||||||||||||||
| 179 | |||||||||||||||||||||
| 180 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 181 | 0 | my $self = shift; | |||||||||||||||||||
| 182 | 0 | my $title = $self->SUPER::to_text(@_); | |||||||||||||||||||
| 183 | 0 | $title =~ s{\A\s+|\s+\Z}{}gxms; | |||||||||||||||||||
| 184 | 0 | $title =~ s{\s+}{ }gxms; | |||||||||||||||||||
| 185 | 0 | my $number = $self->number; | |||||||||||||||||||
| 186 | 0 | ▶ | if (defined $number) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 187 | 0 | $title = "$number. $title"; | |||||||||||||||||||
| 188 | } | ||||||||||||||||||||
| 189 | 0 | return "\n\n$title\n"; | |||||||||||||||||||
| 190 | } | ||||||||||||||||||||
| 191 | |||||||||||||||||||||
| 192 | # Standard =head4 block... | ||||||||||||||||||||
| 193 | package Perl6::Perldoc::Block::head4; | ||||||||||||||||||||
| 194 | |||||||||||||||||||||
| 195 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 196 | 0 | my $self = shift; | |||||||||||||||||||
| 197 | 0 | my $title = $self->SUPER::to_text(@_); | |||||||||||||||||||
| 198 | 0 | $title =~ s{\A\s+|\s+\Z}{}gxms; | |||||||||||||||||||
| 199 | 0 | $title =~ s{\s+}{ }gxms; | |||||||||||||||||||
| 200 | 0 | my $number = $self->number; | |||||||||||||||||||
| 201 | 0 | ▶ | if (defined $number) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 202 | 0 | $title = "$number. $title"; | |||||||||||||||||||
| 203 | } | ||||||||||||||||||||
| 204 | 0 | return "\n\n$title\n"; | |||||||||||||||||||
| 205 | } | ||||||||||||||||||||
| 206 | |||||||||||||||||||||
| 207 | # Implicit list block... | ||||||||||||||||||||
| 208 | package Perl6::Perldoc::Block::list; | ||||||||||||||||||||
| 209 | 1 | ▶ | use base 'Perl6::Perldoc::Root'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 210 | |||||||||||||||||||||
| 211 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 212 | 0 | my $self = shift; | |||||||||||||||||||
| 213 | 0 | return $self->add_text_nesting($self->SUPER::to_text(@_)); | |||||||||||||||||||
| 214 | } | ||||||||||||||||||||
| 215 | |||||||||||||||||||||
| 216 | |||||||||||||||||||||
| 217 | # Standard =item block... | ||||||||||||||||||||
| 218 | package Perl6::Perldoc::Block::item; | ||||||||||||||||||||
| 219 | |||||||||||||||||||||
| 220 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=4 SCAR=30.0
| |||||||||||||||||||||
| 221 | 0 | my $self = shift; | |||||||||||||||||||
| 222 | |||||||||||||||||||||
| 223 | 0 | my $counter = $self->number; | |||||||||||||||||||
| 224 | 0 | ▶ | $counter = $counter ? qq{$counter.} : q{*}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 225 | |||||||||||||||||||||
| 226 | 0 | my $body = $self->SUPER::to_text(@_); | |||||||||||||||||||
| 227 | |||||||||||||||||||||
| 228 | 0 | ▶ | if (my $term = $self->term()) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 229 | 0 | $term = $self->term( {as_objects=>1} )->to_text(@_); | |||||||||||||||||||
| 230 | 0 | ▶ | if (length $counter) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 231 | 0 | $term =~ s{\A (\s* <[^>]+>)}{$1$counter. }xms; | |||||||||||||||||||
| 232 | } | ||||||||||||||||||||
| 233 | 0 | my $body = $self->add_text_nesting($body); | |||||||||||||||||||
| 234 | 0 | $body =~ s{\A \n+}{}xms; | |||||||||||||||||||
| 235 | 0 | return "\n$term\n$body"; | |||||||||||||||||||
| 236 | } | ||||||||||||||||||||
| 237 | |||||||||||||||||||||
| 238 | 0 | $body = $self->add_text_nesting($body, 1 + length $counter); | |||||||||||||||||||
| 239 | 0 | $body =~ s{\A \n+}{}xms; | |||||||||||||||||||
| 240 | 0 | $body =~ s{\A \s*}{$counter }xms; | |||||||||||||||||||
| 241 | |||||||||||||||||||||
| 242 | 0 | return "\n$body"; | |||||||||||||||||||
| 243 | } | ||||||||||||||||||||
| 244 | |||||||||||||||||||||
| 245 | # Implicit toclist block... | ||||||||||||||||||||
| 246 | package Perl6::Perldoc::Block::toclist; | ||||||||||||||||||||
| 247 | 1 | ▶ | use base 'Perl6::Perldoc::Root'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 248 | |||||||||||||||||||||
| 249 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 250 | 0 | my $self = shift; | |||||||||||||||||||
| 251 | |||||||||||||||||||||
| 252 | # Convert list items to text, and return in an text list... | ||||||||||||||||||||
| 253 | 0 | my $text = join q{}, map {$_->to_text(@_)} $self->content; | |||||||||||||||||||
| 254 | |||||||||||||||||||||
| 255 | 0 | return $self->add_text_nesting($text); | |||||||||||||||||||
| 256 | } | ||||||||||||||||||||
| 257 | |||||||||||||||||||||
| 258 | |||||||||||||||||||||
| 259 | # Standard =tocitem block... | ||||||||||||||||||||
| 260 | package Perl6::Perldoc::Block::tocitem; | ||||||||||||||||||||
| 261 | |||||||||||||||||||||
| 262 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 263 | 0 | my $self = shift; | |||||||||||||||||||
| 264 | |||||||||||||||||||||
| 265 | 0 | my @title = $self->title; | |||||||||||||||||||
| 266 | 0 | ▶ | return "" if ! @title; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 267 | |||||||||||||||||||||
| 268 | 0 | my $title = Perl6::Perldoc::Root::_list_to_text(\@title, @_); | |||||||||||||||||||
| 269 | |||||||||||||||||||||
| 270 | 0 | return "* $title\n"; | |||||||||||||||||||
| 271 | } | ||||||||||||||||||||
| 272 | |||||||||||||||||||||
| 273 | # Handle headN's and itemN's and tocitemN's... | ||||||||||||||||||||
| 274 | 1 | for my $depth (1..100) { | |||||||||||||||||||
| 275 | 1 | ▶ | no strict qw< refs >; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 276 | |||||||||||||||||||||
| 277 | 100 | @{'Perl6::Perldoc::Block::item'.$depth.'::ISA'} | |||||||||||||||||||
| 278 | = 'Perl6::Perldoc::Block::item'; | ||||||||||||||||||||
| 279 | |||||||||||||||||||||
| 280 | 100 | @{'Perl6::Perldoc::Block::tocitem'.$depth.'::ISA'} | |||||||||||||||||||
| 281 | = 'Perl6::Perldoc::Block::tocitem'; | ||||||||||||||||||||
| 282 | |||||||||||||||||||||
| 283 | 100 | ▶ | next if $depth < 5; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 284 | 96 | @{'Perl6::Perldoc::Block::head'.$depth.'::ISA'} | |||||||||||||||||||
| 285 | = 'Perl6::Perldoc::Block::head4'; | ||||||||||||||||||||
| 286 | } | ||||||||||||||||||||
| 287 | # Handle headN's and itemN's | ||||||||||||||||||||
| 288 | 1 | for my $depth (1..100) { | |||||||||||||||||||
| 289 | 1 | ▶ | no strict qw< refs >; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 290 | 100 | @{'Perl6::Perldoc::Block::item'.$depth.'::ISA'} | |||||||||||||||||||
| 291 | = 'Perl6::Perldoc::Block::item'; | ||||||||||||||||||||
| 292 | } | ||||||||||||||||||||
| 293 | |||||||||||||||||||||
| 294 | # Standard =nested block... | ||||||||||||||||||||
| 295 | package Perl6::Perldoc::Block::nested; | ||||||||||||||||||||
| 296 | |||||||||||||||||||||
| 297 | |||||||||||||||||||||
| 298 | # Standard =comment block... | ||||||||||||||||||||
| 299 | package Perl6::Perldoc::Block::comment; | ||||||||||||||||||||
| 300 | |||||||||||||||||||||
| 301 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 302 | 0 | return q{}; | |||||||||||||||||||
| 303 | } | ||||||||||||||||||||
| 304 | |||||||||||||||||||||
| 305 | # Standard SEMANTIC blocks... | ||||||||||||||||||||
| 306 | package Perl6::Perldoc::Block::Semantic; | ||||||||||||||||||||
| 307 | 1 | ▶ | BEGIN { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=8.8
| |||||||||||||||||||||
| 308 | 1 | my @semantic_blocks = qw( | |||||||||||||||||||
| 309 | NAME NAMES | ||||||||||||||||||||
| 310 | VERSION VERSIONS | ||||||||||||||||||||
| 311 | SYNOPSIS SYNOPSES | ||||||||||||||||||||
| 312 | DESCRIPTION DESCRIPTIONS | ||||||||||||||||||||
| 313 | USAGE USAGES | ||||||||||||||||||||
| 314 | INTERFACE INTERFACES | ||||||||||||||||||||
| 315 | METHOD METHODS | ||||||||||||||||||||
| 316 | SUBROUTINE SUBROUTINES | ||||||||||||||||||||
| 317 | OPTION OPTIONS | ||||||||||||||||||||
| 318 | DIAGNOSTIC DIAGNOSTICS | ||||||||||||||||||||
| 319 | ERROR ERRORS | ||||||||||||||||||||
| 320 | WARNING WARNINGS | ||||||||||||||||||||
| 321 | DEPENDENCY DEPENDENCIES | ||||||||||||||||||||
| 322 | BUG BUGS | ||||||||||||||||||||
| 323 | SEEALSO SEEALSOS | ||||||||||||||||||||
| 324 | ACKNOWLEDGEMENT ACKNOWLEDGEMENTS | ||||||||||||||||||||
| 325 | AUTHOR AUTHORS | ||||||||||||||||||||
| 326 | COPYRIGHT COPYRIGHTS | ||||||||||||||||||||
| 327 | DISCLAIMER DISCLAIMERS | ||||||||||||||||||||
| 328 | LICENCE LICENCES | ||||||||||||||||||||
| 329 | LICENSE LICENSES | ||||||||||||||||||||
| 330 | TITLE TITLES | ||||||||||||||||||||
| 331 | SECTION SECTIONS | ||||||||||||||||||||
| 332 | CHAPTER CHAPTERS | ||||||||||||||||||||
| 333 | APPENDIX APPENDIXES APPENDICES | ||||||||||||||||||||
| 334 | TOC TOCS | ||||||||||||||||||||
| 335 | INDEX INDEXES INDICES | ||||||||||||||||||||
| 336 | FOREWORD FOREWORDS | ||||||||||||||||||||
| 337 | SUMMARY SUMMARIES | ||||||||||||||||||||
| 338 | ); | ||||||||||||||||||||
| 339 | |||||||||||||||||||||
| 340 | # Reuse content-to-text converter | ||||||||||||||||||||
| 341 | 1 | *_list_to_text = *Perl6::Perldoc::Root::_list_to_text; | |||||||||||||||||||
| 342 | |||||||||||||||||||||
| 343 | 1 | for my $blockname (@semantic_blocks) { | |||||||||||||||||||
| 344 | 1 | ▶ | no strict qw< refs >; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 345 | |||||||||||||||||||||
| 346 | 60 | *{ "Perl6::Perldoc::Block::${blockname}::to_text" } | |||||||||||||||||||
| 347 | 0 | ▶ | = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 348 | 0 | my $self = shift; | |||||||||||||||||||
| 349 | |||||||||||||||||||||
| 350 | 0 | my @title = $self->title(); | |||||||||||||||||||
| 351 | |||||||||||||||||||||
| 352 | 0 | ▶ | return "" if !@title; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 353 | 0 | my $title = _list_to_text(\@title, @_); | |||||||||||||||||||
| 354 | |||||||||||||||||||||
| 355 | 0 | return "\n$title\n\n" | |||||||||||||||||||
| 356 | . _list_to_text([$self->content], @_); | ||||||||||||||||||||
| 357 | 60 | }; | |||||||||||||||||||
| 358 | } | ||||||||||||||||||||
| 359 | } | ||||||||||||||||||||
| 360 | |||||||||||||||||||||
| 361 | |||||||||||||||||||||
| 362 | # Base class for formatting codes... | ||||||||||||||||||||
| 363 | |||||||||||||||||||||
| 364 | package Perl6::Perldoc::FormattingCode; | ||||||||||||||||||||
| 365 | |||||||||||||||||||||
| 366 | package Perl6::Perldoc::FormattingCode::Named; | ||||||||||||||||||||
| 367 | |||||||||||||||||||||
| 368 | # Basis formatter... | ||||||||||||||||||||
| 369 | package Perl6::Perldoc::FormattingCode::B; | ||||||||||||||||||||
| 370 | |||||||||||||||||||||
| 371 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 372 | 0 | my $self = shift; | |||||||||||||||||||
| 373 | 0 | return '*' . $self->SUPER::to_text(@_) . '*'; | |||||||||||||||||||
| 374 | } | ||||||||||||||||||||
| 375 | |||||||||||||||||||||
| 376 | # Code formatter... | ||||||||||||||||||||
| 377 | package Perl6::Perldoc::FormattingCode::C; | ||||||||||||||||||||
| 378 | |||||||||||||||||||||
| 379 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 380 | 0 | my $self = shift; | |||||||||||||||||||
| 381 | 0 | return '`' . $self->SUPER::to_text(@_) . '`'; | |||||||||||||||||||
| 382 | } | ||||||||||||||||||||
| 383 | |||||||||||||||||||||
| 384 | # Definition formatter... | ||||||||||||||||||||
| 385 | package Perl6::Perldoc::FormattingCode::D; | ||||||||||||||||||||
| 386 | |||||||||||||||||||||
| 387 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 388 | 0 | my $self = shift; | |||||||||||||||||||
| 389 | 0 | return '/' . $self->SUPER::to_text(@_) . '/'; | |||||||||||||||||||
| 390 | } | ||||||||||||||||||||
| 391 | |||||||||||||||||||||
| 392 | |||||||||||||||||||||
| 393 | # Entity formatter... | ||||||||||||||||||||
| 394 | package Perl6::Perldoc::FormattingCode::E; | ||||||||||||||||||||
| 395 | |||||||||||||||||||||
| 396 | 1 | my %is_break_entity = ( | |||||||||||||||||||
| 397 | 'LINE FEED (LF)' => 1, LF => 1, | ||||||||||||||||||||
| 398 | 'CARRIAGE RETURN (CR)' => 1, CR => 1, | ||||||||||||||||||||
| 399 | 'NEXT LINE (NEL)' => 1, NEL => 1, | ||||||||||||||||||||
| 400 | |||||||||||||||||||||
| 401 | 'FORM FEED (FF)' => 10, FF => 10, | ||||||||||||||||||||
| 402 | ); | ||||||||||||||||||||
| 403 | |||||||||||||||||||||
| 404 | 1 | my %is_translatable = ( | |||||||||||||||||||
| 405 | nbsp => q{ }, | ||||||||||||||||||||
| 406 | bull => q{*}, | ||||||||||||||||||||
| 407 | mdash => q{--}, | ||||||||||||||||||||
| 408 | ndash => q{--}, | ||||||||||||||||||||
| 409 | ); | ||||||||||||||||||||
| 410 | |||||||||||||||||||||
| 411 | # Convert E<> contents to text named or numeric entity... | ||||||||||||||||||||
| 412 | 0 | ▶ | sub _to_text_entity { | ||||||||||||||||||
|
Subroutine
_to_text_entity: not called CC=5 SCAR=30.5
| |||||||||||||||||||||
| 413 | 0 | my ($spec) = @_; | |||||||||||||||||||
| 414 | # Is it a line break? | ||||||||||||||||||||
| 415 | 0 | ▶ | if (my $BR_count = $is_break_entity{$spec}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 416 | 0 | return "\n" x $BR_count; | |||||||||||||||||||
| 417 | } | ||||||||||||||||||||
| 418 | # Is it a numeric codepoint in some base... | ||||||||||||||||||||
| 419 | 0 | ▶ | if ($spec =~ m{\A \d}xms) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 420 | # Convert Perl 6 octals and decimals to Perl 5 notation... | ||||||||||||||||||||
| 421 | 0 | ▶ | if ($spec !~ s{\A 0o}{0}xms) { # Convert octal | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 422 | 0 | $spec =~ s{\A 0d}{}xms; # Convert explicit decimal | |||||||||||||||||||
| 423 | 0 | $spec =~ s{\A 0+ (?=\d)}{}xms; # Convert implicit decimal | |||||||||||||||||||
| 424 | } | ||||||||||||||||||||
| 425 | |||||||||||||||||||||
| 426 | # Then return the Xtext numeric code... | ||||||||||||||||||||
| 427 | 1 | ▶ | use charnames ':full'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 428 | 0 | $spec = charnames::viacode(eval $spec); | |||||||||||||||||||
| 429 | } | ||||||||||||||||||||
| 430 | 0 | ▶ | if (my $replacement = $is_translatable{$spec}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 431 | 0 | return $replacement; | |||||||||||||||||||
| 432 | } | ||||||||||||||||||||
| 433 | else { | ||||||||||||||||||||
| 434 | 0 | return "[$spec]"; | |||||||||||||||||||
| 435 | } | ||||||||||||||||||||
| 436 | } | ||||||||||||||||||||
| 437 | |||||||||||||||||||||
| 438 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 439 | 0 | my $self = shift; | |||||||||||||||||||
| 440 | 0 | my $entities = $self->content; | |||||||||||||||||||
| 441 | 0 | return join q{}, map {_to_text_entity($_)} split /\s*;\s*/, $entities; | |||||||||||||||||||
| 442 | } | ||||||||||||||||||||
| 443 | |||||||||||||||||||||
| 444 | # Important formatter... | ||||||||||||||||||||
| 445 | package Perl6::Perldoc::FormattingCode::I; | ||||||||||||||||||||
| 446 | |||||||||||||||||||||
| 447 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 448 | 0 | my $self = shift; | |||||||||||||||||||
| 449 | 0 | return '_' . $self->SUPER::to_text(@_) . '_'; | |||||||||||||||||||
| 450 | } | ||||||||||||||||||||
| 451 | |||||||||||||||||||||
| 452 | # Keyboard input formatter... | ||||||||||||||||||||
| 453 | package Perl6::Perldoc::FormattingCode::K; | ||||||||||||||||||||
| 454 | |||||||||||||||||||||
| 455 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 456 | 0 | my $self = shift; | |||||||||||||||||||
| 457 | 0 | return '`' . $self->SUPER::to_text(@_) . '`'; | |||||||||||||||||||
| 458 | } | ||||||||||||||||||||
| 459 | |||||||||||||||||||||
| 460 | # Link formatter... | ||||||||||||||||||||
| 461 | package Perl6::Perldoc::FormattingCode::L; | ||||||||||||||||||||
| 462 | |||||||||||||||||||||
| 463 | 1 | my $PERLDOC_ORG = 'http://perldoc.perl.org/'; | |||||||||||||||||||
| 464 | 1 | my $SEARCH = 'http://www.google.com/search?q='; | |||||||||||||||||||
| 465 | |||||||||||||||||||||
| 466 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=11 SCAR=48.8
| |||||||||||||||||||||
| 467 | 0 | my $self = shift; | |||||||||||||||||||
| 468 | 0 | my $target = $self->target(); | |||||||||||||||||||
| 469 | 0 | ▶ | my $text = $self->has_distinct_text ? $self->SUPER::to_text(@_) : undef; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 470 | |||||||||||||||||||||
| 471 | # Link within this document... | ||||||||||||||||||||
| 472 | 0 | ▶ | if ($target =~ s{\A (?:doc:\s*)? [#] }{}xms ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 473 | 0 | ▶ | return defined $text ? qq{$text (see the "$target" section)} | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 474 | : qq{the "$target" section} | ||||||||||||||||||||
| 475 | } | ||||||||||||||||||||
| 476 | |||||||||||||||||||||
| 477 | # Link to other documentation... | ||||||||||||||||||||
| 478 | 0 | ▶ | if ($target =~ s{\A doc: }{}xms) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 479 | 0 | ▶ | return defined $text ? qq{$text (see the documentation for $target)} | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 480 | : qq{the documentation for $target} | ||||||||||||||||||||
| 481 | } | ||||||||||||||||||||
| 482 | |||||||||||||||||||||
| 483 | # Link to manpage... | ||||||||||||||||||||
| 484 | 0 | ▶ | if ($target =~ s{\A man: }{}xms) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 485 | 0 | ▶ | return defined $text ? qq{$text (see the $target manpage)} | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 486 | : qq{the $target manpage} | ||||||||||||||||||||
| 487 | } | ||||||||||||||||||||
| 488 | |||||||||||||||||||||
| 489 | # Link back to definition in this document... | ||||||||||||||||||||
| 490 | 0 | ▶ | if ($target =~ s{\A (?:defn) : }{}xms) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 491 | 0 | ▶ | return defined $text ? qq{$text (see the definition of "$target")} | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 492 | : $target | ||||||||||||||||||||
| 493 | } | ||||||||||||||||||||
| 494 | |||||||||||||||||||||
| 495 | # Anything else... | ||||||||||||||||||||
| 496 | 0 | ▶ | return defined $text ? qq{$text <$target>} | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 497 | : $target; | ||||||||||||||||||||
| 498 | } | ||||||||||||||||||||
| 499 | |||||||||||||||||||||
| 500 | # Meta-formatter... | ||||||||||||||||||||
| 501 | package Perl6::Perldoc::FormattingCode::M; | ||||||||||||||||||||
| 502 | |||||||||||||||||||||
| 503 | |||||||||||||||||||||
| 504 | # Note formatter... | ||||||||||||||||||||
| 505 | package Perl6::Perldoc::FormattingCode::N; | ||||||||||||||||||||
| 506 | |||||||||||||||||||||
| 507 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 508 | 0 | my $self = shift; | |||||||||||||||||||
| 509 | 0 | my $count = ++$_[0]{note_count}; | |||||||||||||||||||
| 510 | 0 | my $marker = "[$count]"; | |||||||||||||||||||
| 511 | 0 | $_[0]{notes} .= qq{$marker } . $self->SUPER::to_text(@_) . "\n"; | |||||||||||||||||||
| 512 | 0 | return qq{$marker}; | |||||||||||||||||||
| 513 | } | ||||||||||||||||||||
| 514 | |||||||||||||||||||||
| 515 | # Placement link formatter... | ||||||||||||||||||||
| 516 | package Perl6::Perldoc::FormattingCode::P; | ||||||||||||||||||||
| 517 | |||||||||||||||||||||
| 518 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=5 SCAR=34.0
| |||||||||||||||||||||
| 519 | 0 | my $self = shift; | |||||||||||||||||||
| 520 | 0 | my $target = $self->target(); | |||||||||||||||||||
| 521 | |||||||||||||||||||||
| 522 | # Link within this document... | ||||||||||||||||||||
| 523 | 0 | ▶ | if ($target =~ s{\A (?:doc:\s*)? [#] }{}xms ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 524 | 0 | return qq{(See the "$target" section)}; | |||||||||||||||||||
| 525 | } | ||||||||||||||||||||
| 526 | |||||||||||||||||||||
| 527 | # Link to other documentation... | ||||||||||||||||||||
| 528 | 0 | ▶ | if ($target =~ s{\A doc: }{}xms) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 529 | 0 | return qq{(See the documentation for $target)}; | |||||||||||||||||||
| 530 | } | ||||||||||||||||||||
| 531 | |||||||||||||||||||||
| 532 | # Link to manpage... | ||||||||||||||||||||
| 533 | 0 | ▶ | if ($target =~ s{\A man: }{}xms) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 534 | 0 | return qq{(See the $target manpage)}; | |||||||||||||||||||
| 535 | } | ||||||||||||||||||||
| 536 | |||||||||||||||||||||
| 537 | # TOC insertion... | ||||||||||||||||||||
| 538 | 0 | ▶ | if ($target =~ s{\A toc: }{}xms) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 539 | 0 | return Perl6::Perldoc::Root::_list_to_text([$self->content],@_); | |||||||||||||||||||
| 540 | } | ||||||||||||||||||||
| 541 | |||||||||||||||||||||
| 542 | # Anything else... | ||||||||||||||||||||
| 543 | 0 | $target =~ s{\A (?:defn) : }{}xms; | |||||||||||||||||||
| 544 | 0 | return qq{(See $target)}; | |||||||||||||||||||
| 545 | } | ||||||||||||||||||||
| 546 | |||||||||||||||||||||
| 547 | # Replacable item formatter... | ||||||||||||||||||||
| 548 | package Perl6::Perldoc::FormattingCode::R; | ||||||||||||||||||||
| 549 | |||||||||||||||||||||
| 550 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 551 | 0 | my $self = shift; | |||||||||||||||||||
| 552 | 0 | return '[' . $self->SUPER::to_text(@_) . ']'; | |||||||||||||||||||
| 553 | } | ||||||||||||||||||||
| 554 | |||||||||||||||||||||
| 555 | # Space-preserving formatter... | ||||||||||||||||||||
| 556 | package Perl6::Perldoc::FormattingCode::S; | ||||||||||||||||||||
| 557 | |||||||||||||||||||||
| 558 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 559 | 0 | my $self = shift; | |||||||||||||||||||
| 560 | 0 | return $self->SUPER::to_text(@_); | |||||||||||||||||||
| 561 | } | ||||||||||||||||||||
| 562 | |||||||||||||||||||||
| 563 | |||||||||||||||||||||
| 564 | # Terminal output formatter... | ||||||||||||||||||||
| 565 | package Perl6::Perldoc::FormattingCode::T; | ||||||||||||||||||||
| 566 | |||||||||||||||||||||
| 567 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 568 | 0 | my $self = shift; | |||||||||||||||||||
| 569 | 0 | return '`' . $self->SUPER::to_text(@_) . '`'; | |||||||||||||||||||
| 570 | } | ||||||||||||||||||||
| 571 | |||||||||||||||||||||
| 572 | # Unusual formatter... | ||||||||||||||||||||
| 573 | package Perl6::Perldoc::FormattingCode::U; | ||||||||||||||||||||
| 574 | |||||||||||||||||||||
| 575 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 576 | 0 | my $self = shift; | |||||||||||||||||||
| 577 | 0 | return '_' . $self->SUPER::to_text(@_) . '_'; | |||||||||||||||||||
| 578 | } | ||||||||||||||||||||
| 579 | |||||||||||||||||||||
| 580 | # Verbatim formatter... | ||||||||||||||||||||
| 581 | package Perl6::Perldoc::FormattingCode::V; | ||||||||||||||||||||
| 582 | |||||||||||||||||||||
| 583 | # indeX formatter... | ||||||||||||||||||||
| 584 | package Perl6::Perldoc::FormattingCode::X; | ||||||||||||||||||||
| 585 | |||||||||||||||||||||
| 586 | # Zero-width formatter... | ||||||||||||||||||||
| 587 | package Perl6::Perldoc::FormattingCode::Z; | ||||||||||||||||||||
| 588 | |||||||||||||||||||||
| 589 | 0 | ▶ | sub to_text { | ||||||||||||||||||
|
Subroutine
to_text: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 590 | 0 | return q{}; | |||||||||||||||||||
| 591 | } | ||||||||||||||||||||
| 592 | |||||||||||||||||||||
| 593 | |||||||||||||||||||||
| 594 | # Standard =table block... | ||||||||||||||||||||
| 595 | package Perl6::Perldoc::Block::table; | ||||||||||||||||||||
| 596 | |||||||||||||||||||||
| 597 | |||||||||||||||||||||
| 598 | 1 | 1; # Magic true value required at end of module | |||||||||||||||||||
| 599 | __END__ | ||||||||||||||||||||