@@ -42,10 +42,8 @@ public function buildAll(): void {
4242 self :: findSources(BuildPaths :: HHVM_TREE . ' /hphp/system/php/' , $exts ),
4343 self :: findSources(BuildPaths :: HHVM_TREE . ' /hphp/runtime/ext/' , $exts ),
4444 );
45- $hhi_sources = self :: findSources(
46- BuildPaths :: HHVM_TREE . ' /hphp/hack/hhi/' ,
47- $exts ,
48- );
45+ $hhi_sources =
46+ self :: findSources(BuildPaths :: HHVM_TREE . ' /hphp/hack/hhi/' , $exts );
4947 Log :: i(" \n Parsing builtins" );
5048 list ($runtime_defs , $hhi_defs ) = \HH \Asio \ join (async {
5149 return tuple (
@@ -64,9 +62,8 @@ public function buildAll(): void {
6462 if ($parent !== null ) {
6563 return ScannedDefinitionFilters :: isHHSpecific($parent );
6664 }
67- return ScannedDefinitionFilters :: isHHSpecific(
68- $documentable [' definition' ],
69- );
65+ return
66+ ScannedDefinitionFilters :: isHHSpecific($documentable [' definition' ]);
7067 },
7168 );
7269
@@ -76,25 +73,22 @@ public function buildAll(): void {
7673 // whitelisted files again here.
7774 $hsl_sources =
7875 self :: findSources(BuildPaths :: HHVM_TREE . ' /hphp/hsl/src/' , $exts );
79- $hsl_experimental_sources = self :: findSources(
80- BuildPaths :: HSL_EXPERIMENTAL_TREE . ' /src/' ,
81- $exts ,
82- );
76+ $hsl_experimental_sources =
77+ self :: findSources(BuildPaths :: HSL_EXPERIMENTAL_TREE . ' /src/' , $exts );
8378 Log :: i(" \n Parsing HSL sources" );
8479 $hsl_defs = \HH \Asio \ join (self :: parseAsync($hsl_sources ));
85- $hsl_experimental_defs = \HH \Asio \ join (
86- self :: parseAsync($hsl_experimental_sources ),
87- );
80+ $hsl_experimental_defs =
81+ \HH \Asio \ join (self :: parseAsync($hsl_experimental_sources ));
8882
89- Log :: i(" \n Generating index for builtins" );
83+ Log :: i(" \n Generating search and navigation index for builtins" );
9084 $builtin_index = self :: createProductIndex(APIProduct :: HACK , $builtin_defs );
91- Log :: i(" \n Generating index for the HSL" );
85+ Log :: i(" \n Generating search and navigation index for the HSL" );
9286 $hsl_index = self :: createProductIndex(APIProduct :: HSL , $hsl_defs );
9387 $hsl_experimental_index = self :: createProductIndex(
9488 APIProduct :: HSL_EXPERIMENTAL ,
9589 $hsl_experimental_defs ,
9690 );
97- Log :: i(" \n Writing index file" );
91+ Log :: i(" \n Writing search and navigation index file" );
9892 \file_put_contents (
9993 BuildPaths :: APIDOCS_INDEX_JSON ,
10094 JSON \encode_shape (
@@ -107,14 +101,46 @@ public function buildAll(): void {
107101 ),
108102 );
109103
104+ // HHApiDoc index; needed so that e.g. `File\WriteHandle`'s documentation
105+ // generation knows about `IO\WriteHandle`'s methods
106+ Log :: i(" \n Creating cross-reference index" );
107+ $hh_apidoc_index = shape (
108+ ' types' => dict [],
109+ ' newtypes' => dict [],
110+ ' functions' => dict [],
111+ ' classes' => dict [],
112+ ' interfaces' => dict [],
113+ ' traits' => dict [],
114+ );
115+ $all_documentables =
116+ Vec \flatten (vec [$builtin_defs , $hsl_defs , $hsl_experimental_defs ]);
117+ foreach ($all_documentables as $documentable ) {
118+ $def = $documentable [' definition' ];
119+ // types and newtypes are not currently supported by docs.hhvm.com
120+ if ($def is ScannedFunction ) {
121+ $hh_apidoc_index [' functions' ][$def -> getName()] = $documentable ;
122+ continue ;
123+ }
124+ if ($def is ScannedClass ) {
125+ $hh_apidoc_index [' classes' ][$def -> getName()] = $documentable ;
126+ continue ;
127+ }
128+ if ($def is ScannedInterface ) {
129+ $hh_apidoc_index [' interfaces' ][$def -> getName()] = $documentable ;
130+ continue ;
131+ }
132+ if ($def is ScannedTrait ) {
133+ $hh_apidoc_index [' traits' ][$def -> getName()] = $documentable ;
134+ continue ;
135+ }
136+ }
137+
110138 Log :: i(" \n Generating Markdown for builtins" );
111- $builtin_md = self :: buildMarkdown(APIProduct :: HACK , $builtin_defs );
139+ $builtin_md = self :: buildMarkdown(APIProduct :: HACK , $builtin_defs , $hh_apidoc_index );
112140 Log :: i(" \n Generating Markdown for the HSL" );
113- $hsl_md = self :: buildMarkdown(APIProduct :: HSL , $hsl_defs );
114- $hsl_experimental_md = self :: buildMarkdown(
115- APIProduct :: HSL_EXPERIMENTAL ,
116- $hsl_experimental_defs ,
117- );
141+ $hsl_md = self :: buildMarkdown(APIProduct :: HSL , $hsl_defs , $hh_apidoc_index );
142+ $hsl_experimental_md =
143+ self :: buildMarkdown(APIProduct :: HSL_EXPERIMENTAL , $hsl_experimental_defs , $hh_apidoc_index );
118144
119145 \file_put_contents (
120146 BuildPaths :: APIDOCS_MARKDOWN . ' /index.json' ,
@@ -175,10 +201,8 @@ private static function createProductIndex(
175201 APIProduct $product ,
176202 vec <Documentable > $documentables ,
177203 ): ProductAPIIndexShape {
178- $documentables = Vec \sort_by (
179- $documentables ,
180- $d ==> $d [' definition' ]-> getName(),
181- );
204+ $documentables =
205+ Vec \sort_by ($documentables , $d ==> $d [' definition' ]-> getName());
182206 return shape (
183207 ' class' => self :: createClassishIndex(
184208 $product ,
@@ -274,10 +298,8 @@ private static function createFunctionIndex(
274298 APIProduct $product ,
275299 vec <Documentable > $documentables ,
276300 ): dict <string , APIFunctionIndexEntry > {
277- $functions = Dict \filter (
278- $documentables ,
279- $d ==> $d [' definition' ] is ScannedFunction ,
280- );
301+ $functions =
302+ Dict \filter ($documentables , $d ==> $d [' definition' ] is ScannedFunction );
281303 $html_paths = HTMLPaths :: get($product );
282304 return Dict \pull (
283305 $functions ,
@@ -367,6 +389,7 @@ private static function correctHHIOnlyDefs(Documentable $def): Documentable {
367389 private static function buildMarkdown (
368390 APIProduct $product ,
369391 vec <Documentable > $documentables ,
392+ \Facebook \HHAPIDoc \ Index $index ,
370393 ): vec <string > {
371394 $root = BuildPaths :: APIDOCS_MARKDOWN . ' /' . $product ;
372395
@@ -376,16 +399,7 @@ private static function buildMarkdown(
376399 $md_paths = MarkdownPaths :: get($product );
377400 $ctx = (
378401 new HHAPIDoc \DocumentationBuilderContext (
379- // Empty index; this is used for auto-linking, but we do that when
380- // processing the markdown, instead of when generating it.
381- shape (
382- ' types' => dict [],
383- ' newtypes' => dict [],
384- ' functions' => dict [],
385- ' classes' => dict [],
386- ' interfaces' => dict [],
387- ' traits' => dict [],
388- ),
402+ $index ,
389403 new HHAPIDocExt \PathProvider (),
390404 shape (
391405 ' format' => HHAPIDoc \OutputFormat :: MARKDOWN ,
0 commit comments