|
3 | 3 | use lang\{ClassLoader, Reflection}; |
4 | 4 |
|
5 | 5 | class PackageInformation { |
6 | | - private $package; |
| 6 | + private $package, $flags; |
7 | 7 |
|
8 | 8 | /** @param string $package */ |
9 | | - public function __construct($package) { |
| 9 | + public function __construct($package, $flags) { |
10 | 10 | $this->package= rtrim($package, '.'); |
| 11 | + $this->flags= $flags; |
11 | 12 | } |
12 | 13 |
|
13 | 14 | /** @return iterable */ |
@@ -50,6 +51,19 @@ public function display($out) { |
50 | 51 | usort($types, function($a, $b) { return $a->name() <=> $b->name(); }); |
51 | 52 | $i= 0; |
52 | 53 | 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 | + |
53 | 67 | $out->line(' ', $type->modifiers()->names(true).' '.$type->kind()->name().' '.$type->name()); |
54 | 68 | $i++; |
55 | 69 | } |
|
0 commit comments