Browse Source

Présenter la version utilisée et les liens vers les documentations

master
Matthieu Marcillaud 9 months ago
parent
commit
3a11cae0d5
  1. 2
      placeholders/phpdoc.xml
  2. 7
      src/Stage/GitStage.php
  3. 19
      src/Stage/PackageStage.php
  4. 4
      src/Stage/PhpDocumentorConfigStage.php
  5. 12
      templates/template/components/sidebar.html.twig
  6. 14
      templates/template/css/custom.css.twig

2
placeholders/phpdoc.xml

@ -46,6 +46,8 @@
<setting name="package.slogan" value="@SLOGAN@"/>
<setting name="package.description" value="@DESCRIPTION@"/>
<setting name="package.presentation" value="@PRESENTATION@"/>
<setting name="package.version" value="@VERSION@"/>
<setting name="package.revision" value="@REVISION@"/>
<setting name="package.url_package" value="@URL_PACKAGE@"/>
<setting name="package.url_documentation" value="@URL_DOCUMENTATION@"/>
<setting name="package.url_development" value="@URL_DEVELOPMENT@"/>

7
src/Stage/GitStage.php

@ -24,7 +24,8 @@ class GitStage implements StageInterface
throw new ContextException(sprintf('Key "%s" needs to be defined and instance of Git.', 'git_asked'));
}
$this->download($context);
$git = $this->download($context);
$context->set('git', $git);
return $context;
}
@ -33,7 +34,7 @@ class GitStage implements StageInterface
/**
* Télécharge ou met à jour la source Git
**/
private function download(Context $context): void
private function download(Context $context): Git
{
if (!$context->has('input_directory')) {
$context->set('input_directory', $context->get('input_base_directory') . '/' . $context->get('default_prefix'));
@ -65,6 +66,6 @@ class GitStage implements StageInterface
$checkout->run($this::CHECKOUT_TYPE . ' -b' . $git->getBranch() . ' ' . $git->getUrl());
// On récupère le numéro de dernière révision, ça peut servir
$this->current = $checkout->readGit();
return $checkout->readGit();
}
}

19
src/Stage/PackageStage.php

@ -48,7 +48,7 @@ class PackageStage implements StageInterface
if (!$context->has('presentation')) {
$rev = "";
if ($context->has('git_current')) {
if ($context->has('git')) {
/** @var Git */
$git = $context->get('git');
if ($branch = $git->getBranch() and !in_array($branch, ['main', 'master'])) {
@ -59,27 +59,14 @@ class PackageStage implements StageInterface
}
}
$presentation = 'Cette documentation est issue du code source PHP ';
$presentation = 'Documentation du code PHP ';
$presentation .= match (true) {
$package->is_spip => 'de SPIP '.$package->version.$rev.'.',
$package->is_plugin => 'du plugin « '.$package->name.' », version '.$package->version.$rev.'.',
default => 'de « '.$context->get('title').' »'.$rev.'.',
};
$presentation .= '&#13;&#10;&#13;&#10;';
if (!$package->is_spip or $package->url_documentation or $package->url_development) {
if (!$package->is_spip) {
$presentation .= '- [Description dans l’annuaire des plugins]('.$package->url_package.')&#13;&#10;';
}
if ($package->url_documentation) {
$presentation .= '- [Documentation]('.$package->url_documentation.')&#13;&#10;';
}
if ($package->url_development) {
$presentation .= '- [Outil de développement]('.$package->url_development.')&#13;&#10;';
}
}
$context->set('presentation', $presentation);
$context->get('logger')->debug("Presentation: \n". rtrim(str_replace('&#13;&#10;', "\n", $presentation)));
$context->get('logger')->debug('Presentation: ' . $presentation);
}
}
}

4
src/Stage/PhpDocumentorConfigStage.php

@ -85,9 +85,11 @@ class PhpDocumentorConfigStage implements StageInterface
'@PREFIX@' => $prefix,
'@DEFAULT_PACKAGE_NAME@' => $context->get('default_prefix'),
'@TITLE@' => $context->get('title'),
'@PRESENTATION@' => $context->get('presentation'),
'@SLOGAN@' => $package->get('slogan'),
'@DESCRIPTION@' => $package->get('description'),
'@PRESENTATION@' => $context->get('presentation'),
'@VERSION@' => $package->get('version'),
'@REVISION@' => ($context->has('git') ? $context->get('git')->getCommit() : ''),
'@URL_PACKAGE@' => $package->get('url_package'),
'@URL_DOCUMENTATION@' => $package->get('url_documentation'),
'@URL_DEVELOPMENT@' => $package->get('url_development'),

12
templates/template/components/sidebar.html.twig

@ -2,11 +2,23 @@
{% block intro %}
<div class='phpdocumentor-sidebar__intro'>
{% if project.settings.custom['package.slogan'] %}
<p class='phpdocumentor-sidebar__slogan'>
{{- project.settings.custom['package.slogan'] -}}
</p>
{% endif %}
{% if project.settings.custom['package.version'] %}
<p class='phpdocumentor-sidebar__version'>
Version <strong>{{ project.settings.custom['package.version'] }}</strong>
{% if project.settings.custom['package.revision'] %}
({{ project.settings.custom['package.revision'] }})
{% endif %}
</p>
{% endif %}
</div>
{#
{% if project.settings.custom['package.description'] %}
<div class='phpdocumentor-sidebar__description'>

14
templates/template/css/custom.css.twig

@ -30,6 +30,20 @@ a[href^="https://"]:after {
content: "⬈";
}
.phpdocumentor-title {}
.phpdocumentor-sidebar__intro {
padding: .5em 1em;
background-color: var(--primary-color-lighten);
}
.phpdocumentor-sidebar__slogan {
font-size: var(--text-lg);
margin-bottom: 0 !important;
}
.phpdocumentor-sidebar__version {
margin-bottom: 0 !important;
}
.phpdocumentor-signature__name {
color: var(--spip-name-color);
}

Loading…
Cancel
Save