Skip to content

Commit 2ce5a39

Browse files
committed
No longer aborting on errors, but reporting them
1 parent 4845918 commit 2ce5a39

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

src/CI/MissingFilesChecker.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public function getMissingFiles(): array
2828
->files()
2929
->name('*.rst');
3030

31+
$orphanedFiles = [];
32+
3133
foreach ($this->finder as $file) {
3234
$htmlFile = str_replace(
3335
[$this->buildContext->getSourceDir(), '.rst'],
@@ -37,8 +39,10 @@ public function getMissingFiles(): array
3739

3840
$firstLine = fgets(fopen($file->getRealPath(), 'r'));
3941
if (!$this->filesystem->exists($htmlFile) && ':orphan:' !== trim($firstLine)) {
40-
$io->warning(sprintf('Missing file "%s"', $htmlFile));
42+
$orphanedFiles[] = $htmlFile;
4143
}
4244
}
45+
46+
return $orphanedFiles;
4347
}
4448
}

src/Command/BuildDocsCommand.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ protected function configure()
5757
null,
5858
InputOption::VALUE_NONE,
5959
'If provided, caching meta will be disabled'
60-
);
60+
)
61+
->addOption(
62+
'save-errors',
63+
null,
64+
InputOption::VALUE_REQUIRED,
65+
'Path where any errors should be saved'
66+
)
67+
;
6168
}
6269

6370
protected function initialize(InputInterface $input, OutputInterface $output)
@@ -76,11 +83,24 @@ protected function initialize(InputInterface $input, OutputInterface $output)
7683
protected function execute(InputInterface $input, OutputInterface $output)
7784
{
7885
$this->startBuild();
86+
$buildErrors = $this->builder->getErrorManager()->getErrors();
7987

80-
$this->io->newLine(2);
8188
$this->io->success('HTML rendering complete!');
8289

83-
$this->missingFilesChecker->checkMissingFiles($this->io);
90+
$missingFiles = $this->missingFilesChecker->getMissingFiles();
91+
foreach ($missingFiles as $missingFile) {
92+
$message = sprintf('Missing file "%s"', $missingFile);
93+
$buildErrors[] = $message;
94+
$this->io->warning($message);
95+
}
96+
97+
if ($logPath = $input->getOption('save-errors')) {
98+
if (count($buildErrors) > 0) {
99+
array_unshift($buildErrors, sprintf('Build errors from "%s"', date('Y-m-d h:i:s')));
100+
}
101+
102+
file_put_contents($logPath, implode("\n", $buildErrors));
103+
}
84104

85105
$metas = $this->getMetas();
86106
if (!$this->buildContext->getParseSubPath()) {

src/KernelFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public static function createKernel(BuildContext $buildContext, ?UrlChecker $url
1818
$configuration = new RSTParserConfiguration();
1919
$configuration->setCustomTemplateDirs([sprintf('%s/src/Templates', $buildContext->getBasePath())]);
2020
$configuration->setCacheDir(sprintf('%s/var/cache', $buildContext->getBasePath()));
21+
$configuration->abortOnError(false);
2122

2223
if ($buildContext->getDisableCache()) {
2324
$configuration->setUseCachedMetas(false);

0 commit comments

Comments
 (0)