Skip to content

Commit

Permalink
Merge pull request #87 from neos/task/fix-docs-generator
Browse files Browse the repository at this point in the history
TASK: Repair docs generate
  • Loading branch information
ahaeslich authored Oct 24, 2024
2 parents 8c8acdd + d772964 commit d82472e
Show file tree
Hide file tree
Showing 52 changed files with 951 additions and 182 deletions.
1,041 changes: 939 additions & 102 deletions docs/rules_overview.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/Generic/Rules/FusionPrototypeNameAddCommentRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ class FusionPrototypeNameAddCommentRector implements FusionRectorInterface, Conf

public function getRuleDefinition(): RuleDefinition
{
return CodeSampleLoader::fromFile('Fusion: Add comment to file if prototype name matches at least once.', __CLASS__);
return CodeSampleLoader::fromFile('Fusion: Add comment to file if prototype name matches at least once.', __CLASS__, ['Neos.Neos:Raw', 'Neos.Neos:Raw: Add this comment to top of file.']);
}

public function refactorFileContent(string $fileContent): string
{
$comments = [];
foreach ($this->fusionPrototypeNameAddComments as $fusionPrototypeNameAddComment) {
$matches = [];
$pattern = '/(^|[=\s\(<\/])(' .$fusionPrototypeNameAddComment->name. ')([\s\{\)\/>]|$)/';
$pattern = '/(^|[=\s\(<\/])(' . $fusionPrototypeNameAddComment->name . ')([\s\{\)\/>]|$)/';
preg_match($pattern, $fileContent, $matches);

if (count($matches) > 0) {
$comments[] = "// " . $fusionPrototypeNameAddComment->comment;
}
}

if (count($comments) > 0){
if (count($comments) > 0) {
$fileContent = implode("\n", $comments) . "\n" . $fileContent;
}

Expand Down
12 changes: 6 additions & 6 deletions src/Generic/Rules/FusionReplacePrototypeNameRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FusionReplacePrototypeNameRector implements FusionRectorInterface, Configu

public function getRuleDefinition(): RuleDefinition
{
return CodeSampleLoader::fromFile('Fusion: Rewrite prototype names form e.g Foo.Bar:Boo to Boo.Bar:Foo', __CLASS__);
return CodeSampleLoader::fromFile('Fusion: Rewrite prototype names form e.g Foo.Bar:Boo to Boo.Bar:Foo', __CLASS__, ['Neos.Neos:Raw', 'Neos.Neos:NewRaw', 'Neos.Neos:Raw: This comment should be added on top of the file.']);
}

public function refactorFileContent(string $fileContent): string
Expand All @@ -29,19 +29,19 @@ public function refactorFileContent(string $fileContent): string
foreach ($this->fusionPrototypeNameReplacements as $fusionPrototypeNameReplacement) {
$replacementCount = 0;
if ($fusionPrototypeNameReplacement->skipPrototypeDefinitions) {
$pattern = '/(^|[=\s<\/])(' .$fusionPrototypeNameReplacement->oldName. ')([\s{\/>]|$)/';
$pattern = '/(^|[=\s<\/])(' . $fusionPrototypeNameReplacement->oldName . ')([\s{\/>]|$)/';
} else {
$pattern = '/(^|[=\s(<\/])(' .$fusionPrototypeNameReplacement->oldName. ')([\s{)\/>]|$)/';
$pattern = '/(^|[=\s(<\/])(' . $fusionPrototypeNameReplacement->oldName . ')([\s{)\/>]|$)/';
}
$replacement = '$1'.$fusionPrototypeNameReplacement->newName.'$3';
$replacement = '$1' . $fusionPrototypeNameReplacement->newName . '$3';
$fileContent = preg_replace($pattern, $replacement, $fileContent, count: $replacementCount);

if($replacementCount > 0 && $fusionPrototypeNameReplacement->comment !== null) {
if ($replacementCount > 0 && $fusionPrototypeNameReplacement->comment !== null) {
$comments[] = '// TODO 9.0 migration: ' . $fusionPrototypeNameReplacement->comment;
}
}

if (count($comments) > 0){
if (count($comments) > 0) {
$fileContent = implode("\n", $comments) . "\n" . $fileContent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Neos\Rector\Tests\Generic\Rules\FusionPrototypeNameReplacement;
namespace Neos\Rector\Tests\Generic\Rules\FusionReplacePrototypeNameRector;

use Rector\Testing\PHPUnit\AbstractRectorTestCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Neos\Rector\Tests\Generic\Rules\FusionPrototypeNameReplacement;
namespace Neos\Rector\Tests\Generic\Rules\FusionReplacePrototypeNameRector;

use Rector\Testing\PHPUnit\AbstractRectorTestCase;

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Neos\Rector\Tests\Rules\AnnotationToAttribute;
namespace Neos\Rector\Tests\Rules\AnnotationToAttributeRector;

use Rector\Testing\PHPUnit\AbstractRectorTestCase;

Expand Down

0 comments on commit d82472e

Please sign in to comment.