in src/GeneratorCLI.hack [140:201]
public async function mainAsync(): Awaitable<int> {
switch ($this->format) {
case OutputFormat::MARKDOWN:
$extension = '.md';
break;
case OutputFormat::HTML:
$extension = '.html';
break;
}
await $this->getStdout()->writeAllAsync("Parsing...\n");
$documentables = $this->parse();
$index = create_index(
$documentables,
shape(
'hidePrivateNamespaces' => $this->hidePrivateNamespaces
)
);
$paths = new SingleDirectoryPathProvider($extension);
$config = shape(
'format' => $this->format,
'syntaxHighlighting' => $this->syntaxHighlightingOn,
'hidePrivateMethods' => $this->hidePrivateMethods,
'hideInheritedMethods' => $this->hideInheritedMethods,
);
$fmc = $this->frontMatterConfig;
if ($fmc is nonnull) {
$config['frontMatter'] = $fmc;
}
$context = new DocumentationBuilderContext($index, $paths, $config);
$md_builder = new DocumentationBuilder($context);
if ($this->outputRoot === null) {
$prefix = '';
} else {
$prefix = $this->outputRoot;
if (!Str\ends_with($prefix, '/')) {
$prefix .= '/';
}
}
if (!\is_dir($prefix)) {
\mkdir($prefix);
}
await $this->getStdout()->writeAllAsync("Generating documentation...\n");
foreach ($documentables as $documentable) {
$content = $md_builder->getDocumentation($documentable);
$path = get_path_for_documentable($paths, $documentable);
\file_put_contents($prefix.$path, $content);
$this->verboseWrite($path."\n");
}
await $this->getStdout()->writeAllAsync("Creating index document...\n");
\file_put_contents(
$prefix.'index'.$extension,
(new IndexDocumentBuilder($context))->getIndexDocument(),
);
await $this->getStdout()->writeAllAsync("Done.\n");
return 0;
}