Skip to content
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
1 change: 1 addition & 0 deletions guides.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.phpdoc.org/guides packages/guides-cli/resources/schema/guides.xsd">
<project title="phpDocumentor Guides"/>
<theme>bootstrap</theme>

<extension class="phpDocumentor\Guides\Bootstrap"/>
</guides>
2 changes: 1 addition & 1 deletion packages/guides-cli/resources/schema/guides.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<xsd:element name="extension" type="extension" minOccurs="0" maxOccurs="unbounded"/>
</xsd:choice>

<xsd:attribute name="html-theme" type="xsd:string"/>
<xsd:attribute name="theme" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="extension">
Expand Down
5 changes: 3 additions & 2 deletions packages/guides-cli/src/Command/Run.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public function __construct(
null,
InputOption::VALUE_REQUIRED,
'The theme used for rendering.',
'default',
);

$this->addOption(
Expand Down Expand Up @@ -154,9 +153,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$theme = $input->getOption('theme');
if ($theme) {
$this->themeManager->useTheme($theme);
$settings->setTheme($theme);
}

$this->themeManager->useTheme($settings->getTheme());

$documents = $this->commandBus->handle(new CompileDocumentsCommand($documents, new CompilerContext($projectNode)));

$destinationFileSystem = new Filesystem(new Local($outputDir));
Expand Down
11 changes: 5 additions & 6 deletions packages/guides/src/DependencyInjection/GuidesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->end()
->end()
->end()
->scalarNode('html_theme')->end()
->scalarNode('theme')->end()
->arrayNode('base_template_paths')
->defaultValue([])
->scalarPrototype()->end()
Expand Down Expand Up @@ -104,16 +104,15 @@ public function load(array $configs, ContainerBuilder $container): void
$projectSettings['inventories'] = $config['inventories']['inventory'];
}

if (isset($config['theme'])) {
$projectSettings['theme'] = (string) $config['theme'];
}

if ($projectSettings) {
$container->getDefinition(SettingsManager::class)
->addMethodCall('setProjectSettings', [new ProjectSettings($projectSettings)]);
}

if (isset($config['html_theme'])) {
$container->getDefinition(ThemeManager::class)
->addMethodCall('useTheme', [$config['html_theme']]);
}

$config['base_template_paths'][] = dirname(__DIR__, 2) . '/resources/template/html';
$container->setParameter('phpdoc.guides.base_template_paths', $config['base_template_paths']);

Expand Down
34 changes: 31 additions & 3 deletions packages/guides/src/Settings/ProjectSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
class ProjectSettings
{
/** @var array<string, string> */
private readonly array $inventories;
private readonly string $title;
private readonly string $version;
private array $inventories;
private string $title;
private string $version;
private string $theme;

/** @param array<string, string|array<string, string>> $settingsArray */
public function __construct(array $settingsArray)
{
$this->title = isset($settingsArray['title']) && is_string($settingsArray['title']) ? $settingsArray['title'] : '';
$this->version = isset($settingsArray['version']) && is_string($settingsArray['version']) ? $settingsArray['version'] : '';
$this->inventories = isset($settingsArray['inventories']) && is_array($settingsArray['inventories']) ? $settingsArray['inventories'] : [];
$this->theme = isset($settingsArray['theme']) && is_string($settingsArray['theme']) ? $settingsArray['theme'] : 'default';
}

public function getTitle(): string
Expand All @@ -37,4 +39,30 @@ public function getInventories(): array
{
return $this->inventories;
}

public function getTheme(): string
{
return $this->theme;
}

/** @param array<string, string> $inventories*/
public function setInventories(array $inventories): void
{
$this->inventories = $inventories;
}

public function setTitle(string $title): void
{
$this->title = $title;
}

public function setVersion(string $version): void
{
$this->version = $version;
}

public function setTheme(string $theme): void
{
$this->theme = $theme;
}
}
158 changes: 0 additions & 158 deletions tests/Integration/IntegrationBootstrapTest.php

This file was deleted.

8 changes: 8 additions & 0 deletions tests/Integration/tests/bootstrap-admonition/input/guides.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<guides xmlns="https://www.phpdoc.org/guides"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.phpdoc.org/guides packages/guides-cli/resources/schema/guides.xsd">
<theme>bootstrap</theme>

<extension class="phpDocumentor\Guides\Bootstrap"/>
</guides>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<guides xmlns="https://www.phpdoc.org/guides"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.phpdoc.org/guides packages/guides-cli/resources/schema/guides.xsd">
<theme>bootstrap</theme>

<extension class="phpDocumentor\Guides\Bootstrap"/>
</guides>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<guides xmlns="https://www.phpdoc.org/guides"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.phpdoc.org/guides packages/guides-cli/resources/schema/guides.xsd">
<theme>bootstrap</theme>

<extension class="phpDocumentor\Guides\Bootstrap"/>
</guides>
8 changes: 8 additions & 0 deletions tests/Integration/tests/bootstrap-index/input/guides.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<guides xmlns="https://www.phpdoc.org/guides"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.phpdoc.org/guides packages/guides-cli/resources/schema/guides.xsd">
<theme>bootstrap</theme>

<extension class="phpDocumentor\Guides\Bootstrap"/>
</guides>
8 changes: 8 additions & 0 deletions tests/Integration/tests/bootstrap-tabs/input/guides.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<guides xmlns="https://www.phpdoc.org/guides"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.phpdoc.org/guides packages/guides-cli/resources/schema/guides.xsd">
<theme>bootstrap</theme>

<extension class="phpDocumentor\Guides\Bootstrap"/>
</guides>