Skip to content
Browse files

spore2dot: split long list of arguments

  • Loading branch information...
1 parent d5c361b commit 2528c7f26c45dd50df2eca7a63e51eb3aea8231f @fperrad fperrad committed
Showing with 19 additions and 0 deletions.
  1. +19 −0 utils/spore2dot.pl
View
19 utils/spore2dot.pl
@@ -34,6 +34,7 @@
}
+my $MAX_LEN = 90;
my %meth;
foreach my $spec (@specs) {
my $name = $spec->{meta}->{module} || $spec->{name};
@@ -46,29 +47,47 @@
$meth{$name} = 1;
my $desc = $spec->{methods}->{$name};
print $name, "(";
+ my $len = length $name;
my $first = 1;
if ($desc->{required_payload}) {
print "payload";
+ $len += 7;
$first = 0;
}
for (@{$desc->{required_params}}) {
print ", " unless $first;
+ $len += 2;
+ if ($len > $MAX_LEN) {
+ print "\\l    ";
+ $len = 4;
+ }
print $_;
+ $len += length $_;
$first = 0;
}
if ($desc->{optional_params}) {
print " " unless $first;
}
for (@{$desc->{optional_params}}) {
+ if ($len > $MAX_LEN) {
+ print "\\l    ";
+ $len = 4;
+ }
print "\\[";
print ", " unless $first;
print $_, "\\]";
+ $len += 4 + length $_;
$first = 0;
}
if ($desc->{optional_payload}) {
+ if ($len > $MAX_LEN) {
+ print "\\l    ";
+ $len = 4;
+ }
print "\\[";
print ", " unless $first;
print "payload\\]";
+ $len += 11;
$first = 0;
}
if ($desc->{unattended_params} || $spec->{unattended_params}) {

0 comments on commit 2528c7f

Please sign in to comment.
Something went wrong with that request. Please try again.