Skip to content

Commit

Permalink
[FEATURE] Automatically generate rst or md documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
linawolf committed Dec 16, 2024
1 parent 4af78a0 commit bd7bbb2
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions packages/typo3-guides-cli/src/Command/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

namespace T3Docs\GuidesCli\Command;

use T3Docs\GuidesCli\Generation\DocumentationGenerator;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
use T3Docs\GuidesCli\Generation\DocumentationGenerator;
use T3Docs\VersionHandling\Packagist\ComposerPackage;
use T3Docs\VersionHandling\Packagist\PackagistService;

Expand Down Expand Up @@ -76,7 +76,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$question = new Question(sprintf('Do you want to use reStructuredText(rst) or MarkDown(md)? <comment>[rst, md]</comment>: '), 'rst');
$question->setValidator(function ($answer) {
if (is_null($answer) || !in_array($answer, ['rst', 'md'], true)) {
if (is_null($answer) || !in_array($answer, [
'rst',
'md',
], true)) {
throw new \RuntimeException('Choose reStructuredText(rst) or MarkDown(md). ');
}
return $answer;
Expand Down Expand Up @@ -127,14 +130,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$question = new Question('Do you want generate some Documentation? (yes/no) ', 'yes');
$question->setValidator(function ($answer) {
if (!in_array(strtolower($answer), ['yes', 'y', 'no', 'n'], true)) {
if (!in_array(strtolower($answer), [
'yes',
'y',
'no',
'n',
], true)) {
throw new \RuntimeException('Please answer with yes, no, y, or n.');
}
return strtolower($answer);
});

$answer = $helper->ask($input, $output, $question);
$enableExampleFileGeneration = in_array($answer, ['yes', 'y'], true);
$enableExampleFileGeneration = in_array($answer, [
'yes',
'y',
], true);

$question = new Question('Does your extension offer a site set to be included? If so enter the name: ');
$siteSet = $helper->ask($input, $output, $question);
Expand Down

0 comments on commit bd7bbb2

Please sign in to comment.