Sub/To/Text.pm

filter: Statementstmt 31.5% 18 / 57 Branchbran 0.0% 0 / 28 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 2 totaltotal 19.8% 22 / 111 CC 20 SCAR 58.2
CC
20
Cov
19%
after_gen_doc
420.0
BUILD
2.0
BEGIN
1.0
CRAP 336.2
« To/Doc/Role/Section/AddTextLines.pm ↑ Summary Sub/To/FuncBase.pm »
1 package Perinci::Sub::To::Text;
2  
3 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Log::ger;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Locale::TextDomain::UTF8 'Perinci-To-Doc';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 extends 'Perinci::Sub::To::FuncBase';
10 1 with 'Perinci::To::Doc::Role::Section::AddTextLines';
11  
12 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
13 1 our $DATE = '2023-07-09'; # DATE
14 1 our $DIST = 'Perinci-To-Doc'; # DIST
15 1 our $VERSION = '0.881'; # VERSION
16  
17 0 ▶sub BUILD {
Subroutine BUILD: not called CC=1 SCAR=6.9
Pod undocumented
18 0 my ($self, $args) = @_;
19 }
20  
21 # because we need stuffs in parent's gen_doc_section_arguments() even to print
22 # the name, we'll just do everything in after_gen_doc().
23 0 ▶sub after_gen_doc {
Subroutine after_gen_doc: not called CC=20 SCAR=60.4
Pod undocumented
24 0 my ($self) = @_;
25  
26 0 my $meta = $self->meta;
27 0 my $dres = $self->{_doc_res};
28  
29 0 ▶ my $orig_result_naked = $meta->{_orig_result_naked} // $meta->{result_naked};
Condition0%0/3
$meta->{"_orig_result_naked"} // $meta->{"result_naked"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$meta->{"_orig_result_naked"} // $meta->{"result_naked"}
$meta->{"_orig_result_naked"} $meta->{"result_naked"}
Truth table0%0/3
A // B
A= $meta->{"_orig_result_naked"}B= $meta->{"result_naked"}
ABresult
1X1
011
000
30  
31 $self->add_doc_lines(
32 "+ ".$dres->{name}.$dres->{args_plterm}.' -> '.$dres->{human_ret},
33 0 );
34 0 $self->inc_doc_indent;
35  
36 0 ▶ $self->add_doc_lines("", $dres->{summary}) if $dres->{summary};
Branch: 1 branch
BranchTrueFalseTotal
if $dres->{"summary"} 0 0 0
37 0 ▶ $self->add_doc_lines("", $dres->{description}) if $dres->{description};
Branch: 1 branch
BranchTrueFalseTotal
if $dres->{"description"} 0 0 0
38 0 ▶ if (keys %{$dres->{args}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$$dres{"args"};}) 0 0 0
39 0 $self->add_doc_lines(
40 "",
41 __("Arguments") .
42 ' (' . __("'*' denotes required arguments") . '):',
43 "");
44 0 my $i = 0;
45 0 my $arg_has_ct;
46 0 for my $name (sort keys %{$dres->{args}}) {
47 0 my $prev_arg_has_ct = $arg_has_ct;
48 0 $arg_has_ct = 0;
49 0 my $ra = $dres->{args}{$name};
50 0 ▶ next if grep { $_ eq 'hidden' } @{ $ra->{arg}{tags} // [] };
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ eq "hidden";} @{$ra->{"arg"}{"tags"} // [];} 0 0 0
Condition0%0/2
$ra->{"arg"}{"tags"} // []
l!l
00
MC/DC0%0/1
$ra->{"arg"}{"tags"} // []
$ra->{"arg"}{"tags"}
Truth table0%0/2
A
A= $ra->{"arg"}{"tags"}
Aresult
11
00
51 0 ▶ $self->add_doc_lines("") if $i++ > 0 && $prev_arg_has_ct;
Branch: 1 branch
BranchTrueFalseTotal
if $i++ > 0 and $prev_arg_has_ct 0 0 0
Condition0%0/3
$i++ > 0 and $prev_arg_has_ct
!ll&&!rl&&r
000
MC/DC0%0/2
$i++ > 0 and $prev_arg_has_ct
$i++ > 0 $prev_arg_has_ct
Truth table0%0/3
A and B
A= $i++ > 0B= $prev_arg_has_ct
ABresult
0X0
100
111
52 $self->add_doc_lines(join(
53 "",
54 "- ", $name, ($ra->{arg}{req} ? '*' : ''), ' => ',
55 $ra->{human_arg},
56 0 ▶ (defined($ra->{human_arg_default}) ?
Branch: 2 branches
BranchTrueFalseTotal
$ra->{'arg'}{'req'} ? : 0 0 0
defined $ra->{'human_arg_default'} ? : 0 0 0
57 " (" . __("default") .
58 ": $ra->{human_arg_default})" : "")
59 ));
60 0 ▶ if ($ra->{summary} || $ra->{description}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ra->{"summary"} or $ra->{"description"}) 0 0 0
Condition0%0/3
$ra->{"summary"} or $ra->{"description"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$ra->{"summary"} or $ra->{"description"}
$ra->{"summary"} $ra->{"description"}
Truth table0%0/3
A or B
A= $ra->{"summary"}B= $ra->{"description"}
ABresult
1X1
011
000
61 0 $arg_has_ct++;
62 0 $self->inc_doc_indent(2);
63 0 ▶ $self->add_doc_lines($ra->{summary}.".") if $ra->{summary};
Branch: 1 branch
BranchTrueFalseTotal
if $ra->{"summary"} 0 0 0
64 0 ▶ if ($ra->{description}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ra->{"description"}) 0 0 0
65 0 $self->add_doc_lines("", $ra->{description});
66 }
67 0 $self->dec_doc_indent(2);
68 }
69 }
70 }
71  
72 0 ▶ if ($meta->{dies_on_error}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($meta->{"dies_on_error"}) 0 0 0
73 0 $self->add_doc_lines("", __("This function dies on error."), "");
74 }
75  
76 0 $self->add_doc_lines("", __("Return value") . ':');
77 0 $self->inc_doc_indent;
78 0 ▶ $self->add_doc_lines(__(
Branch: 1 branch
BranchTrueFalseTotal
unless $orig_result_naked 0 0 0
79 'Returns an enveloped result (an array).
80  
81 First element ($status_code) is an integer containing HTTP-like status code
82 (200 means OK, 4xx caller error, 5xx function error). Second element
83 ($reason) is a string containing error message, or something like "OK" if status is
84 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth
85 element (%result_meta) is called result metadata and is optional, a hash
86 that contains extra information, much like how HTTP response headers provide additional metadata.'))
87 unless $orig_result_naked;
88 0 ▶ $self->add_doc_lines($dres->{res_summary} . ($dres->{res_schema} ? " ($dres->{res_schema}[0])" : "")) if $dres->{res_summary};
Branch: 2 branches
BranchTrueFalseTotal
if $dres->{"res_summary"} 0 0 0
$dres->{'res_schema'} ? : 0 0 0
89  
90 0 $self->dec_doc_indent;
91  
92 0 $self->dec_doc_indent;
93 }
94  
95 1 1;
96 # ABSTRACT: Generate text documentation from Rinci function metadata
97  
98 __END__
« To/Doc/Role/Section/AddTextLines.pm ↑ Summary Sub/To/FuncBase.pm »