diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Context.php b/packages/documentator/src/Processor/Tasks/Preprocess/Context.php index 6ec79813..38349d48 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Context.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Context.php @@ -13,6 +13,7 @@ use LastDragon_ru\LaraASP\Documentator\Markdown\Mutations\ReferencesInline; use LastDragon_ru\LaraASP\Documentator\Markdown\Mutations\ReferencesPrefix; use LastDragon_ru\LaraASP\Documentator\Markdown\Mutations\SelfLinksRemove; +use LastDragon_ru\LaraASP\Documentator\Markdown\Nodes\Reference\Block; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; @@ -20,8 +21,8 @@ class Context { public function __construct( public readonly Directory $root, public readonly File $file, - public readonly string $target, - public readonly ?string $parameters, + public readonly Document $document, + public readonly Block $node, private readonly Mutation $mutation, ) { // empty diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Exceptions/ArtisanCommandError.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Exceptions/ArtisanCommandError.php index 3754d227..8b3153e9 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Exceptions/ArtisanCommandError.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Exceptions/ArtisanCommandError.php @@ -17,7 +17,7 @@ public function __construct( $context, sprintf( 'Artisan command `%s` failed (in `%s`).', - $context->target, + $context->node->getDestination(), $context->root->getRelativePath($context->file), ), $previous, diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Exceptions/ArtisanCommandFailed.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Exceptions/ArtisanCommandFailed.php index a5dca2c5..eaa6478f 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Exceptions/ArtisanCommandFailed.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Exceptions/ArtisanCommandFailed.php @@ -18,7 +18,7 @@ public function __construct( $context, sprintf( 'Artisan command `%s` exited with status code `%s` (in `%s`).', - $context->target, + $context->node->getDestination(), $this->result, $context->root->getRelativePath($context->file), ), diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/InstructionTest.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/InstructionTest.php index d47900d9..07a376d2 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/InstructionTest.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/InstructionTest.php @@ -8,7 +8,9 @@ use LastDragon_ru\LaraASP\Core\Application\ApplicationResolver; use LastDragon_ru\LaraASP\Core\Path\DirectoryPath; use LastDragon_ru\LaraASP\Core\Path\FilePath; +use LastDragon_ru\LaraASP\Documentator\Markdown\Document; use LastDragon_ru\LaraASP\Documentator\Markdown\Mutations\Nop; +use LastDragon_ru\LaraASP\Documentator\Markdown\Nodes\Reference\Block; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context; @@ -36,7 +38,7 @@ public function testInvoke(): void { $params = new Parameters('...'); $expected = 'result'; $command = 'command to execute'; - $context = new Context($root, $file, $command, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); $this->override(Kernel::class, static function (MockInterface $mock) use ($command, $expected): void { @@ -82,9 +84,15 @@ static function (InputInterface $input, OutputInterface $output) use ($expected) public function testInvokeFailed(): void { $root = new Directory((new DirectoryPath(__DIR__))->getNormalizedPath(), false); $file = new File((new FilePath(__FILE__))->getNormalizedPath(), false); + $node = new class() extends Block { + #[Override] + public function getDestination(): string { + return 'command to execute'; + } + }; $params = new Parameters('...'); - $command = 'command to execute'; - $context = new Context($root, $file, $command, '{...}', new Nop()); + $command = $node->getDestination(); + $context = new Context($root, $file, new Document(''), $node, new Nop()); $instance = $this->app()->make(Instruction::class); $this->override(Kernel::class, static function (MockInterface $mock) use ($command): void { @@ -140,7 +148,7 @@ public function testGetCommand(): void { $file = new File((new FilePath(__FILE__))->getNormalizedPath(), false); $params = new Parameters('...'); $command = 'artisan:command $directory {$directory} "{$directory}" $file {$file} "{$file}"'; - $context = new Context($root, $file, $command, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = new class (Mockery::mock(ApplicationResolver::class)) extends Instruction { #[Override] public function getCommand(Context $context, string $target, Parameters $parameters): string { diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocBlock/Exceptions/TargetIsNotValidPhpFile.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocBlock/Exceptions/TargetIsNotValidPhpFile.php index 9447ddb2..769f557b 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocBlock/Exceptions/TargetIsNotValidPhpFile.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocBlock/Exceptions/TargetIsNotValidPhpFile.php @@ -14,7 +14,7 @@ public function __construct(Context $context, ?Throwable $previous = null) { $context, sprintf( 'The `%s` is not a valid PHP file (in `%s`).', - $context->target, + $context->node->getDestination(), $context->root->getRelativePath($context->file), ), $previous, diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocBlock/InstructionTest.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocBlock/InstructionTest.php index 6de20089..fe7189da 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocBlock/InstructionTest.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocBlock/InstructionTest.php @@ -7,6 +7,7 @@ use LastDragon_ru\LaraASP\Core\Path\FilePath; use LastDragon_ru\LaraASP\Documentator\Markdown\Document; use LastDragon_ru\LaraASP\Documentator\Markdown\Mutations\Nop; +use LastDragon_ru\LaraASP\Documentator\Markdown\Nodes\Reference\Block; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context; @@ -34,7 +35,7 @@ public function testInvoke(Closure|string $expected, string $file, Parameters $p $root = new Directory($path->getDirectoryPath(), false); $file = new File($path, false); $target = $file->getName(); - $context = new Context($root, $file, $target, null, new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); if ($expected instanceof Closure) { diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocumentList/InstructionTest.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocumentList/InstructionTest.php index c6867b6a..1a7e6689 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocumentList/InstructionTest.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocumentList/InstructionTest.php @@ -3,7 +3,9 @@ namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeDocumentList; use LastDragon_ru\LaraASP\Core\Path\FilePath; +use LastDragon_ru\LaraASP\Documentator\Markdown\Document; use LastDragon_ru\LaraASP\Documentator\Markdown\Mutations\Nop; +use LastDragon_ru\LaraASP\Documentator\Markdown\Nodes\Reference\Block; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context; @@ -25,7 +27,7 @@ public function testInvokeSameDirectory(): void { $file = new File($path, false); $params = new Parameters('...'); $target = './'; - $context = new Context($root, $file, $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); $actual = ProcessorHelper::runInstruction($instance, $context, $target, $params); @@ -45,7 +47,7 @@ public function testInvokeAnotherDirectory(): void { $file = new File($path, false); $params = new Parameters('...'); $target = basename(self::getTestData()->path('/')); - $context = new Context($root, $file, $target, '', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); $actual = ProcessorHelper::runInstruction($instance, $context, $target, $params); @@ -66,7 +68,7 @@ public function testInvokeNestedDirectories(): void { $file = new File($path, false); $params = new Parameters('...', null, order: SortOrder::Desc); $target = './'; - $context = new Context($root, $file, $target, '', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); $actual = ProcessorHelper::runInstruction($instance, $context, $target, $params); diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExample/InstructionTest.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExample/InstructionTest.php index 045b1e02..6492ad02 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExample/InstructionTest.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExample/InstructionTest.php @@ -3,7 +3,9 @@ namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeExample; use LastDragon_ru\LaraASP\Core\Path\FilePath; +use LastDragon_ru\LaraASP\Documentator\Markdown\Document; use LastDragon_ru\LaraASP\Documentator\Markdown\Mutations\Nop; +use LastDragon_ru\LaraASP\Documentator\Markdown\Nodes\Reference\Block; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context; @@ -32,7 +34,7 @@ public function testInvoke(string $expected, string $output): void { $file = new File($path, false); $params = new Parameters('...'); $target = self::getTestData()->path('Example.md'); - $context = new Context($root, $file, $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $this->override(Runner::class, static function (MockInterface $mock) use ($target, $output): void { $mock @@ -58,7 +60,7 @@ public function testInvokeNoRun(): void { $file = new File($path, false); $params = new Parameters('...'); $target = $file->getName(); - $context = new Context($root, $file, $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $expected = trim($file->getContent()); $instance = $this->app()->make(Instruction::class); $actual = ProcessorHelper::runInstruction($instance, $context, $target, $params); diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExec/Exceptions/TargetExecFailed.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExec/Exceptions/TargetExecFailed.php index f93f1348..e93c7be3 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExec/Exceptions/TargetExecFailed.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExec/Exceptions/TargetExecFailed.php @@ -14,7 +14,7 @@ public function __construct(Context $context, ?Throwable $previous = null) { $context, sprintf( 'Failed to execute the `%s` command (in `%s`).', - $context->target, + $context->node->getDestination(), $context->root->getRelativePath($context->file), ), $previous, diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExec/InstructionTest.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExec/InstructionTest.php index 962fdbdc..d80a6634 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExec/InstructionTest.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExec/InstructionTest.php @@ -6,7 +6,9 @@ use Illuminate\Process\PendingProcess; use LastDragon_ru\LaraASP\Core\Path\DirectoryPath; use LastDragon_ru\LaraASP\Core\Path\FilePath; +use LastDragon_ru\LaraASP\Documentator\Markdown\Document; use LastDragon_ru\LaraASP\Documentator\Markdown\Mutations\Nop; +use LastDragon_ru\LaraASP\Documentator\Markdown\Nodes\Reference\Block; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context; @@ -25,7 +27,7 @@ public function testInvoke(): void { $params = new Parameters('...'); $expected = 'result'; $command = 'command to execute'; - $context = new Context($root, $file, $command, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $factory = $this->override(Factory::class, function () use ($command, $expected): Factory { $factory = $this->app()->make(Factory::class); $factory->preventStrayProcesses(); diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeFile/InstructionTest.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeFile/InstructionTest.php index 4d4a9d06..35ad1248 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeFile/InstructionTest.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeFile/InstructionTest.php @@ -6,6 +6,7 @@ use LastDragon_ru\LaraASP\Core\Path\FilePath; use LastDragon_ru\LaraASP\Documentator\Markdown\Document; use LastDragon_ru\LaraASP\Documentator\Markdown\Mutations\Nop; +use LastDragon_ru\LaraASP\Documentator\Markdown\Nodes\Reference\Block; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context; @@ -31,7 +32,7 @@ public function testInvoke(string $expected, string $source): void { $file = new File((new FilePath(__FILE__))->getNormalizedPath(), false); $params = new Parameters('...'); $target = self::getTestData()->path($source); - $context = new Context($root, $file, $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); $expected = self::getTestData()->content($expected); $actual = ProcessorHelper::runInstruction($instance, $context, $target, $params); diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeGraphqlDirective/Exceptions/TargetIsNotDirective.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeGraphqlDirective/Exceptions/TargetIsNotDirective.php index 6c868d89..b2e92336 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeGraphqlDirective/Exceptions/TargetIsNotDirective.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeGraphqlDirective/Exceptions/TargetIsNotDirective.php @@ -14,7 +14,7 @@ public function __construct(Context $context, ?Throwable $previous = null) { $context, sprintf( 'The `%s` is not a directive (in `%s`).', - $context->target, + $context->node->getDestination(), $context->root->getRelativePath($context->file), ), $previous, diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeGraphqlDirective/InstructionTest.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeGraphqlDirective/InstructionTest.php index 318ac7de..368c0a34 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeGraphqlDirective/InstructionTest.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeGraphqlDirective/InstructionTest.php @@ -6,7 +6,9 @@ use GraphQL\Language\Parser; use LastDragon_ru\LaraASP\Core\Path\DirectoryPath; use LastDragon_ru\LaraASP\Core\Path\FilePath; +use LastDragon_ru\LaraASP\Documentator\Markdown\Document; use LastDragon_ru\LaraASP\Documentator\Markdown\Mutations\Nop; +use LastDragon_ru\LaraASP\Documentator\Markdown\Nodes\Reference\Block; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context; @@ -52,7 +54,7 @@ public function testInvoke(): void { $file = Mockery::mock(File::class); $params = new Parameters('...'); $target = '@test'; - $context = new Context($root, $file, $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); $actual = ProcessorHelper::runInstruction($instance, $context, $target, $params); @@ -79,7 +81,7 @@ public function testInvokeNoPrinter(): void { $file = new File((new FilePath(__FILE__))->getNormalizedPath(), false); $params = new Parameters('...'); $target = '@test'; - $context = new Context($root, $file, $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); self::expectExceptionObject( @@ -107,7 +109,7 @@ public function testInvokeNoDirective(): void { $file = new File((new FilePath(__FILE__))->getNormalizedPath(), false); $params = new Parameters('...'); $target = '@test'; - $context = new Context($root, $file, $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); self::expectExceptionObject( @@ -126,7 +128,7 @@ public function testInvokeNoDirectiveResolver(): void { $file = new File((new FilePath(__FILE__))->getNormalizedPath(), false); $params = new Parameters('...'); $target = '@test'; - $context = new Context($root, $file, $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); self::expectExceptionObject( diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludePackageList/InstructionTest.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludePackageList/InstructionTest.php index 7936fca6..5218ac10 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludePackageList/InstructionTest.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludePackageList/InstructionTest.php @@ -3,7 +3,9 @@ namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludePackageList; use LastDragon_ru\LaraASP\Core\Path\FilePath; +use LastDragon_ru\LaraASP\Documentator\Markdown\Document; use LastDragon_ru\LaraASP\Documentator\Markdown\Mutations\Nop; +use LastDragon_ru\LaraASP\Documentator\Markdown\Nodes\Reference\Block; use LastDragon_ru\LaraASP\Documentator\Processor\Dependencies\FileReference; use LastDragon_ru\LaraASP\Documentator\Processor\Exceptions\DependencyNotFound; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; @@ -31,7 +33,7 @@ public function testInvoke(string $expected, string $template, SortOrder $order) $file = new File($path, false); $target = $root->getDirectoryPath('packages'); $params = new Parameters('...', template: $template, order: $order); - $context = new Context($root, $file, (string) $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); $actual = ProcessorHelper::runInstruction($instance, $context, $target, $params); @@ -52,7 +54,7 @@ public function testInvokeNoReadme(): void { $file = new File($path, false); $target = $root->getDirectoryPath('no readme'); $params = new Parameters('...'); - $context = new Context($root, $file, (string) $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); $package = $fs->getDirectory(new Directory($target, false), 'package'); @@ -71,7 +73,7 @@ public function testInvokeEmptyReadme(): void { $file = new File($path, false); $target = $root->getDirectoryPath('empty readme'); $params = new Parameters('...'); - $context = new Context($root, $file, (string) $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); $package = $fs->getDirectory(new Directory($target, false), 'package'); $expected = $fs->getFile($root, 'empty readme/package/README.md'); diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeTemplate/InstructionTest.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeTemplate/InstructionTest.php index f8a4a2d2..55976282 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeTemplate/InstructionTest.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeTemplate/InstructionTest.php @@ -6,6 +6,7 @@ use LastDragon_ru\LaraASP\Core\Path\FilePath; use LastDragon_ru\LaraASP\Documentator\Markdown\Document; use LastDragon_ru\LaraASP\Documentator\Markdown\Mutations\Nop; +use LastDragon_ru\LaraASP\Documentator\Markdown\Nodes\Reference\Block; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context; @@ -37,7 +38,7 @@ public function testInvoke(string $expected, string $source, array $data): void $file = new File((new FilePath(__FILE__))->getNormalizedPath(), false); $params = new Parameters('...', $data); $target = self::getTestData()->path($source); - $context = new Context($root, $file, $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); $expected = self::getTestData()->content($expected); $actual = ProcessorHelper::runInstruction($instance, $context, $target, $params); @@ -56,7 +57,7 @@ public function testInvokeNoData(): void { $file = new File((new FilePath(__FILE__))->getNormalizedPath(), false); $params = new Parameters('...', []); $target = $file->getPath(); - $context = new Context($root, $file, (string) $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); self::expectExceptionObject( @@ -77,7 +78,7 @@ public function testInvokeVariablesUnused(): void { 'd' => 'D', ]); $target = $file->getPath(); - $context = new Context($root, $file, (string) $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); self::expectExceptionObject( @@ -95,7 +96,7 @@ public function testInvokeVariablesMissed(): void { 'a' => 'A', ]); $target = $file->getPath(); - $context = new Context($root, $file, (string) $target, '{...}', new Nop()); + $context = new Context($root, $file, new Document(''), new Block(), new Nop()); $instance = $this->app()->make(Instruction::class); self::expectExceptionObject( diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Task.php b/packages/documentator/src/Processor/Tasks/Preprocess/Task.php index 9dfe5e50..32474ec3 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Task.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Task.php @@ -235,9 +235,7 @@ protected function parse(Directory $root, File $file, Document $document): array } // Parse - $title = $node->getTitle(); - $title = $title !== '' ? $title : null; - $context = new Context($root, $file, $node->getDestination(), $title, $mutation); + $context = new Context($root, $file, $document, $node, $mutation); $parameters = $instruction::getParameters(); $parameters = $this->serializer->deserialize($parameters, $params, 'json'); diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/TaskTest.php b/packages/documentator/src/Processor/Tasks/Preprocess/TaskTest.php index f3bfb3a3..b2ef7724 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/TaskTest.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/TaskTest.php @@ -4,17 +4,14 @@ use LastDragon_ru\LaraASP\Core\Application\ContainerResolver; use LastDragon_ru\LaraASP\Core\Path\FilePath; -use LastDragon_ru\LaraASP\Core\Utils\Cast; use LastDragon_ru\LaraASP\Documentator\Markdown\Document; use LastDragon_ru\LaraASP\Documentator\Markdown\Location\Location; use LastDragon_ru\LaraASP\Documentator\Markdown\Utils; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; -use LastDragon_ru\LaraASP\Documentator\Processor\InstanceList; use LastDragon_ru\LaraASP\Documentator\Processor\Metadata\Markdown; use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Contracts\Instruction; use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Contracts\Parameters; -use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Mutations\InstructionsRemove; use LastDragon_ru\LaraASP\Documentator\Testing\Package\ProcessorHelper; use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase; use LastDragon_ru\LaraASP\Serializer\Contracts\Serializable; @@ -22,7 +19,6 @@ use Mockery; use Override; use PHPUnit\Framework\Attributes\CoversClass; -use ReflectionProperty; use function array_map; use function json_encode; @@ -93,9 +89,6 @@ public function parse(Directory $root, File $file, Document $document): array { $root = Mockery::mock(Directory::class); $file = Mockery::mock(File::class); - $mutation = new InstructionsRemove( - Cast::to(InstanceList::class, (new ReflectionProperty(Task::class, 'instructions'))->getValue($task)), - ); $document = new Document(self::MARKDOWN); $tokens = $task->parse($root, $file, $document); $actual = array_map( @@ -106,7 +99,6 @@ static function (Token $token): array { return [ $token->instruction, - $token->context, $token->target, $token->parameters, $nodes, @@ -123,7 +115,6 @@ static function (Token $token): array { 0 => [ 'bb30809c6ca4c80a' => [ $b, - new Context($root, $file, './path/to/file', null, $mutation), './path/to/file', new TaskTest__Parameters('./path/to/file'), [ @@ -136,13 +127,6 @@ static function (Token $token): array { ], 'f5f55887ee415b3d' => [ $b, - new Context( - $root, - $file, - './path/to/file/parametrized', - '{"a": "aa", "b": {"a": "a", "b": "b"}}', - $mutation, - ), './path/to/file/parametrized', new TaskTest__Parameters( './path/to/file/parametrized', @@ -161,7 +145,6 @@ static function (Token $token): array { PHP_INT_MAX => [ '4f76e5da6e5aabbc' => [ $a, - new Context($root, $file, './path/to/file%20%22value%22', null, $mutation), './path/to/file "value"', new TaskTest__ParametersEmpty('./path/to/file "value"'), [