@@ -42,10 +42,8 @@ public function buildAll(): void {
42
42
self :: findSources(BuildPaths :: HHVM_TREE . ' /hphp/system/php/' , $exts ),
43
43
self :: findSources(BuildPaths :: HHVM_TREE . ' /hphp/runtime/ext/' , $exts ),
44
44
);
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 );
49
47
Log :: i(" \n Parsing builtins" );
50
48
list ($runtime_defs , $hhi_defs ) = \HH \Asio \ join (async {
51
49
return tuple (
@@ -64,9 +62,8 @@ public function buildAll(): void {
64
62
if ($parent !== null ) {
65
63
return ScannedDefinitionFilters :: isHHSpecific($parent );
66
64
}
67
- return ScannedDefinitionFilters :: isHHSpecific(
68
- $documentable [' definition' ],
69
- );
65
+ return
66
+ ScannedDefinitionFilters :: isHHSpecific($documentable [' definition' ]);
70
67
},
71
68
);
72
69
@@ -76,25 +73,22 @@ public function buildAll(): void {
76
73
// whitelisted files again here.
77
74
$hsl_sources =
78
75
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 );
83
78
Log :: i(" \n Parsing HSL sources" );
84
79
$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 ));
88
82
89
- Log :: i(" \n Generating index for builtins" );
83
+ Log :: i(" \n Generating search and navigation index for builtins" );
90
84
$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" );
92
86
$hsl_index = self :: createProductIndex(APIProduct :: HSL , $hsl_defs );
93
87
$hsl_experimental_index = self :: createProductIndex(
94
88
APIProduct :: HSL_EXPERIMENTAL ,
95
89
$hsl_experimental_defs ,
96
90
);
97
- Log :: i(" \n Writing index file" );
91
+ Log :: i(" \n Writing search and navigation index file" );
98
92
\file_put_contents (
99
93
BuildPaths :: APIDOCS_INDEX_JSON ,
100
94
JSON \encode_shape (
@@ -107,14 +101,46 @@ public function buildAll(): void {
107
101
),
108
102
);
109
103
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
+
110
138
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 );
112
140
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 );
118
144
119
145
\file_put_contents (
120
146
BuildPaths :: APIDOCS_MARKDOWN . ' /index.json' ,
@@ -175,10 +201,8 @@ private static function createProductIndex(
175
201
APIProduct $product ,
176
202
vec <Documentable > $documentables ,
177
203
): 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());
182
206
return shape (
183
207
' class' => self :: createClassishIndex(
184
208
$product ,
@@ -274,10 +298,8 @@ private static function createFunctionIndex(
274
298
APIProduct $product ,
275
299
vec <Documentable > $documentables ,
276
300
): 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 );
281
303
$html_paths = HTMLPaths :: get($product );
282
304
return Dict \pull (
283
305
$functions ,
@@ -367,6 +389,7 @@ private static function correctHHIOnlyDefs(Documentable $def): Documentable {
367
389
private static function buildMarkdown (
368
390
APIProduct $product ,
369
391
vec <Documentable > $documentables ,
392
+ \Facebook \HHAPIDoc \ Index $index ,
370
393
): vec <string > {
371
394
$root = BuildPaths :: APIDOCS_MARKDOWN . ' /' . $product ;
372
395
@@ -376,16 +399,7 @@ private static function buildMarkdown(
376
399
$md_paths = MarkdownPaths :: get($product );
377
400
$ctx = (
378
401
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 ,
389
403
new HHAPIDocExt \PathProvider (),
390
404
shape (
391
405
' format' => HHAPIDoc \OutputFormat :: MARKDOWN ,
0 commit comments