Skip to content

Commit 1a2090b

Browse files
committed
Splitting layout into an rtd theme so we can render tests in a "pure" format
1 parent 9011e3d commit 1a2090b

16 files changed

+24
-153
lines changed

src/BuildContext.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace SymfonyDocsBuilder;
44

5+
use Doctrine\RST\Configuration;
6+
57
class BuildContext
68
{
79
private $symfonyVersion;
@@ -14,6 +16,7 @@ class BuildContext
1416
private $outputDir;
1517
private $parseSubPath;
1618
private $disableCache = false;
19+
private $theme;
1720
private $cacheDirectory;
1821

1922
public function __construct(
@@ -28,12 +31,13 @@ public function __construct(
2831
$this->symfonyDocUrl = $symfonyDocUrl;
2932
}
3033

31-
public function initializeRuntimeConfig(string $sourceDir, string $outputDir, ?string $parseSubPath = null, bool $disableCache = false)
34+
public function initializeRuntimeConfig(string $sourceDir, string $outputDir, ?string $parseSubPath = null, bool $disableCache = false, string $theme = Configuration::THEME_DEFAULT)
3235
{
3336
$this->sourceDir = $sourceDir;
3437
$this->outputDir = $outputDir;
3538
$this->parseSubPath = $parseSubPath;
3639
$this->disableCache = $disableCache;
40+
$this->theme = $theme;
3741
$this->runtimeInitialized = true;
3842
}
3943

@@ -85,6 +89,13 @@ public function getDisableCache(): bool
8589
return $this->disableCache;
8690
}
8791

92+
public function getTheme(): string
93+
{
94+
$this->checkThatRuntimeConfigIsInitialized();
95+
96+
return $this->theme;
97+
}
98+
8899
public function getCacheDir(): string
89100
{
90101
return $this->cacheDirectory ?: $this->getOutputDir().'/.cache';

src/Command/BuildDocsCommand.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Doctrine\Common\EventManager;
66
use Doctrine\RST\Builder;
7+
use Doctrine\RST\Configuration;
78
use Doctrine\RST\Event\PostBuildRenderEvent;
89
use Doctrine\RST\Meta\Metas;
910
use Symfony\Component\Console\Command\Command;
@@ -71,6 +72,12 @@ protected function configure()
7172
InputOption::VALUE_REQUIRED,
7273
'Path where any errors should be saved'
7374
)
75+
->addOption(
76+
'no-theme',
77+
null,
78+
InputOption::VALUE_NONE,
79+
'Use the default theme instead of the styled one'
80+
)
7481
;
7582
}
7683

@@ -102,7 +109,8 @@ protected function initialize(InputInterface $input, OutputInterface $output)
102109
$sourceDir,
103110
$htmlOutputDir,
104111
$parseSubPath,
105-
$input->getOption('disable-cache')
112+
$input->getOption('disable-cache'),
113+
$input->getOption('no-theme') ? Configuration::THEME_DEFAULT : 'rtd'
106114
);
107115
}
108116

src/KernelFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public static function createKernel(BuildContext $buildContext, ?UrlChecker $url
2020
{
2121
$configuration = new RSTParserConfiguration();
2222
$configuration->setCustomTemplateDirs([__DIR__.'/Templates']);
23+
$configuration->setTheme($buildContext->getTheme());
2324
$configuration->setCacheDir(sprintf('%s/var/cache', $buildContext->getCacheDir()));
2425
$configuration->abortOnError(false);
2526

src/Listener/AssetsCopyListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function postBuildRender()
1818
{
1919
$fs = new Filesystem();
2020
$fs->mirror(
21-
sprintf('%s/../Templates/default/assets', __DIR__),
21+
sprintf('%s/../Templates/rtd/assets', __DIR__),
2222
sprintf('%s/assets', $this->targetDir)
2323
);
2424
}

src/Templates/default/html/layout.html.twig

Lines changed: 0 additions & 150 deletions
This file was deleted.

0 commit comments

Comments
 (0)