Browse Source

Permettre d’avoir des docs .rst dans 'docs/' ou 'doc/'. Correction de sourci de préfixe sur from:directory

master
Matthieu Marcillaud 9 months ago
parent
commit
852b1411da
  1. 2
      src/Command/FromDirectory.php
  2. 6
      src/Package.php
  3. 7
      src/Stage/PhpDocumentorConfigStage.php
  4. 6
      templates/phpdoc.xml.twig

2
src/Command/FromDirectory.php

@ -52,7 +52,7 @@ class FromDirectory extends Command
$context->directory->set('input', $source);
$context->directory->set('output', $input->getOption('output'));
if ($input->hasOption('prefix')) {
if ($input->hasOption('prefix') and $input->getOption('prefix')) {
$context->set('default_prefix', $input->getOption('prefix'));
}
$context->set('topnav', $input->getOption('topnav'));

6
src/Package.php

@ -19,7 +19,7 @@ class Package
private string $url_package = '';
private string $url_documentation = '';
private string $url_development = '';
private bool $with_rst_documentation = false;
private string $rst_directory = '';
public function __construct(
private string $input_directory,
@ -76,7 +76,9 @@ class Package
$this->logger->notice('Directory does not contains Spip or Plugin');
}
if (file_exists($this->input_directory.'/docs/index.rst')) {
$this->with_rst_documentation = true;
$this->rst_directory = 'docs';
} elseif (file_exists($this->input_directory.'/doc/index.rst')) {
$this->rst_directory = 'doc';
}
}

7
src/Stage/PhpDocumentorConfigStage.php

@ -57,6 +57,9 @@ class PhpDocumentorConfigStage implements StageInterface
if (!$fs->exists($cache_directory)) {
$fs->mkdir($cache_directory);
}
if (!$fs->exists($cache_directory . '/guides')) {
$fs->mkdir($cache_directory . '/guides');
}
$config_directory = $context->directory->config;
if (!$fs->exists($config_directory)) {
@ -96,11 +99,11 @@ class PhpDocumentorConfigStage implements StageInterface
'presentation' => $context->presentation,
'package' => $context->package,
'directory' => $context->directory,
'git' => $context->git,
'git' => $context->has('git') ? $context->git : null,
'topnav' => $topnav,
'header' => $header
]);
$file = 'phpdoc_' . $context->package->prefix . '.xml';
$file = 'phpdoc_' . ($context->package->prefix ?: $context->default_prefix) . '.xml';
$template->write($file, $content);
$context->phpdocumentor->set('config', $context->directory->config . '/' . $file);

6
templates/phpdoc.xml.twig

@ -37,9 +37,9 @@
</api>
<guide format="rst">
<source dsn="{{ directory.input }}">
<path>docs</path>
<path>{{ package.rst_directory }}</path>
</source>
<output>docs</output>
<output>guide</output>
</guide>
</version>
@ -58,6 +58,6 @@
<setting name="header.title" value="{{ header.title }}"/>
<setting name="header.subtitle" value="{{ header.subtitle }}"/>
<setting name="guides.enabled" value="{{ package.with_rst_documentation ? 'true' : 'false' }}"/>
<setting name="guides.enabled" value="{{ package.rst_directory ? 'true' : 'false' }}"/>
<template name="default" />
</phpdocumentor>

Loading…
Cancel
Save