in src/markdown-extensions/IncludeGeneratedMarkdownBlock.php [51:86]
private static function getOutputBlock(string $file): ?UnparsedBlocks\Block {
if (\file_exists($file.'.no.auto.output')) {
return null;
}
$out = $file.'.example.hhvm.out';
$expect = $file.'.hhvm.expect';
$out_exists = \file_exists($out);
$expect_exists = \file_exists($expect);
invariant(
!($out_exists && $expect_exists),
'both %s and %s exist.',
$out,
$expect,
);
invariant(
$out_exists || $expect_exists || Str\contains($file, '.inc.php'),
'none of %s, %s, or %s exist.',
$out,
$expect,
$file.'.no.auto.output',
);
if (!($out_exists || $expect_exists)) {
return null;
}
$out = $out_exists ? $out : $expect;
return UnparsedBlocks\BlockSequence::flatten(
new UnparsedBlocks\HTMLBlock('<em>Output</em>'),
new UnparsedBlocks\FencedCodeBlock(\file_get_contents($out), null),
);
}