diff --git a/phpdoc/template/components/sidebar.html.twig b/phpdoc/template/components/sidebar.html.twig index b29e710..45373db 100644 --- a/phpdoc/template/components/sidebar.html.twig +++ b/phpdoc/template/components/sidebar.html.twig @@ -66,6 +66,6 @@ {% block outro %}
-

Documentation générée le {{ 'now'|date('d m Y', "Europe/Paris") }} à {{ 'now'|date('h\\hi', "Europe/Paris") }}

+

Documentation générée le {{ 'now'|date('d m Y', "Europe/Paris") }} à {{ 'now'|date('H\\hi', "Europe/Paris") }}

{% endblock %} \ No newline at end of file diff --git a/src/Stage/IndexStage.php b/src/Stage/IndexStage.php index 84c5222..852f77e 100644 --- a/src/Stage/IndexStage.php +++ b/src/Stage/IndexStage.php @@ -20,26 +20,27 @@ class IndexStage implements StageInterface { } $list = $this->load($context->directory->output_base); - $sorted = $this->sort($list); - dump($sorted); + $list = $this->sort($list); + $this->createIndex($context, $list); return $context; } /** @return array */ - public function load(string $output_base_directory): array { + private function load(string $output_base_directory): array { $list = []; $projects = glob($output_base_directory . '/*/autodoc.json'); foreach ($projects as $project) { $dir = basename(dirname($project)); $json = json_decode(file_get_contents($project)); - $list[$dir] = $json; + $json->path = $dir; + $list[] = $json; } return $list; } /** @return array */ - public function sort(array $list): array { + private function sort(array $list): array { $groups = []; foreach ($list as $project) { $organization = basename(dirname($project->urls->repository ?: '')) ?: 'other'; @@ -55,4 +56,33 @@ class IndexStage implements StageInterface { } return $groups; } + + private function createIndex(Context $context, array $groups) { + // charger Twig, générer la page et l'enregitrer + $loader = new \Twig\Loader\FilesystemLoader($context->directory->templates); + $twig = new \Twig\Environment($loader); + $twig->getExtension(\Twig\Extension\CoreExtension::class)->setTimezone('Europe/Paris'); + + $organizations = [ + 'spip' => 'SPIP', + 'spip-core' => 'Core', + 'spip-contrib-extensions' => 'Plugins', + 'spip-contrib-outils' => 'Outils', + 'spip-contrib-squelettes' => 'Squelettes', + 'other' => 'Autres', + ]; + $others = array_diff(array_keys($groups), array_keys($organizations)); + foreach ($others as $other) { + $organizations[$other] = $other; + } + + $index = $twig->render('index.html.twig', [ + 'title' => 'Documentation automatique de SPIP et ses plugins', + 'groups' => $groups, + 'organizations' => $organizations, + ]); + file_put_contents($context->directory->output_base . '/index.html', $index); + + return $context; + } } \ No newline at end of file diff --git a/src/Stage/JsonAutodocStage.php b/src/Stage/JsonAutodocStage.php index 12fa41b..b12bc19 100644 --- a/src/Stage/JsonAutodocStage.php +++ b/src/Stage/JsonAutodocStage.php @@ -42,7 +42,7 @@ class JsonAutodocStage implements StageInterface $json->urls->package = $package->get('url_package'); $json->urls->documentation = $package->get('url_documentation'); $json->urls->development = $package->get('url_development'); - $json->urls->repository = $context->has('git_asked') ? ($context->get('git_asked')->getRepositoryUrl() ?? '') : ''; + $json->urls->repository = $context->has('git') ? ($context->get('git')->getRepositoryUrl() ?? '') : ''; file_put_contents($output_directory . '/autodoc.json', json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); diff --git a/src/Stage/PhpDocumentorConfigStage.php b/src/Stage/PhpDocumentorConfigStage.php index 8c53032..c1a2554 100644 --- a/src/Stage/PhpDocumentorConfigStage.php +++ b/src/Stage/PhpDocumentorConfigStage.php @@ -76,8 +76,6 @@ class PhpDocumentorConfigStage implements StageInterface private function generateConfig(Context $context) { - $repository = $context->has('git_asked') ? ($context->get('git_asked')->getRepositoryUrl() ?? '') : ''; - // charger Twig, générer la page et l'enregitrer $loader = new \Twig\Loader\FilesystemLoader($context->directory->templates); $twig = new \Twig\Environment($loader); diff --git a/templates/index.html b/templates/index.html.twig similarity index 57% rename from templates/index.html rename to templates/index.html.twig index c6993f8..e7d093f 100644 --- a/templates/index.html +++ b/templates/index.html.twig @@ -1,7 +1,7 @@ - {{ titre }} + {{ title }} @@ -28,7 +28,7 @@
-

{{ titre }}

+

{{ title }}

@@ -50,38 +50,41 @@
-

{{ titre }}

+

{{ title }}

-

Liste des documentations du code PHP de plugin pour SPIP :

- - - - - - {% for plugin in plugins %} - - - - - - {% endfor %} - -
NomDescriptionAutres liens
- {{ plugin.nom }}{{ plugin.slogan }} - {%- if plugin.annuaire %} - Annuaire - {%- endif %} - - {%- if plugin.documentation %} - {{- plugin.annuaire ? ' / '}} - Documentation - {%- endif %} - - {%- if plugin.developpement %} - {{- (plugin.annuaire or plugin.documentation) ? ' / '}} - Suivi - {%- endif %} -
+ {% for organization, name in organizations %} + {% if groups[organization] %} +

{{ name }}

+ + + + + + {% for package in groups[organization] %} + + + + + + {% endfor %} + +
NomDescriptionAutres liens
+ {{ package.title }}{{ package.slogan }}
+ {% endif %} + {% endfor %}