From c6af87a69a72827e9ace099f5bc84bb96c4e09b5 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 28 Feb 2022 10:51:18 +0100 Subject: [PATCH] Fix the local doc build --- README.markdown | 8 +++++++- _build/build.php | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 2139c1599ac..c7758624d24 100644 --- a/README.markdown +++ b/README.markdown @@ -42,4 +42,10 @@ $ composer install $ php build.php ``` -Now you can browse the docs at `_build/output/index.html` +After generating docs, serve them with the internal PHP server: + +```bash +$ php -S localhost:8000 -t output/ +``` + +Browse `http://localhost:8000` to read the docs. diff --git a/_build/build.php b/_build/build.php index b17e3e984be..3c64f4d6b85 100755 --- a/_build/build.php +++ b/_build/build.php @@ -46,6 +46,12 @@ $result = (new DocBuilder())->build($buildConfig); if ($result->isSuccessful()) { + // fix assets URLs to make them absolute (otherwise, they don't work in subdirectories) + foreach (glob($outputDir.'/**/*.html') as $htmlFilePath) { + $htmlContents = file_get_contents($htmlFilePath); + file_put_contents($htmlFilePath, str_replace('href="assets/', 'href="/assets/', $htmlContents)); + } + $io->success(sprintf("The Symfony Docs were successfully built at %s", realpath($outputDir))); } else { $io->error(sprintf("There were some errors while building the docs:\n\n%s\n", $result->getErrorTrace()));