| 1 | package Pod::Perldoc::ToFancy; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use v5.14; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | our $VERSION = "0.02"; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | # Modeled after Pod::Perldoc::ToTerm (Pod-Perldoc 3.28). | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use parent 'Pod::Perldoc::BaseTo'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Pod::Text::Fancy (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub is_pageable { 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_pageable: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | sub write_with_binmode { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_with_binmode: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | sub output_extension { 'txt' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output_extension: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 17 | ▶ | sub new { return bless {}, ref($_[0]) || $_[0] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=9.2
Pod
undocumented
Condition33%1/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub alt { shift->_perldoc_elem('alt' , @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub indent { shift->_perldoc_elem('indent' , @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
indent: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub loose { shift->_perldoc_elem('loose' , @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loose: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub quotes { shift->_perldoc_elem('quotes' , @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quotes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub sentence { shift->_perldoc_elem('sentence', @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sentence: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | sub theme { shift->_perldoc_elem('_theme' , @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
theme: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | sub base { shift->_perldoc_elem('_base' , @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | sub wall { shift->_perldoc_elem('_wall' , @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wall: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | # -w colormap:label=spec, repeatable. | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | sub colormap { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
colormap: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | my ($label, $spec) = split /=/, $value, 2; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | $self->{_colormap}{$label} = $spec; | |||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | # Width given by the user (-w width or MANWIDTH) is the desired line | ||||||||||||||||||||||||||||||||||||||||||
| 36 | # length, which run-in may exceed. Terminal width is a physical limit, | ||||||||||||||||||||||||||||||||||||||||||
| 37 | # so leave room for run-in. | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 20 | ▶ | sub width { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
width: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 20 | ▶ | return $self->_perldoc_elem('width', @_) if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | $self->_perldoc_elem('width') | ||||||||||||||||||||||||||||||||||||||||||
| 42 | || $self->_get_columns_from_manwidth | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 19 | ▶ | || do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$self->_perldoc_elem("width") or $self->_get_columns_from_manwidth or do {
my $cols = $self->_get_columns_from_stty;
$cols ? $cols - "Pod::Text::Fancy"->runin : 0
}
$self->_perldoc_elem("width") or $self->_get_columns_from_manwidth
MC/DC100%3/3
$self->_perldoc_elem("width") or $self->_get_columns_from_manwidth or do {
my $cols = $self->_get_columns_from_stty;
$cols ? $cols - "Pod::Text::Fancy"->runin : 0
}
$self->_perldoc_elem("width")
$self->_get_columns_from_manwidth
do {
my $cols = $self->_get_columns_from_stty;
$cols ? $cols - "Pod::Text::Fancy"->runin : 0
}
Truth table100%4/4
A or B or C
A= $self->_perldoc_elem("width")B= $self->_get_columns_from_manwidthC= do {
my $cols = $self->_get_columns_from_stty;
$cols ? $cols - "Pod::Text::Fancy"->runin : 0
}
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 16 | my $cols = $self->_get_columns_from_stty; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 16 | ▶ | $cols ? $cols - Pod::Text::Fancy->runin : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | || $self->_get_default_width; | ||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | # An explicit theme is always used, unless NO_COLOR is set | ||||||||||||||||||||||||||||||||||||||||||
| 51 | # (no-color.org). The default theme quiet is used only on a terminal. | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 15 | ▶ | sub _theme_to_use { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_theme_to_use: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 15 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 15 | ▶ | return 'none' if defined $ENV{NO_COLOR} and $ENV{NO_COLOR} ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $ENV{"NO_COLOR"} and $ENV{"NO_COLOR"} ne ""
MC/DC100%2/2
defined $ENV{"NO_COLOR"} and $ENV{"NO_COLOR"} ne ""
defined $ENV{"NO_COLOR"}
$ENV{"NO_COLOR"} ne ""
Truth table100%3/3
A and B
A= defined $ENV{"NO_COLOR"}B= $ENV{"NO_COLOR"} ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 13 | ▶ | return $self->{_theme} if defined $self->{_theme}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 11 | ▶ | return 'none' if !$ENV{TERM} or $ENV{TERM} eq 'dumb'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $ENV{"TERM"} or $ENV{"TERM"} eq "dumb"
MC/DC100%2/2
not $ENV{"TERM"} or $ENV{"TERM"} eq "dumb"
not $ENV{"TERM"}
$ENV{"TERM"} eq "dumb"
Truth table100%3/3
not(A) or B
A= not $ENV{"TERM"}B= $ENV{"TERM"} eq "dumb"
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 9 | ▶ | return 'none' unless $self->_stdout_is_tty; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 7 | return 'quiet'; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | ▶ | sub _stdout_is_tty { -t STDOUT } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stdout_is_tty: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | # Options passed to Pod::Text::Fancy->new. | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 15 | ▶ | sub fancy_options { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fancy_options: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 15 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my %opt = map { $_ => $self->{$_} } grep { !/^_/ } keys %$self; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 15 | $opt{width} = $self->width; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 15 | $opt{theme} = $self->_theme_to_use; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 15 | ▶ | $opt{base} = $self->{_base} if defined $self->{_base}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 15 | ▶ | $opt{wall} = $self->{_wall} if defined $self->{_wall}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 15 | ▶ | $opt{colormap} = { %{ $self->{_colormap} // {} } }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"_colormap"} // {}
MC/DC100%1/1
$self->{"_colormap"} // {}
$self->{"_colormap"}
Truth table100%2/2
A
A= $self->{"_colormap"}
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 15 | return \%opt; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub pager_configuration { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pager_configuration: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my ($self, $pager, $perldoc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | return if $perldoc->is_mswin32 || $perldoc->is_dos; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$perldoc->is_mswin32 or $perldoc->is_dos
MC/DC0%0/2
$perldoc->is_mswin32 or $perldoc->is_dos
$perldoc->is_mswin32
$perldoc->is_dos
Truth table0%0/3
A or B
A= $perldoc->is_mswin32B= $perldoc->is_dos
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | if ($pager =~ /less/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $self->_maybe_modify_environment('LESS'); | |||||||||||||||||||||||||||||||||||||||||
| 80 | } elsif ($pager =~ /more/) { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $self->_maybe_modify_environment('MORE'); | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub _maybe_modify_environment { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_modify_environment: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | $ENV{$name} = '-R' unless defined $ENV{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub _get_stty { `stty -a` } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_stty: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 16 | ▶ | sub _get_columns_from_stty { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_columns_from_stty: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 16 | ▶ | my $output = $_[0]->_get_stty // ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0]->_get_stty // ""
MC/DC0%0/1
$_[0]->_get_stty // ""
$_[0]->_get_stty
Truth table50%1/2
A
A= $_[0]->_get_stty
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 16 | ▶ | return $1 if $output =~ /\bcolumns\s+(\d+)/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 16 | ▶ | return $1 if $output =~ /;\s*(\d+)\s+columns;/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 15 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 18 | ▶ | sub _get_columns_from_manwidth { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_columns_from_manwidth: called CC=4 SCAR=15.5
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 18 | my $w = $ENV{MANWIDTH}; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 18 | ▶ | return 0 unless defined $w; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | ▶ | unless ($w =~ /\A\d+\z/ and $w > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$w =~ /\A\d+\z/u and $w > 0
MC/DC0%0/2
$w =~ /\A\d+\z/u and $w > 0
$w =~ /\A\d+\z/u
$w > 0
Truth table33%1/3
A and B
A= $w =~ /\A\d+\z/uB= $w > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $self->warn("Ignoring invalid MANWIDTH ($w)\n"); | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | return $w; | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 15 | ▶ | sub _get_default_width { 76 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_default_width: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | ▶ | sub parse_from_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_from_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | my %opt = %{ $self->fancy_options }; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | Pod::Text::Fancy->new(%opt)->parse_from_file(@_); | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 120 | __END__ | ||||||||||||||||||||||||||||||||||||||||||