private static function createClassishIndex()

in src/build/HHAPIDocBuildStep.php [226:295]


  private static function createClassishIndex(
    APIProduct $product,
    APIDefinitionType $type,
    vec<Documentable> $documentables,
  ): dict<string, APIClassIndexEntry> {
    $classes = Vec\filter(
      $documentables,
      $d ==> {
        if ($type === APIDefinitionType::CLASS_DEF) {
          return $d['definition'] is ScannedClass;
        }
        if ($type === APIDefinitionType::INTERFACE_DEF) {
          return $d['definition'] is ScannedInterface;
        }
        if ($type === APIDefinitionType::TRAIT_DEF) {
          return $d['definition'] is ScannedTrait;
        }
        invariant_violation('unhandled type: %s', $type);
      },
    );

    $html_paths = HTMLPaths::get($product);

    return Dict\pull(
      $classes,
      $class ==> {
        $class_name = $class['definition']->getName();
        $methods = Dict\filter(
          $documentables,
          $d ==> $d['parent'] === $class['definition'],
        );

        return shape(
          'type' => $type,
          'name' => $class_name,
          'htmlPath' => $html_paths->getPathForClassish($type, $class_name),
          'urlPath' => \APIClassPageControllerURIBuilder::getPath(shape(
            'Product' => $product,
            'Name' => Str\replace($class_name, "\\", '.'),
            'Type' => $type,
          )),
          'methods' => Dict\pull(
            $methods,
            $method ==> {
              $method_name = $method['definition']->getName();
              return shape(
                'name' => $method_name,
                'className' => $class_name,
                'classType' => $type,
                'htmlPath' => $html_paths->getPathForClassishMethod(
                  $type,
                  $class_name,
                  $method_name,
                ),
                'urlPath' => \APIMethodPageControllerURIBuilder::getPath(shape(
                  'Product' => $product,
                  'Class' => Str\replace($class_name, "\\", '.'),
                  'Method' => $method_name,
                  'Type' => $type,
                )),
              );
            },
            $method ==>
              Str\replace($method['definition']->getName(), "\\", '.'),
          ),
        );
      },
      $class ==> Str\replace($class['definition']->getName(), "\\", '.'),
    );
  }