diff --git a/src/Command/FromDirectory.php b/src/Command/FromDirectory.php
index bbefdd4..b144066 100644
--- a/src/Command/FromDirectory.php
+++ b/src/Command/FromDirectory.php
@@ -55,8 +55,7 @@ class FromDirectory extends Command
if ($input->hasOption('prefix') and $input->getOption('prefix')) {
$context->set('default_prefix', $input->getOption('prefix'));
}
- $context->set('topnav', $input->getOption('topnav'));
- $context->set('topnav_spip', $input->getOption('topnav_spip'));
+ $context->header->set('topnav', $input->getOption('topnav_spip') ? Context::TOPNAV_SPIP : $input->getOption('topnav'));
$context->phpdocumentor->options->set('force', $input->getOption('force'));
$this->pipeline($context);
diff --git a/src/Command/FromFile.php b/src/Command/FromFile.php
index 4f634d5..6391588 100644
--- a/src/Command/FromFile.php
+++ b/src/Command/FromFile.php
@@ -78,8 +78,7 @@ https://git.spip.net/spip-contrib-extensions/champs_extras_core@master;cextras
$context->set('only_this_prefix', $input->getOption('outputs'));
}
- $context->set('topnav', $input->getOption('topnav'));
- $context->set('topnav_spip', $input->getOption('topnav_spip'));
+ $context->header->set('topnav', $input->getOption('topnav_spip') ? Context::TOPNAV_SPIP : $input->getOption('topnav'));
$context->phpdocumentor->options->set('force', $input->getOption('force'));
$autodoc = new AutodocFile(
diff --git a/src/Command/FromGit.php b/src/Command/FromGit.php
index f87f179..02bfa43 100644
--- a/src/Command/FromGit.php
+++ b/src/Command/FromGit.php
@@ -68,8 +68,7 @@ class FromGit extends Command
$context->directory->set('output', $input->getOption('output'));
$context->set('default_prefix', $input->getOption('prefix') ?: pathinfo($source, \PATHINFO_FILENAME));
- $context->set('topnav', $input->getOption('topnav'));
- $context->set('topnav_spip', $input->getOption('topnav_spip'));
+ $context->header->set('topnav', $input->getOption('topnav_spip') ? Context::TOPNAV_SPIP : $input->getOption('topnav'));
$context->phpdocumentor->options->set('force', $input->getOption('force'));
$branch = $input->getOption('branch');
diff --git a/src/Command/MakeIndex.php b/src/Command/MakeIndex.php
index e77bfd3..8a1ae61 100644
--- a/src/Command/MakeIndex.php
+++ b/src/Command/MakeIndex.php
@@ -43,8 +43,7 @@ class MakeIndex extends Command
if ($input->getOption('outputs')) {
$context->directory->set('output_base', $input->getOption('outputs'));
}
- $context->set('topnav', $input->getOption('topnav'));
- $context->set('topnav_spip', $input->getOption('topnav_spip'));
+ $context->header->set('topnav', $input->getOption('topnav_spip') ? Context::TOPNAV_SPIP : $input->getOption('topnav'));
$this->pipeline($context);
diff --git a/src/Context.php b/src/Context.php
index 2f72365..48f5723 100644
--- a/src/Context.php
+++ b/src/Context.php
@@ -9,6 +9,8 @@ use Symfony\Component\Console\Style\SymfonyStyle;
class Context extends Container
{
+ const TOPNAV_SPIP = '//boussole.spip.net/?page=spipnav.js&lang=fr';
+
public function __construct(InputInterface $input, OutputInterface $output)
{
$this->set('io', new SymfonyStyle($input, $output));
@@ -17,8 +19,13 @@ class Context extends Container
$this->set('php', PHP_BINARY);
$this->set('default_prefix', 'default');
$this->set('only_this_prefix', null);
- $this->set('topnav', null);
- $this->set('topnav_spip', null);
+
+ $this->set('header', new Container([
+ 'title' => 'SPIP Code',
+ 'subtitle' => 'Documentation du code de SPIP et de ses plugins',
+ 'url' => 'https://code.spip.net/',
+ 'topnav' => null,
+ ]));
$cwd = getcwd();
$var = $cwd . '/var';
diff --git a/src/Stage/IndexStage.php b/src/Stage/IndexStage.php
index a2f8590..a47d8e6 100644
--- a/src/Stage/IndexStage.php
+++ b/src/Stage/IndexStage.php
@@ -99,19 +99,11 @@ class IndexStage implements StageInterface {
$organizations[$other] = $other;
}
- $topnav = match (true) {
- !$context->empty('topnav_spip') => PhpDocumentorConfigStage::TOPNAV_SPIP,
- !$context->empty('topnav') => $context->get('topnav'),
- default => null,
- };
-
$template = new Template($context->directory->templates, $context->directory->output_base);
$template->generate('index.html.twig', [
- 'title' => 'SPIP Code',
- 'subtitle' => 'Documentation du code de SPIP et ses plugins',
+ 'header' => $context->header,
'groups' => $groups,
'organizations' => $organizations,
- 'topnav' => $topnav,
]);
}
diff --git a/src/Stage/PhpDocumentorConfigStage.php b/src/Stage/PhpDocumentorConfigStage.php
index d594d81..6cece98 100644
--- a/src/Stage/PhpDocumentorConfigStage.php
+++ b/src/Stage/PhpDocumentorConfigStage.php
@@ -16,7 +16,6 @@ use Symfony\Component\Filesystem\Filesystem;
*/
class PhpDocumentorConfigStage implements StageInterface
{
- const TOPNAV_SPIP = '//boussole.spip.net/?page=spipnav.js&lang=fr';
public function __invoke(Context $context): Context
{
@@ -84,24 +83,13 @@ class PhpDocumentorConfigStage implements StageInterface
private function generateConfig(Context $context) {
$template = new Template($context->directory->templates, $context->directory->config);
- $topnav = match (true) {
- !$context->empty('topnav_spip') => $this::TOPNAV_SPIP,
- !$context->empty('topnav') => $context->get('topnav'),
- default => null,
- };
- // FIXME: externaliser en config ...
- $header = new stdClass();
- $header->title = 'SPIP Code';
- $header->subtitle = 'Documentation du code de SPIP et ses plugins';
- $header->url = 'https://code.spip.net/';
$content = $template->render('phpdoc.xml.twig', [
'title' => $context->title,
'presentation' => $context->presentation,
'package' => $context->package,
'directory' => $context->directory,
'git' => $context->has('git') ? $context->git : null,
- 'topnav' => $topnav,
- 'header' => $header
+ 'header' => $context->header,
]);
$file = 'phpdoc_' . ($context->package->prefix ?: $context->default_prefix) . '.xml';
$template->write($file, $content);
diff --git a/templates/index.html.twig b/templates/index.html.twig
index 23b4eae..5aaf270 100644
--- a/templates/index.html.twig
+++ b/templates/index.html.twig
@@ -13,11 +13,11 @@
- {%- if topnav %}
+ {%- if header.topnav %}
{%- endif -%}
@@ -27,13 +27,13 @@
{{ title }}
+ {{ header.title }}