Skip to content

Commit 1dc03bb

Browse files
committed
migrate APIIndexData from PHP codegen to json
1 parent 7654d9f commit 1dc03bb

File tree

4 files changed

+21
-23
lines changed

4 files changed

+21
-23
lines changed

src/APIIndex.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,27 @@
1010
*/
1111
namespace HHVM\UserDocumentation;
1212

13-
require(BuildPaths::APIDOCS_INDEX);
14-
1513
use namespace Facebook\TypeAssert;
1614
use namespace HH\Lib\{C, Math, Str, Vec};
1715

1816
final class APIIndex {
17+
<<__Memoize>>
1918
public static function getIndex(
2019
): APIIndexShape {
21-
return APIIndexData::getIndex();
20+
$key = __CLASS__.'!'.BuildPaths::BUILD_ID;
21+
22+
$success = false;
23+
$data = apc_fetch($key, $success);
24+
if ($success) {
25+
return $data;
26+
}
27+
28+
$data = JSON\decode_as_shape(
29+
APIIndexShape::class,
30+
\file_get_contents(BuildPaths::APIDOCS_INDEX_JSON),
31+
);
32+
apc_store($key, $data);
33+
return $data;
2234
}
2335

2436
public static function getIndexForType(

src/build/APIIndexBuildStep.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
namespace HHVM\UserDocumentation;
1313

1414
final class APIIndexBuildStep extends BuildStep {
15-
use CodegenBuildStep;
16-
1715
public function buildAll(): void {
1816
Log::i("\nAPIIndexBuild");
1917

@@ -29,13 +27,12 @@ private function createIndex(
2927
Log::i("\nCreate Index");
3028

3129
$index = $this->generateIndexData($list);
32-
$code = $this->writeCode(
33-
'APIIndexData.hhi',
34-
$index,
35-
);
3630
file_put_contents(
37-
BuildPaths::APIDOCS_INDEX,
38-
$code,
31+
BuildPaths::APIDOCS_INDEX_JSON,
32+
JSON\encode_shape(
33+
APIIndexShape::class,
34+
$index,
35+
),
3936
);
4037
}
4138

src/build/BuildPaths.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
const string APIDOCS_MARKDOWN = self::BUILD_DIR.'/api-markdown';
2828
const string APIDOCS_HTML = self::BUILD_DIR.'/api-html';
29-
const string APIDOCS_INDEX = self::BUILD_DIR.'/api-index.php';
29+
const string APIDOCS_INDEX_JSON = self::BUILD_DIR.'/api-index.json';
3030
const string APIDOCS_LEGACY_REDIRECTS
3131
= self::BUILD_DIR.'/api-legacy-redirects.php';
3232

src/codegen-hhi/APIIndexData.hhi

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)