From e0e069febf42643828b33eac11391d93a96f8037 Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Tue, 26 Nov 2024 14:21:43 -0800 Subject: [PATCH] CLI-1406: Command documentation markup (#1833) * CLI-1406: Command documentation markup * kill mutant --- src/Command/Self/MakeDocsCommand.php | 4 +++- tests/phpunit/src/Commands/Self/MakeDocsCommandTest.php | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Command/Self/MakeDocsCommand.php b/src/Command/Self/MakeDocsCommand.php index b888f642a..ad777cc2e 100644 --- a/src/Command/Self/MakeDocsCommand.php +++ b/src/Command/Self/MakeDocsCommand.php @@ -7,6 +7,7 @@ use Acquia\Cli\Command\CommandBase; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Helper\DescriptorHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -19,7 +20,7 @@ final class MakeDocsCommand extends CommandBase protected function configure(): void { $this->addOption('format', 'f', InputOption::VALUE_OPTIONAL, 'The format to describe the docs in.', 'rst'); - $this->addOption('dump', 'd', InputOption::VALUE_OPTIONAL, 'Dump docs to directory'); + $this->addOption('dump', 'd', InputOption::VALUE_OPTIONAL, 'Dump docs to directory (implies JSON format)'); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -46,6 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int continue; } $filename = $command['name'] . '.json'; + $command['help'] = (new OutputFormatter())->format($command['help']); $index[] = [ 'command' => $command['name'], 'help' => $command['help'], diff --git a/tests/phpunit/src/Commands/Self/MakeDocsCommandTest.php b/tests/phpunit/src/Commands/Self/MakeDocsCommandTest.php index 6ae7a534b..1ae603ef9 100644 --- a/tests/phpunit/src/Commands/Self/MakeDocsCommandTest.php +++ b/tests/phpunit/src/Commands/Self/MakeDocsCommandTest.php @@ -7,6 +7,7 @@ use Acquia\Cli\Command\CommandBase; use Acquia\Cli\Command\Self\MakeDocsCommand; use Acquia\Cli\Tests\CommandTestBase; +use org\bovigo\vfs\vfsStream; /** * @property \Acquia\Cli\Command\Self\MakeDocsCommand $command @@ -26,4 +27,11 @@ public function testMakeDocsCommand(): void $this->assertStringContainsString('============', $output); $this->assertStringContainsString('- `help`_', $output); } + + public function testMakeDocsCommandDump(): void + { + $vfs = vfsStream::setup('root'); + $this->executeCommand(['--dump' => $vfs->url()]); + $this->assertStringContainsString('The completion command dumps', $vfs->getChild('completion.json')->getContent()); + } }