mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 05:18:18 +01:00
[Docs] Improve rule doc generator to generat rules_overview with categories (#4688)
* numbers * update ECS config to Symplify 9 * regenerate rules with categorize * [CI] disable automated rebase, as not working propperly * update misc
This commit is contained in:
parent
e8553cd647
commit
0456cc088c
25
.github/workflows/automated_rebase.yaml
vendored
25
.github/workflows/automated_rebase.yaml
vendored
@ -1,25 +0,0 @@
|
||||
name: Automatic Rebase
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# every 5 minutes, https://crontab.guru/#0/10_*_*_*_*
|
||||
- cron: 0/5 * * * *
|
||||
|
||||
jobs:
|
||||
automated_rebase:
|
||||
if: github.event.issue.pull_request != ''
|
||||
|
||||
name: Rebase
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
-
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# see https://github.com/cirrus-actions/rebase
|
||||
-
|
||||
uses: cirrus-actions/rebase@1.3.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
@ -1,4 +1,4 @@
|
||||
name: Monorepo Split Packages
|
||||
name: Split Monorepo
|
||||
|
||||
on:
|
||||
push:
|
||||
@ -6,7 +6,7 @@ on:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
monorepo_split_packages:
|
||||
split_monorepo:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
|
@ -243,6 +243,7 @@
|
||||
"Rector\\Order\\Tests\\": "rules/order/tests",
|
||||
"Rector\\PHPOffice\\Tests\\": "rules/php-office/tests",
|
||||
"Rector\\PHPStanExtensions\\": "utils/phpstan-extensions/src",
|
||||
"Rector\\RuleDocGenerator\\": "utils/rule-doc-generator/src",
|
||||
"Rector\\PHPStanExtensions\\Tests\\": "utils/phpstan-extensions/tests",
|
||||
"Rector\\PHPStanStaticTypeMapper\\Tests\\": "packages/phpstan-static-type-mapper/tests",
|
||||
"Rector\\PHPStan\\Tests\\": "rules/phpstan/tests",
|
||||
@ -316,7 +317,7 @@
|
||||
"vendor/bin/changelog-linker cleanup --ansi"
|
||||
],
|
||||
"docs": [
|
||||
"vendor/bin/rule-doc-generator generate packages rules --output-file docs/rector_rules_overview.md --ansi",
|
||||
"vendor/bin/rule-doc-generator generate packages rules --output-file docs/rector_rules_overview.md --ansi --categorize",
|
||||
"bin/rector dump-nodes --output-file docs/nodes_overview.md --ansi",
|
||||
"vendor/bin/ecs check-markdown docs/rector_rules_overview.md docs/nodes_overview.md --ansi --fix"
|
||||
],
|
||||
|
File diff suppressed because it is too large
Load Diff
22
ecs.php
22
ecs.php
@ -66,7 +66,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
SetList::CLEAN_CODE,
|
||||
]);
|
||||
|
||||
$parameters->set(Option::EXCLUDE_PATHS, [
|
||||
$parameters->set(Option::SKIP, [
|
||||
'*/Source/*',
|
||||
'*/Fixture/*',
|
||||
'*/Expected/*',
|
||||
@ -74,14 +74,13 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
__DIR__ . '/packages/doctrine-annotation-generated/src/ConstantPreservingDocParser.php',
|
||||
__DIR__ . '/packages/doctrine-annotation-generated/src/ConstantPreservingAnnotationReader.php',
|
||||
// template files
|
||||
__DIR__ . '/packages/rector-generator/templates/*',
|
||||
]);
|
||||
__DIR__ . '/packages/rector-generator/templates',
|
||||
|
||||
$parameters->set(Option::SKIP, [
|
||||
// broken
|
||||
UnusedVariableSniff::class => null,
|
||||
GlobalNamespaceImportFixer::class => null,
|
||||
MethodDeclarationSniff::class . '.Underscore' => null,
|
||||
UnusedVariableSniff::class,
|
||||
GlobalNamespaceImportFixer::class,
|
||||
MethodDeclarationSniff::class . '.Underscore',
|
||||
|
||||
PhpdocTypesFixer::class => [__DIR__ . '/rules/php74/src/Rector/Double/RealToFloatTypeCastRector.php'],
|
||||
CommentedOutCodeSniff::class . '.Found' => [
|
||||
__DIR__ . '/rules/php72/src/Rector/Assign/ListEachRector.php',
|
||||
@ -93,12 +92,13 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
__DIR__ . '/tests/PhpParser/Node/NodeFactoryTest.php',
|
||||
'*TypeResolverTest.php',
|
||||
],
|
||||
UnaryOperatorSpacesFixer::class => null,
|
||||
UnaryOperatorSpacesFixer::class,
|
||||
// breaks on-purpose annotated variables
|
||||
ReturnAssignmentFixer::class => null,
|
||||
ReturnAssignmentFixer::class,
|
||||
// buggy with specific markdown snippet file in docs/rules_overview.md
|
||||
ArrayListItemNewlineFixer::class => null,
|
||||
BlankLineAfterOpeningTagFixer::class => null,
|
||||
ArrayListItemNewlineFixer::class,
|
||||
BlankLineAfterOpeningTagFixer::class,
|
||||
|
||||
StrictComparisonFixer::class => [__DIR__ . '/rules/polyfill/src/ConditionEvaluator.php'],
|
||||
|
||||
// bugged for some reason
|
||||
|
@ -16,7 +16,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
// name, basically short class name; use PascalCase
|
||||
'RenameMethodCallRector',
|
||||
|
||||
// particular node types to change
|
||||
// 1+ node types to change, pick from classes here https://github.com/nikic/PHP-Parser/tree/master/lib/PhpParser/Node
|
||||
// the best practise is to have just 1 type here if possible, and make separated rule for other node types
|
||||
[MethodCall::class],
|
||||
|
||||
|
14
rule-doc-generator.php
Normal file
14
rule-doc-generator.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\RuleDocGenerator\Category\RectorCategoryInferer;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->defaults()
|
||||
->autowire();
|
||||
|
||||
$services->set(RectorCategoryInferer::class);
|
||||
};
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\RuleDocGenerator\Category;
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Symplify\RuleDocGenerator\Contract\Category\CategoryInfererInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
||||
final class RectorCategoryInferer implements CategoryInfererInterface
|
||||
{
|
||||
/**
|
||||
* @see https://regex101.com/r/wyW01F/1
|
||||
* @var string
|
||||
*/
|
||||
private const RECTOR_CATEGORY_REGEX = '#Rector\\\\(?<category>\w+)\\\\#';
|
||||
|
||||
public function infer(RuleDefinition $ruleDefinition): ?string
|
||||
{
|
||||
$matches = Strings::match($ruleDefinition->getRuleClass(), self::RECTOR_CATEGORY_REGEX);
|
||||
if (! isset($matches['category'])) {
|
||||
$message = sprintf('Category for "%s" could not be resolved', $ruleDefinition->getRuleClass());
|
||||
throw new ShouldNotHappenException($message);
|
||||
}
|
||||
|
||||
return $matches['category'];
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user