Skip to content

Commit 20662a3

Browse files
committed
bug #112 Fixed some minor issues related to edge cases (javiereguiluz)
This PR was merged into the main branch. Discussion ---------- Fixed some minor issues related to edge cases I faced this when generating the entire Symfony Docs for all its versions from 2.0 to 6.0. Commits ------- c0b230d Fixed some minor issues related to edge cases
2 parents 1514b88 + c0b230d commit 20662a3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Generator/JsonGenerator.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,13 @@ private function getMetaEntry(string $parserFilename, bool $throwOnMissing = fal
216216
private function walkTocTreeAndReturnHierarchy(string $filename, array &$walkedFiles): array
217217
{
218218
$hierarchy = [];
219-
foreach ($this->getMetaEntry($filename)->getTocs() as $toc) {
219+
220+
// happens in edge-cases such as empty or not found documents
221+
if (null === $meta = $this->getMetaEntry($filename)) {
222+
return $hierarchy;
223+
}
224+
225+
foreach ($meta->getTocs() as $toc) {
220226
foreach ($toc as $tocFilename) {
221227
// only walk a file one time, the first time you see it
222228
if (in_array($tocFilename, $walkedFiles, true)) {
@@ -275,7 +281,10 @@ private function determineParents(string $parserFilename, array $tocTreeHierarch
275281

276282
private function makeRelativeLink(string $currentFilename, string $filename): array
277283
{
278-
$meta = $this->getMetaEntry($filename);
284+
// happens in edge-cases such as empty or not found documents
285+
if (null === $meta = $this->getMetaEntry($filename)) {
286+
return ['title' => '', 'link' => ''];
287+
}
279288

280289
return [
281290
'title' => $meta->getTitle(),

0 commit comments

Comments
 (0)