Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions packages/documentation-generator/config/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
_defaults:
public: true
autowire: true
autoconfigure: true

Rector\DocumentationGenerator\:
resource: '../src'
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,7 +50,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$source = $input->getArgument(Option::SOURCE);
$source = (array) $input->getArgument(Option::SOURCE);

$isRectorProject = $source === [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -68,7 +68,7 @@ public function format(array $packageRectors, array $generalRectors, bool $isRec
$this->printRectorsWithHeadline($packageRectors, 'Projects');
$this->printRectorsWithHeadline($generalRectors, 'General');
} else {
$this->printRectors($packageRectors);
$this->printRectors($packageRectors, $isRectorProject);
}
}

Expand Down Expand Up @@ -105,10 +105,15 @@ private function printGroupsMenu(array $rectorsByGroup): void
$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);

Expand Down Expand Up @@ -237,23 +242,28 @@ private function printRectorsWithHeadline(array $rectors, string $headline): voi
$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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Rector\Utils\DocumentationGenerator;
namespace Rector\DocumentationGenerator;

use Nette\Utils\Strings;

Expand Down
2 changes: 1 addition & 1 deletion src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down