Skip to content

Fix the local doc build #16554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
6 changes: 6 additions & 0 deletions _build/build.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down