Skip to content

Commit a3aadf0

Browse files
committed
Include value types' purpose in package listing if -d flag is passed
1 parent a8abfe4 commit a3aadf0

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/main/php/xp/reflection/PackageInformation.class.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
use lang\{ClassLoader, Reflection};
44

55
class PackageInformation {
6-
private $package;
6+
private $package, $flags;
77

88
/** @param string $package */
9-
public function __construct($package) {
9+
public function __construct($package, $flags) {
1010
$this->package= rtrim($package, '.');
11+
$this->flags= $flags;
1112
}
1213

1314
/** @return iterable */
@@ -50,6 +51,19 @@ public function display($out) {
5051
usort($types, function($a, $b) { return $a->name() <=> $b->name(); });
5152
$i= 0;
5253
foreach ($types as $type) {
54+
if ($this->flags & Information::DOC && ($comment= $type->comment())) {
55+
$out->line();
56+
$p= strpos($comment, "\n\n");
57+
$s= min(strpos($comment, '. ') ?: $p, strpos($comment, ".\n") ?: $p);
58+
59+
if (false === $s || $s > $p) {
60+
$purpose= false === $p ? trim($comment) : substr($comment, 0, $p);
61+
} else {
62+
$purpose= substr($comment, 0, $s);
63+
}
64+
$out->documentation(str_replace(["\n", ' '], [' ', ' '], trim($purpose)), ' ');
65+
}
66+
5367
$out->line(' ', $type->modifiers()->names(true).' '.$type->kind()->name().' '.$type->name());
5468
$i++;
5569
}

0 commit comments

Comments
 (0)