in src/consumers/doccomment_from_ast.hack [15:36]
function doccomment_from_ast(
ScannedDefinition::TContext $_context,
?HHAST\Node $node,
): ?string {
if ($node === null) {
return null;
}
$leading = $node->getFirstToken()?->getLeading();
if ($leading === null && $node is HHAST\NodeList<_>) {
$maybe_doc_comments =
$node->getChildrenOfType(HHAST\DelimitedComment::class);
} else if ($leading is HHAST\NodeList<_>) {
$maybe_doc_comments =
$leading->getChildrenOfType(HHAST\DelimitedComment::class);
} else {
return null;
}
$doc_comments = $maybe_doc_comments
|> Vec\map($$, $c ==> $c->getText())
|> Vec\filter($$, $c ==> Str\starts_with($c, '/**'));
return C\last($doc_comments);
}