Browse Source

Générer un index_autodoc.json

master
Matthieu Marcillaud 1 year ago
parent
commit
d80e12986e
  1. 8
      src/Container.php
  2. 21
      src/Stage/IndexStage.php
  3. 3
      src/Stage/JsonAutodocStage.php

8
src/Container.php

@ -2,7 +2,9 @@
namespace Spip\Autodoc;
class Container
use JsonSerializable;
class Container implements JsonSerializable
{
public function __construct(private array $context = [])
{
@ -70,4 +72,8 @@ class Container
return $this;
}
public function jsonSerialize(): array {
return $this->context;
}
}

21
src/Stage/IndexStage.php

@ -99,13 +99,28 @@ class IndexStage implements StageInterface {
foreach ($others as $other) {
$organizations[$other] = $other;
}
$repositories = [];
foreach ($groups as $projects) {
foreach ($projects as $project) {
if ($project->urls->repository) {
$repositories[$project->urls->repository] = rtrim($context->header->url, '/') . '/' . $project->path;
}
}
}
$template = new Template($context->directory->templates, $context->directory->output_base);
$template->generate('index.html.twig', [
$data = [
'header' => $context->header,
'groups' => $groups,
'organizations' => $organizations,
]);
'repositories' => $repositories,
];
dump($repositories);
$template = new Template($context->directory->templates, $context->directory->output_base);
$template->generate('index.html.twig', $data);
file_put_contents($context->directory->output_base . '/index_autodoc.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
}
private function copyCss(Context $context) {

3
src/Stage/JsonAutodocStage.php

@ -36,7 +36,8 @@ class JsonAutodocStage implements StageInterface
$json->prefix = $package->get('prefix');
$json->slogan = $package->get('slogan');
$json->version = $package->get('version');
$json->revision = ($context->has('git') ? $context->get('git')->getCommit() : '');
$json->branch = ($context->has('git') ? $context->git->getBranch() : '');
$json->revision = ($context->has('git') ? $context->git->getCommit() : '');
$json->date = (new DateTime())->format(DateTimeInterface::W3C);
$json->urls = new stdClass();
$json->urls->package = $package->get('url_package');

Loading…
Cancel
Save