private static function buildMarkdown()

in src/build/HHAPIDocBuildStep.php [389:441]


  private static function buildMarkdown(
    APIProduct $product,
    vec<Documentable> $documentables,
    \Facebook\HHAPIDoc\Index $index,
  ): vec<string> {
    $root = BuildPaths::APIDOCS_MARKDOWN.'/'.$product;

    if (!\is_dir($root)) {
      \mkdir($root, /* mode = */ 0755, /* recursive = */ true);
    }
    $md_paths = MarkdownPaths::get($product);
    $ctx = (
      new HHAPIDoc\DocumentationBuilderContext(
        $index,
        new HHAPIDocExt\PathProvider(),
        shape(
          'format' => HHAPIDoc\OutputFormat::MARKDOWN,
          'syntaxHighlighting' => true,
          'hidePrivateMethods' => true,
          'hideInheritedMethods' => false,
        ),
      )
    );
    $builder = new HHAPIDocExt\MarkdownBuilder($ctx);

    return Vec\map($documentables, $documentable ==> {
      Log::v('.');
      $md = $builder->getDocumentation($documentable);
      $what = $documentable['definition'];
      if ($what is ScannedMethod) {
        $parent = TypeAssert\not_null($documentable['parent']);
        $path = $md_paths->getPathForClassishMethod(
          self::getClassishAPIDefinitionType($parent),
          $parent->getName(),
          $what->getName(),
        );
      } else if ($what is ScannedFunction) {
        $path = $md_paths->getPathForFunction($what->getName());
      } else if ($what is ScannedClassish) {
        $path = $md_paths->getPathForClassish(
          self::getClassishAPIDefinitionType($what),
          $what->getName(),
        );
      } else {
        invariant_violation(
          "Can't handle definition of type %s",
          \get_class($what),
        );
      }
      \file_put_contents($path, $md."\n<!-- HHAPIDOC -->\n");
      return $path;
    });
  }