Skip to content

Commit 1b0cd02

Browse files
committed
bug #16554 Fix the local doc build (javiereguiluz)
This PR was merged into the 4.4 branch. Discussion ---------- Fix the local doc build It's not a very beautiful solution, but it works. Commits ------- c6af87a Fix the local doc build
2 parents 9490e36 + c6af87a commit 1b0cd02

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

README.markdown

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,10 @@ $ composer install
4242
$ php build.php
4343
```
4444

45-
Now you can browse the docs at `_build/output/index.html`
45+
After generating docs, serve them with the internal PHP server:
46+
47+
```bash
48+
$ php -S localhost:8000 -t output/
49+
```
50+
51+
Browse `http://localhost:8000` to read the docs.

_build/build.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
$result = (new DocBuilder())->build($buildConfig);
4747

4848
if ($result->isSuccessful()) {
49+
// fix assets URLs to make them absolute (otherwise, they don't work in subdirectories)
50+
foreach (glob($outputDir.'/**/*.html') as $htmlFilePath) {
51+
$htmlContents = file_get_contents($htmlFilePath);
52+
file_put_contents($htmlFilePath, str_replace('href="assets/', 'href="/assets/', $htmlContents));
53+
}
54+
4955
$io->success(sprintf("The Symfony Docs were successfully built at %s", realpath($outputDir)));
5056
} else {
5157
$io->error(sprintf("There were some errors while building the docs:\n\n%s\n", $result->getErrorTrace()));

0 commit comments

Comments
 (0)