Skip to content

Commit 41e28a3

Browse files
committed
automatically generate lvalue usage portion of doc
1 parent a42733e commit 41e28a3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/PDL/PP.pm

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,12 +1474,12 @@ EOF
14741474

14751475
PDL::PP::Rule->new([qw(UsageDoc ParamDoc)],
14761476
[qw(Name Doc? SignatureObj OtherParsDefaults? ArgOrder?
1477-
OverloadDocValues InplaceDocValues ParamDesc?
1477+
OverloadDocValues InplaceDocValues ParamDesc? Lvalue?
14781478
)],
14791479
'generate "usage" section of doc',
14801480
sub {
14811481
my ($name, $doc, $sig, $otherdefaults, $argorder,
1482-
$overloadvals, $inplacevals, $paramdesc,
1482+
$overloadvals, $inplacevals, $paramdesc, $lvalue,
14831483
) = @_;
14841484
$otherdefaults ||= {};
14851485
$paramdesc ||= {};
@@ -1538,6 +1538,15 @@ EOF
15381538
).";",
15391539
[@{$_->[2]}]], grep @{$_->[0]}, @argsets;
15401540
push @invocs, @$inplacevals;
1541+
if ($lvalue) {
1542+
my ($first_meth) = grep @{$_->[1]} == 1, @argsets;
1543+
push @invocs, [
1544+
"\$$first_meth->[0][0]->$name".(
1545+
@{$first_meth->[0]} <= 1 ? '' :
1546+
"(".join(", ", map "\$$_", @{$first_meth->[0]}[1..$#{$first_meth->[0]}]).")"
1547+
)." .= \$data;",
1548+
['usable as lvalue']] if $first_meth;
1549+
}
15411550
require List::Util;
15421551
my $maxlen = List::Util::max(map length($_->[0]), @invocs);
15431552
(join('', "\n=for usage\n\n",

0 commit comments

Comments
 (0)