Skip to content

Commit

Permalink
CLI-1406: Command documentation markup (#1833)
Browse files Browse the repository at this point in the history
* CLI-1406: Command documentation markup

* kill mutant
  • Loading branch information
danepowell authored Nov 26, 2024
1 parent 449792d commit e0e069f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Command/Self/MakeDocsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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'],
Expand Down
8 changes: 8 additions & 0 deletions tests/phpunit/src/Commands/Self/MakeDocsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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());
}
}

0 comments on commit e0e069f

Please sign in to comment.