-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor #3735 Use the PHP doc builder instead of Sphinx in CI (fabpot)
This PR was merged into the 2.x branch. Discussion ---------- Use the PHP doc builder instead of Sphinx in CI Commits ------- fcf65bd Use the PHP doc builder instead of Sphinx in CI
- Loading branch information
Showing
9 changed files
with
2,065 additions
and
455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/doc/** export-ignore | ||
/extra/** export-ignore | ||
/tests export-ignore | ||
/doc/ export-ignore | ||
/extra/ export-ignore | ||
/tests/ export-ignore | ||
/phpunit.xml.dist export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/doc/_build/vendor | ||
/doc/_build/output | ||
/composer.lock | ||
/phpunit.xml | ||
/vendor | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
require __DIR__.'/vendor/autoload.php'; | ||
|
||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
use SymfonyDocsBuilder\BuildConfig; | ||
use SymfonyDocsBuilder\DocBuilder; | ||
|
||
(new Application('Twig docs Builder', '1.0')) | ||
->register('build-docs') | ||
->addOption('disable-cache', null, InputOption::VALUE_NONE, 'Use this option to force a full regeneration of all doc contents') | ||
->setCode(function (InputInterface $input, OutputInterface $output) { | ||
$io = new SymfonyStyle($input, $output); | ||
$io->text('Building all Twig docs...'); | ||
|
||
$outputDir = __DIR__.'/output'; | ||
$buildConfig = (new BuildConfig()) | ||
->setContentDir(__DIR__.'/..') | ||
->setOutputDir($outputDir) | ||
->setImagesDir(__DIR__.'/output/_images') | ||
->setImagesPublicPrefix('_images') | ||
->setTheme('rtd') | ||
; | ||
|
||
$buildConfig->setExcludedPaths(['vendor/']); | ||
$buildConfig->disableJsonFileGeneration(); | ||
$buildConfig->disableBuildCache(); | ||
|
||
$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 Twig 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())); | ||
$io->newLine(); | ||
$io->comment('Tip: you can add the -v, -vv or -vvv flags to this command to get debug information.'); | ||
|
||
return 1; | ||
} | ||
|
||
return 0; | ||
}) | ||
->getApplication() | ||
->setDefaultCommand('build-docs', true) | ||
->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"config": { | ||
"platform": { | ||
"php": "8.1.0" | ||
}, | ||
"preferred-install": { | ||
"*": "dist" | ||
}, | ||
"sort-packages": true | ||
}, | ||
"require": { | ||
"php": ">=8.1", | ||
"symfony/console": "^5.4", | ||
"symfony/process": "^5.4", | ||
"symfony-tools/docs-builder": "^0.18" | ||
} | ||
} |
Oops, something went wrong.