publish dump-rectors command with 3rd party install

This commit is contained in:
TomasVotruba 2020-04-26 23:21:29 +02:00
parent 42bbbe210d
commit 93c033809a
8 changed files with 37 additions and 18 deletions

View File

@ -67,6 +67,7 @@
"Rector\\ConsoleDiffer\\": "packages/console-differ/src",
"Rector\\Core\\": "src",
"Rector\\DeadCode\\": "rules/dead-code/src",
"Rector\\DocumentationGenerator\\": "packages/documentation-generator/src",
"Rector\\DoctrineCodeQuality\\": "rules/doctrine-code-quality/src",
"Rector\\DoctrineGedmoToKnplabs\\": "rules/doctrine-gedmo-to-knplabs/src",
"Rector\\Doctrine\\": "rules/doctrine/src",

View File

@ -0,0 +1,8 @@
services:
_defaults:
public: true
autowire: true
autoconfigure: true
Rector\DocumentationGenerator\:
resource: '../src'

View File

@ -2,12 +2,12 @@
declare(strict_types=1);
namespace Rector\Utils\DocumentationGenerator\Command;
namespace Rector\DocumentationGenerator\Command;
use Rector\Core\Configuration\Option;
use Rector\Core\Console\Command\AbstractCommand;
use Rector\Core\Testing\Finder\RectorsFinder;
use Rector\Utils\DocumentationGenerator\OutputFormatter\DumpRectors\MarkdownDumpRectorsOutputFormatter;
use Rector\DocumentationGenerator\OutputFormatter\MarkdownDumpRectorsOutputFormatter;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -50,7 +50,7 @@ final class DumpRectorsCommand extends AbstractCommand
protected function execute(InputInterface $input, OutputInterface $output): int
{
$source = $input->getArgument(Option::SOURCE);
$source = (array) $input->getArgument(Option::SOURCE);
$isRectorProject = $source === [];

View File

@ -2,15 +2,15 @@
declare(strict_types=1);
namespace Rector\Utils\DocumentationGenerator\OutputFormatter\DumpRectors;
namespace Rector\DocumentationGenerator\OutputFormatter;
use Nette\Utils\Strings;
use Rector\ConsoleDiffer\MarkdownDifferAndFormatter;
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\Contract\RectorDefinition\CodeSampleInterface;
use Rector\Core\RectorDefinition\ConfiguredCodeSample;
use Rector\DocumentationGenerator\RectorMetadataResolver;
use Rector\PHPUnit\TestClassResolver\TestClassResolver;
use Rector\Utils\DocumentationGenerator\RectorMetadataResolver;
use ReflectionClass;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Yaml\Yaml;
@ -68,7 +68,7 @@ final class MarkdownDumpRectorsOutputFormatter
$this->printRectorsWithHeadline($packageRectors, 'Projects');
$this->printRectorsWithHeadline($generalRectors, 'General');
} else {
$this->printRectors($packageRectors);
$this->printRectors($packageRectors, $isRectorProject);
}
}
@ -105,10 +105,15 @@ final class MarkdownDumpRectorsOutputFormatter
$this->symfonyStyle->newLine();
}
private function printRector(RectorInterface $rector): void
private function printRector(RectorInterface $rector, bool $isRectorProject): void
{
$headline = $this->getRectorClassWithoutNamespace($rector);
$this->symfonyStyle->writeln(sprintf('### `%s`', $headline));
if ($isRectorProject) {
$this->symfonyStyle->writeln(sprintf('### `%s`', $headline));
} else {
$this->symfonyStyle->writeln(sprintf('## `%s`', $headline));
}
$rectorClass = get_class($rector);
@ -237,23 +242,28 @@ final class MarkdownDumpRectorsOutputFormatter
$this->symfonyStyle->writeln('## ' . $headline);
$this->symfonyStyle->newLine();
$this->printRectors($rectors);
$this->printRectors($rectors, true);
}
/**
* @param RectorInterface[] $rectors
*/
private function printRectors(array $rectors): void
private function printRectors(array $rectors, bool $isRectorProject): void
{
$groupedRectors = $this->groupRectorsByPackage($rectors);
$this->printGroupsMenu($groupedRectors);
if ($isRectorProject) {
$this->printGroupsMenu($groupedRectors);
}
foreach ($groupedRectors as $group => $rectors) {
$this->symfonyStyle->writeln('## ' . $group);
$this->symfonyStyle->newLine();
if ($isRectorProject) {
$this->symfonyStyle->writeln('## ' . $group);
$this->symfonyStyle->newLine();
}
foreach ($rectors as $rector) {
$this->printRector($rector);
$this->printRector($rector, $isRectorProject);
}
}
}

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\Utils\DocumentationGenerator;
namespace Rector\DocumentationGenerator;
use Nette\Utils\Strings;

View File

@ -11,8 +11,8 @@ use Rector\ChangesReporting\Output\CheckstyleOutputFormatter;
use Rector\ChangesReporting\Output\JsonOutputFormatter;
use Rector\Core\Configuration\Configuration;
use Rector\Core\Exception\Configuration\InvalidConfigurationException;
use Rector\DocumentationGenerator\Command\DumpRectorsCommand;
use Rector\Utils\DocumentationGenerator\Command\DumpNodesCommand;
use Rector\Utils\DocumentationGenerator\Command\DumpRectorsCommand;
use Symfony\Component\Console\Application as SymfonyApplication;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputDefinition;

View File

@ -100,7 +100,7 @@ use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\PhpParser\Printer\BetterStandardPrinter;
use Rector\Utils\DocumentationGenerator\Node\NodeClassProvider;
use Rector\Utils\DocumentationGenerator\Node\NodeInfoResult;
use Rector\Utils\DocumentationGenerator\OutputFormatter\DumpNodes\MarkdownDumpNodesOutputFormatter;
use Rector\Utils\DocumentationGenerator\OutputFormatter\MarkdownDumpNodesOutputFormatter;
use Rector\Utils\DocumentationGenerator\ValueObject\NodeInfo;
use ReflectionClass;
use ReflectionMethod;

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\Utils\DocumentationGenerator\OutputFormatter\DumpNodes;
namespace Rector\Utils\DocumentationGenerator\OutputFormatter;
use Nette\Utils\Strings;
use Rector\Utils\DocumentationGenerator\Node\NodeInfoResult;