Sub/To/POD.pm

filter: Statementstmt 9.3% 20 / 215 Branchbran 0.0% 0 / 142 Conditioncond 0.0% 0 / 42 MC/DCmcdc 0.0% 0 / 23 Subroutinesub 45.4% 5 / 11 Podpod 0.0% 0 / 2 totaltotal 5.7% 25 / 435 CC 93 SCAR 89.5
CC
93
Cov
5%
after_gen_doc
8535.5
BUILD
2.0
_podquote
2.0
CRAP 7707.0
↑ Summary To/Doc/Role/Section/AddTextLines.pm »
1 package Perinci::Sub::To::POD;
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  
11 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
12 1 our $DATE = '2023-07-09'; # DATE
13 1 our $DIST = 'Perinci-To-Doc'; # DIST
14 1 our $VERSION = '0.881'; # VERSION
15  
16 0 ▶sub BUILD {
Subroutine BUILD: not called CC=1 SCAR=6.9
Pod undocumented
17 0 my ($self, $args) = @_;
18 }
19  
20 0 ▶sub _podquote {
Subroutine _podquote: not called CC=1 SCAR=6.9
21 0 require String::PodQuote;
22 0 String::PodQuote::pod_quote($_[1]);
23 }
24  
25 0 ▶sub _md2pod {
Subroutine _md2pod: not called CC=1 SCAR=6.9
26 0 require Markdown::To::POD;
27  
28 0 my ($self, $md) = @_;
29 0 my $pod = Markdown::To::POD::markdown_to_pod($md);
30 # make sure we add a couple of blank lines in the end
31 0 $pod =~ s/\s+\z//s;
32 0 $pod . "\n\n\n";
33 }
34  
35 # because we need stuffs in parent's gen_doc_section_arguments() even to print
36 # the name, we'll just do everything in after_gen_doc().
37 0 ▶sub after_gen_doc {
Subroutine after_gen_doc: not called CC=93 SCAR=90.5
Pod undocumented
38 1 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
39 0 require Data::Dump::SortKeys;
40 0 local $Data::Dump::SortKeys::REMOVE_PRAGMAS = 1;
41  
42 0 my ($self) = @_;
43  
44 0 my $meta = $self->meta;
45 0 my $dres = $self->{_doc_res};
46  
47 0 my $orig_meta = $self->{_orig_meta};
48  
49 0 my $has_args = !!keys(%{$dres->{args}});
50  
51 0 $self->add_doc_lines("=head2 $dres->{name}", "");
52  
53 $self->add_doc_lines(
54 "Usage:",
55 "",
56 " " . $dres->{name} .
57 ($has_args ? $dres->{args_plterm} : "()").' -> '.$dres->{human_ret},
58 0 ▶ "");
Branch: 1 branch
BranchTrueFalseTotal
$has_args ? : 0 0 0
59  
60 {
61 0 my $pdres = $self->parent->{_doc_res};
62 0 my $fnames = $pdres->{function_names_by_meta_addr}{"$orig_meta"};
63 0 ▶ if ($fnames && @$fnames > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fnames and @$fnames > 1) 0 0 0
Condition0%0/3
$fnames and @$fnames > 1
!ll&&!rl&&r
000
MC/DC0%0/2
$fnames and @$fnames > 1
$fnames @$fnames > 1
Truth table0%0/3
A and B
A= $fnamesB= @$fnames > 1
ABresult
0X0
100
111
64 0 $self->add_doc_lines(
65 __("Alias for") . " C<$fnames->[0]>.",
66 "",
67 );
68 0 return;
69 }
70 }
71  
72 0 ▶ if (defined $dres->{summary}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dres->{"summary"}) 0 0 0
73 $self->add_doc_lines(
74 $self->_podquote($dres->{summary}) .
75 0 ▶ ($dres->{summary} =~ /\.$/ ? "":"."),
Branch: 1 branch
BranchTrueFalseTotal
$dres->{'summary'} =~ /\.$/ ? : 0 0 0
76 "");
77 }
78  
79 0 my $examples = $meta->{examples};
80 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
81 0 ▶ my $orig_args_as = $meta->{_orig_args_as} // 'hash';
Condition0%0/2
$meta->{"_orig_args_as"} // "hash"
l!l
00
MC/DC0%0/1
$meta->{"_orig_args_as"} // "hash"
$meta->{"_orig_args_as"}
Truth table0%0/2
A
A= $meta->{"_orig_args_as"}
Aresult
11
00
82 0 my $i = 0;
83 0 my @eg_lines;
84 0 my $arg_sorter = do {
85 0 require Perinci::Sub::Util::Sort;
86 0 require Sort::ByExample;
87 my $sorter = Sort::ByExample::sbe(
88 0 [ Perinci::Sub::Util::Sort::sort_args($meta->{args}) ]);
89 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
90 0 my $hash = shift;
91 0 $sorter->(keys %$hash);
92 0 };
93 };
94 EXAMPLE:
95 0 for my $eg (@$examples) {
96 0 $i++;
97 0 ▶ next if exists $eg->{doc} && !$eg->{doc};
Branch: 1 branch
BranchTrueFalseTotal
if exists $eg->{"doc"} and not $eg->{"doc"} 0 0 0
Condition0%0/3
exists $eg->{"doc"} and not $eg->{"doc"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $eg->{"doc"} and not $eg->{"doc"}
exists $eg->{"doc"} not $eg->{"doc"}
Truth table0%0/3
A and not(B)
A= exists $eg->{"doc"}B= not $eg->{"doc"}
ABresult
0X0
100
111
98 0 my $argsdump;
99 0 ▶ if ($eg->{args}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($eg->{'args'}) { } 0 0 0
elsif ($eg->{'argv'}) { } 0 0 0
100 0 local $Data::Dump::SortKeys::SORT_KEYS = $arg_sorter;
101 0 ▶ if ($orig_args_as =~ /array/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($orig_args_as =~ /array/) { } 0 0 0
102 0 require Perinci::Sub::ConvertArgs::Array;
103 my $cares = Perinci::Sub::ConvertArgs::Array::convert_args_to_array(
104 0 args => $eg->{args}, meta => $meta,
105 );
106 0 ▶ die "Can't convert args to argv in example #$i ".
Branch: 1 branch
BranchTrueFalseTotal
unless $cares->[0] == 200 0 0 0
107 "of function $dres->{name}): $cares->[0] - $cares->[1]"
108 unless $cares->[0] == 200;
109 0 $argsdump = Data::Dump::SortKeys::dump($cares->[2]);
110 0 ▶ unless ($orig_args_as =~ /ref/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($orig_args_as =~ /ref/) 0 0 0
111 0 $argsdump =~ s/\A\[\s*//s; $argsdump =~ s/,?\s*\]\s*\z//s;
112 }
113 } else {
114 0 $argsdump = Data::Dump::SortKeys::dump($eg->{args});
115 0 ▶ unless ($orig_args_as =~ /ref/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($orig_args_as =~ /ref/) 0 0 0
116 0 $argsdump =~ s/\A\{\s*//s; $argsdump =~ s/,?\s*\}\s*\z//s;
117 }
118 }
119 } elsif ($eg->{argv}) {
120 0 local $Data::Dump::SortKeys::SORT_KEYS = $arg_sorter;
121 0 ▶ if ($orig_args_as =~ /hash/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($orig_args_as =~ /hash/) { } 0 0 0
122 0 require Perinci::Sub::GetArgs::Argv;
123 my $gares = Perinci::Sub::GetArgs::Argv::get_args_from_argv(
124 0 argv => [@{ $eg->{argv} }],
125 meta => $meta,
126 per_arg_json => 1,
127 per_arg_yaml => 1,
128 );
129 0 ▶ die "Can't convert argv to args in example #$i ".
Branch: 1 branch
BranchTrueFalseTotal
unless $gares->[0] == 200 0 0 0
130 "of function $dres->{name}): $gares->[0] - $gares->[1]"
131 unless $gares->[0] == 200;
132 0 $argsdump = Data::Dump::SortKeys::dump($gares->[2]);
133 0 ▶ unless ($orig_args_as =~ /ref/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($orig_args_as =~ /ref/) 0 0 0
134 0 $argsdump =~ s/^\{\n*//; $argsdump =~ s/,?\s*\}\n?$//;
135 }
136 } else {
137 0 $argsdump = Data::Dump::SortKey::dump($eg->{argv});
138 0 ▶ unless ($orig_args_as =~ /ref/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($orig_args_as =~ /ref/) 0 0 0
139 0 $argsdump =~ s/^\[\n*//; $argsdump =~ s/,?\s*\]\n?$//;
140 }
141 }
142 } else {
143 # no argv or args, skip, probably not perl example
144 0 next EXAMPLE;
145 }
146 0 ▶ $argsdump =~ s/\A\s+// if $argsdump !~ /\R/;
Branch: 1 branch
BranchTrueFalseTotal
unless $argsdump =~ /\R/ 0 0 0
147 my $example_code = join(
148 "",
149 0 ▶ $dres->{name}, "(",
Branch: 2 branches
BranchTrueFalseTotal
$argsdump =~ /\n/ ? : 0 0 0
$argsdump =~ /\n/ ? : 0 0 0
150 $argsdump =~ /\n/ ? "\n " : "",
151 $argsdump,
152 $argsdump =~ /\n/ ? "\n" : "",
153 ");",
154 );
155 0 my $resdump;
156 GET_RESULT:
157 {
158 0 ▶ last unless $eg->{'x.doc.show_result'} // 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $eg->{"x.doc.show_result"} // 1 0 0 0
Condition0%0/2
$eg->{"x.doc.show_result"} // 1
l!l
00
MC/DC0%0/1
$eg->{"x.doc.show_result"} // 1
$eg->{"x.doc.show_result"}
Truth table0%0/2
A
A= $eg->{"x.doc.show_result"}
Aresult
11
00
159 0 log_trace("result_naked: %s", $meta->{result_naked});
160 0 log_trace("orig_result_naked: %s", $orig_result_naked);
161 0 my $envres;
162 my $tff;
163 0 ▶ if (exists $eg->{result}) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $eg->{'result'}) { } 0 0 0
elsif (exists $eg->{'naked_result'}) { } 0 0 0
elsif (exists $eg->{'env_result'}) { } 0 0 0
164 0 ▶ $envres = $orig_result_naked ? [200, "OK (envelope generated)", $eg->{result}] : $eg->{result};
Branch: 1 branch
BranchTrueFalseTotal
$orig_result_naked ? : 0 0 0
165 0 ▶ unless ($orig_result_naked) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($orig_result_naked) 0 0 0
166 0 $tff = $envres->[3]{'table.fields'};
167 }
168 } elsif (exists $eg->{naked_result}) {
169 0 $envres = [200, "OK (envelope generated)", $eg->{naked_result}];
170 } elsif (exists $eg->{env_result}) {
171 0 $envres = $eg->{env_result};
172 0 $tff = $envres->[3]{'table.fields'};
173 } else {
174 # NOTE: since we retrieve the result by calling through Riap,
175 # the result will enveloped and be json-cleaned.
176 0 my %extra;
177 0 ▶ if ($eg->{argv}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($eg->{'argv'}) { } 0 0 0
elsif ($eg->{'args'}) { } 0 0 0
178 0 $extra{argv} = $eg->{argv};
179 } elsif($eg->{args}) {
180 0 $extra{args} = $eg->{args};
181 } else {
182 0 log_debug("Example does not provide args/argv, skipped trying to get result from calling function");
183 0 last GET_RESULT;
184 }
185 0 my $url;
186 0 ▶ if ($self->{url} =~ /\A\w+\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'url'} =~ /\A\w+\z/) { } 0 0 0
187 0 $url = $self->parent->name . $self->{url};
188 } else {
189 0 $url = $self->{url};
190 }
191 0 $envres = $self->{_pa}->request(call => $url, \%extra);
192 0 ▶ unless ($orig_result_naked) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($orig_result_naked) 0 0 0
193 0 $tff = $envres->[3]{'table.fields'};
194 }
195 }
196 0 local $Data::Dump::SortKeys::SORT_KEYS = do {
197 0 ▶ if ($tff) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tff) { } 0 0 0
198 0 require Sort::ByExample;
199 0 my $sorter = Sort::ByExample::sbe($tff);
200 0 ▶ sub { $sorter->(keys %{$_[0]}) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
201 } else {
202 0 undef;
203 }
204 };
205 0 ▶ $resdump = Data::Dump::SortKeys::dump($orig_result_naked ? $envres->[2] : $envres);
Branch: 1 branch
BranchTrueFalseTotal
$orig_result_naked ? : 0 0 0
206 }
207  
208 0 ▶ my $status = $eg->{status} // 200;
Condition0%0/2
$eg->{"status"} // 200
l!l
00
MC/DC0%0/1
$eg->{"status"} // 200
$eg->{"status"}
Truth table0%0/2
A
A= $eg->{"status"}
Aresult
11
00
209 0 my $comment;
210 0 $example_code =~ s/^/ /mg;
211 0 my @result_lines;
212 # all fits on a single not-too-long line
213 0 ▶ if ($argsdump !~ /\n/ &&
Branch: 1 branch
BranchTrueFalseTotal
if (not $argsdump =~ /\n/ || defined $resdump && $resdump =~ /\n/ and length($argsdump) + length($resdump // '') < 80) { } 0 0 0
Condition0%0/11
not $argsdump =~ /\n/ || defined $resdump && $resdump =~ /\n/ and length($argsdump) + length($resdump // "") < 80
!ll&&!rl&&r
000
$argsdump =~ /\n/ || defined $resdump && $resdump =~ /\n/
l!l&&r!l&&!r
000
defined $resdump and $resdump =~ /\n/
!ll&&!rl&&r
000
$resdump // ""
l!l
00
MC/DC0%0/4
not $argsdump =~ /\n/ || defined $resdump && $resdump =~ /\n/ and length($argsdump) + length($resdump // "") < 80
$argsdump =~ /\n/ defined $resdump $resdump =~ /\n/ length($argsdump) + length($resdump // "") < 80
MC/DC0%0/1
$resdump // ""
$resdump
Truth table0%0/6
not(A || B and C) and D
A= $argsdump =~ /\n/B= defined $resdumpC= $resdump =~ /\n/D= length($argsdump) + length($resdump // "") < 80
ABCDresult
1XXX0
011X0
00X00
01000
00X11
01011
Truth table0%0/2
A
A= $resdump
Aresult
11
00
214 (!defined($resdump) || $resdump !~ /\n/) &&
215 length($argsdump) + length($resdump // "") < 80) {
216 0 ▶ if ($status == 200) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 200) { } 0 0 0
217 0 ▶ $comment = "-> $resdump" if defined $resdump;
Branch: 1 branch
BranchTrueFalseTotal
if defined $resdump 0 0 0
218 } else {
219 0 $comment = "ERROR $status";
220 }
221 } else {
222 0 ▶ if (defined $resdump) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $resdump) 0 0 0
223 0 my @resdump = split /^/, $resdump;
224 0 ▶ if (my $max_lines = $eg->{'x.doc.max_result_lines'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $max_lines = $eg->{"x.doc.max_result_lines"}) 0 0 0
225 0 $max_lines += 7; # to accomodate extra lines associated with envelopes and array enclosures
226 0 ▶ if (@resdump > $max_lines) {
Branch: 1 branch
BranchTrueFalseTotal
if (@resdump > $max_lines) 0 0 0
227 0 my $n = int($max_lines/2);
228 0 my $num_remove = @resdump - $max_lines + 1;
229 0 ▶ splice @resdump, $n, $num_remove, "# ...snipped ".($num_remove > 1 ? "$num_remove lines" : "1 line")." for brevity...\n";
Branch: 1 branch
BranchTrueFalseTotal
$num_remove > 1 ? : 0 0 0
230 0 $resdump = join("", @resdump);
231 }
232 }
233 0 push @result_lines, "Result:", "", (map {" $_"} @resdump), "";
234 }
235 }
236 0 my @summary_lines;
237 {
238 0 my $summary = $self->_podquote($eg->{summary} //
239 0 ▶ "Example #$i".(defined($eg->{name}) ? " ($eg->{name})" :""));
Branch: 1 branch
BranchTrueFalseTotal
defined $eg->{'name'} ? : 0 0 0
Condition0%0/2
$eg->{"summary"} // "Example #$i" . (defined $eg->{"name"} ? qq[ ($eg->{"name"})] : "")
l!l
00
MC/DC0%0/1
$eg->{"summary"} // "Example #$i" . (defined $eg->{"name"} ? qq[ ($eg->{"name"})] : "")
$eg->{"summary"}
Truth table0%0/2
A
A= $eg->{"summary"}
Aresult
11
00
240 0 push @summary_lines, ("=item * $summary" . ":", "");
241 }
242  
243 0 my @description_lines;
244 push @description_lines, $self->_md2pod($eg->{description}), ""
245 0 ▶ if $eg->{description};
Branch: 1 branch
BranchTrueFalseTotal
if $eg->{"description"} 0 0 0
246  
247 0 ▶ push @eg_lines, (
Branch: 1 branch
BranchTrueFalseTotal
defined $comment ? : 0 0 0
248 @summary_lines,
249 $example_code . (defined($comment) ? " # $comment" : ""), "",
250 @result_lines,
251 @description_lines,
252 );
253 } # for each example
254 0 ▶ if (@eg_lines) {
Branch: 1 branch
BranchTrueFalseTotal
if (@eg_lines) 0 0 0
255 0 $self->add_doc_lines(
256 __("Examples") . ":", "",
257 "=over", "",
258 @eg_lines,
259 "=back", "",
260 );
261 }
262  
263 $self->add_doc_lines($self->_md2pod($dres->{description}), "")
264 0 ▶ if $dres->{description};
Branch: 1 branch
BranchTrueFalseTotal
if $dres->{"description"} 0 0 0
265  
266 {
267 0 my $export = $self->{export};
268 0 ▶ if (!defined($export)) {
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $export) { } 0 0 0
elsif ($export == 0) { } 0 0 0
elsif ($export == 1) { } 0 0 0
elsif ($export == -1) { } 0 0 0
269 # unknown
270 } elsif ($export == 0) {
271 0 $self->add_doc_lines(__("This function is not exported by default, but exportable."), "");
272 } elsif ($export == 1) {
273 0 $self->add_doc_lines(__("This function is exported by default."), "");
274 } elsif ($export == -1) {
275 0 $self->add_doc_lines(__("This function is not exported."), "");
276 }
277 }
278  
279 0 ▶ my $feat = $meta->{features} // {};
Condition0%0/2
$meta->{"features"} // {}
l!l
00
MC/DC0%0/1
$meta->{"features"} // {}
$meta->{"features"}
Truth table0%0/2
A
A= $meta->{"features"}
Aresult
11
00
280 0 my @ft;
281 my %spargs;
282 0 ▶ if ($feat->{reverse}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($feat->{"reverse"}) 0 0 0
283 0 push @ft, __("This function supports reverse operation.");
284 $spargs{-reverse} = {
285 0 type => 'bool',
286 summary => __("Pass -reverse=>1 to reverse operation."),
287 };
288 }
289 # undo is deprecated now in Rinci 1.1.24+, but we still support it
290 0 ▶ if ($feat->{undo}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($feat->{"undo"}) 0 0 0
291 0 push @ft, __("This function supports undo operation.");
292 $spargs{-undo_action} = {
293 0 type => 'str',
294 summary => __(
295 "To undo, pass -undo_action=>'undo' to function. ".
296 "You will also need to pass -undo_data. ".
297 "For more details on undo protocol, ".
298 "see L<Rinci::Undo>."),
299 };
300 $spargs{-undo_data} = {
301 0 type => 'array',
302 summary => __(
303 "Required if you pass -undo_action=>'undo'. ".
304 "For more details on undo protocol, ".
305 "see L<Rinci::function::Undo>."),
306 };
307 }
308 0 ▶ if ($feat->{dry_run}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($feat->{"dry_run"}) 0 0 0
309 0 push @ft, __("This function supports dry-run operation.");
310 $spargs{-dry_run} = {
311 0 type => 'bool',
312 summary=>__("Pass -dry_run=>1 to enable simulation mode."),
313 };
314 }
315 push @ft, __("This function is pure (produce no side effects).")
316 0 ▶ if $feat->{pure};
Branch: 1 branch
BranchTrueFalseTotal
if $feat->{"pure"} 0 0 0
317 push @ft, __("This function is immutable (returns same result ".
318 "for same arguments).")
319 0 ▶ if $feat->{immutable};
Branch: 1 branch
BranchTrueFalseTotal
if $feat->{"immutable"} 0 0 0
320 push @ft, __("This function is idempotent (repeated invocations ".
321 "with same arguments has the same effect as ".
322 "single invocation).")
323 0 ▶ if $feat->{idempotent};
Branch: 1 branch
BranchTrueFalseTotal
if $feat->{"idempotent"} 0 0 0
324 0 ▶ if ($feat->{tx}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($feat->{"tx"}) 0 0 0
325 die "Sorry, I only support transaction protocol v=2"
326 0 ▶ unless $feat->{tx}{v} == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless $feat->{"tx"}{"v"} == 2 0 0 0
327 0 push @ft, __("This function supports transactions.");
328 $spargs{$_} = {
329 type => 'str',
330 summary => __(
331 "For more information on transaction, see ".
332 "L<Rinci::Transaction>."),
333 0 } for qw(-tx_action -tx_action_id -tx_v -tx_rollback -tx_recovery),
334 }
335 0 ▶ $self->add_doc_lines(join(" ", @ft), "", "") if @ft;
Branch: 1 branch
BranchTrueFalseTotal
if @ft 0 0 0
336  
337 0 ▶ if ($has_args) {
Branch: 1 branch
BranchTrueFalseTotal
if ($has_args) { } 0 0 0
338 0 $self->add_doc_lines(
339 __("Arguments") .
340 ' (' . __("'*' denotes required arguments") . '):',
341 "",
342 "=over 4",
343 "",
344 );
345 0 for my $name (sort keys %{$dres->{args}}) {
346 0 my $ra = $dres->{args}{$name};
347 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
348 0 ▶ next if grep { $_ eq 'hidden-mod' } @{ $ra->{arg}{tags} // [] };
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ eq "hidden-mod";} @{$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
349 $self->add_doc_lines(join(
350 "",
351 "=item * B<".(($orig_args_as =~ /array/ && defined($ra->{arg}{pos}) ? '$' : '').$name).">",
352 ($ra->{arg}{req} ? '*' : ''), ' => ',
353 "I<", $ra->{human_arg}, ">",
354 0 ▶ (defined($ra->{human_arg_default}) ?
Branch: 3 branches
BranchTrueFalseTotal
$orig_args_as =~ /array/ && defined $ra->{'arg'}{'pos'} ? : 0 0 0
$ra->{'arg'}{'req'} ? : 0 0 0
defined $ra->{'human_arg_default'} ? : 0 0 0
Condition0%0/3
$orig_args_as =~ /array/ and defined $ra->{"arg"}{"pos"}
!ll&&!rl&&r
000
MC/DC0%0/2
$orig_args_as =~ /array/ and defined $ra->{"arg"}{"pos"}
$orig_args_as =~ /array/ defined $ra->{"arg"}{"pos"}
Truth table0%0/3
A and B
A= $orig_args_as =~ /array/B= defined $ra->{"arg"}{"pos"}
ABresult
0X0
100
111
355 " (" . __("default") .
356 ": $ra->{human_arg_default})" : "")
357 ), "");
358 {
359 0 my ($summary, $description);
360 0 $summary = $ra->{summary};
361 0 $description = $ra->{description};
362 0 ▶ $description = "(No description)" if !defined $summary && !defined $description;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $summary or defined $description 0 0 0
Condition0%0/3
defined $summary or defined $description
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $summary or defined $description
defined $summary defined $description
Truth table0%0/3
A or B
A= defined $summaryB= defined $description
ABresult
1X1
011
000
363  
364 0 ▶ if (defined $summary) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $summary) 0 0 0
365 0 ▶ $self->add_doc_lines(
Branch: 1 branch
BranchTrueFalseTotal
$summary =~ /\.$/ ? : 0 0 0
366 $self->_podquote($summary) .
367 ($summary =~ /\.$/ ? "" : "."),
368 "");
369 }
370 $self->add_doc_lines(
371 0 ▶ $self->_md2pod($description),
Branch: 1 branch
BranchTrueFalseTotal
if defined $description 0 0 0
372 "") if defined $description;
373 }
374 }
375 0 $self->add_doc_lines("", "=back", "");
376 } else {
377 0 $self->add_doc_lines(__("No arguments") . ".", "");
378 }
379  
380 0 ▶ if (keys %spargs) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %spargs) 0 0 0
381 0 $self->add_doc_lines(
382 __("Special arguments") . ":",
383 "",
384 "=over 4",
385 "",
386 );
387 0 for my $name (sort keys %spargs) {
388 0 my $spa = $spargs{$name};
389 $self->add_doc_lines(join(
390 "",
391 "=item * B<", $name, ">",
392 ' => ',
393 "I<", $spa->{type}, ">",
394 0 ▶ (defined($spa->{default}) ?
Branch: 1 branch
BranchTrueFalseTotal
defined $spa->{'default'} ? : 0 0 0
395 " (" . __("default") .
396 ": $spa->{default})" : "")
397 ), "");
398 $self->add_doc_lines(
399 $self->_podquote($spa->{summary}) . ($spa->{summary} =~ /\.$/ ? "" : "."),
400 0 ▶ "") if defined $spa->{summary};
Branch: 2 branches
BranchTrueFalseTotal
if defined $spa->{"summary"} 0 0 0
$spa->{'summary'} =~ /\.$/ ? : 0 0 0
401 }
402 0 $self->add_doc_lines("=back", "");
403 }
404  
405 0 ▶ $self->add_doc_lines($self->_md2pod(__(
Branch: 1 branch
BranchTrueFalseTotal
unless $orig_result_naked 0 0 0
406 'Returns an enveloped result (an array).
407  
408 First element ($status_code) is an integer containing HTTP-like status code
409 (200 means OK, 4xx caller error, 5xx function error). Second element
410 ($reason) is a string containing error message, or something like "OK" if status is
411 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
412 element (%result_meta) is called result metadata and is optional, a hash
413 that contains extra information, much like how HTTP response headers provide additional metadata.')), "")
414 unless $orig_result_naked;
415  
416 $self->add_doc_lines(__("Return value") . ': ' .
417 0 ▶ ($dres->{res_summary} // "") . " ($dres->{human_res})",
Condition0%0/2
$dres->{"res_summary"} // ""
l!l
00
MC/DC0%0/1
$dres->{"res_summary"} // ""
$dres->{"res_summary"}
Truth table0%0/2
A
A= $dres->{"res_summary"}
Aresult
11
00
418 "");
419 $self->add_doc_lines("", $self->_md2pod($dres->{res_description}), "")
420 0 ▶ if $dres->{res_description};
Branch: 1 branch
BranchTrueFalseTotal
if $dres->{"res_description"} 0 0 0
421  
422 # we only show See Also on a per-package basis
423 #
424 #if ($meta->{links} && @{ $meta->{links} }) {
425 # $self->add_doc_lines(__("See also") . ":", "", "=over", "");
426 # for my $link (@{ $meta->{links} }) {
427 # my $url = $link->{url};
428 # if ($url =~ m!\Apm:(.+)!) {
429 # my $mod = $1;
430 # $self->add_doc_lines("* L<$mod>", "");
431 # } else {
432 # $self->add_doc_lines("* L<$url>", "");
433 # }
434 # $self->add_doc_lines($self->_podquote($link->{summary}).".", "") if defined $link->{summary};
435 # $self->add_doc_lines($self->_md2pod($link->{description}), "") if defined $link->{description};
436 # }
437 # $self->add_doc_lines("=back", "");
438 #}
439 }
440  
441 1 1;
442 # ABSTRACT: Generate POD documentation from Rinci function metadata
443  
444 __END__
↑ Summary To/Doc/Role/Section/AddTextLines.pm »