From f4a00ee94748db6802b23cec0ea82282782cf42f Mon Sep 17 00:00:00 2001 From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com> Date: Thu, 18 Jan 2024 09:35:49 +0400 Subject: [PATCH] refactor(documentator)!: Instruction templates reorganization. --- packages/documentator/UPGRADE.md | 2 ++ .../commands/{markdown.blade.php => default.blade.php} | 0 .../{markdown.blade.php => default.blade.php} | 0 .../package-list/{markdown.blade.php => default.blade.php} | 0 .../requirements/{markdown.blade.php => default.blade.php} | 0 packages/documentator/src/Commands/Commands.php | 2 +- packages/documentator/src/Commands/Requirements.php | 2 +- .../Instructions/IncludeDocumentList/Instruction.php | 2 +- .../Instructions/IncludeDocumentList/Parameters.php | 2 +- .../Instructions/IncludePackageList/Instruction.php | 2 +- .../Instructions/IncludePackageList/InstructionTest.php | 7 +++---- ...tructionTest~markdown.md => InstructionTest~default.md} | 0 .../Instructions/IncludePackageList/Parameters.php | 2 +- 13 files changed, 11 insertions(+), 10 deletions(-) rename packages/documentator/defaults/views/commands/{markdown.blade.php => default.blade.php} (100%) rename packages/documentator/defaults/views/document-list/{markdown.blade.php => default.blade.php} (100%) rename packages/documentator/defaults/views/package-list/{markdown.blade.php => default.blade.php} (100%) rename packages/documentator/defaults/views/requirements/{markdown.blade.php => default.blade.php} (100%) rename packages/documentator/src/Preprocessor/Instructions/IncludePackageList/{InstructionTest~markdown.md => InstructionTest~default.md} (100%) diff --git a/packages/documentator/UPGRADE.md b/packages/documentator/UPGRADE.md index 286271276..1b8d07895 100644 --- a/packages/documentator/UPGRADE.md +++ b/packages/documentator/UPGRADE.md @@ -42,3 +42,5 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases) * [ ] Use [`Illuminate\Support\Facades\Process`](https://laravel.com/docs/processes) instead of `LastDragon_ru\LaraASP\Documentator\Utils\Process`. * [ ] If you are extending built-in instructions, their classes were moved to `LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\\Instruction` namespace. + +* [ ] If you are extending built-in templates, they were renamed from `markdown.blade.php` to `default.blade.php`. diff --git a/packages/documentator/defaults/views/commands/markdown.blade.php b/packages/documentator/defaults/views/commands/default.blade.php similarity index 100% rename from packages/documentator/defaults/views/commands/markdown.blade.php rename to packages/documentator/defaults/views/commands/default.blade.php diff --git a/packages/documentator/defaults/views/document-list/markdown.blade.php b/packages/documentator/defaults/views/document-list/default.blade.php similarity index 100% rename from packages/documentator/defaults/views/document-list/markdown.blade.php rename to packages/documentator/defaults/views/document-list/default.blade.php diff --git a/packages/documentator/defaults/views/package-list/markdown.blade.php b/packages/documentator/defaults/views/package-list/default.blade.php similarity index 100% rename from packages/documentator/defaults/views/package-list/markdown.blade.php rename to packages/documentator/defaults/views/package-list/default.blade.php diff --git a/packages/documentator/defaults/views/requirements/markdown.blade.php b/packages/documentator/defaults/views/requirements/default.blade.php similarity index 100% rename from packages/documentator/defaults/views/requirements/markdown.blade.php rename to packages/documentator/defaults/views/requirements/default.blade.php diff --git a/packages/documentator/src/Commands/Commands.php b/packages/documentator/src/Commands/Commands.php index 6b426cdd4..2ea9bbd93 100644 --- a/packages/documentator/src/Commands/Commands.php +++ b/packages/documentator/src/Commands/Commands.php @@ -86,7 +86,7 @@ static function () use ( // Render $name = Str::after((string) $command->getName(), "{$namespace}:"); $path = Path::getPath($target, "{$name}.md"); - $content = $viewer->render('commands.markdown', [ + $content = $viewer->render('commands.default', [ 'serializer' => $serializer, 'command' => $command, ]); diff --git a/packages/documentator/src/Commands/Requirements.php b/packages/documentator/src/Commands/Requirements.php index 99ba5b612..6d66d7a3f 100644 --- a/packages/documentator/src/Commands/Requirements.php +++ b/packages/documentator/src/Commands/Requirements.php @@ -145,7 +145,7 @@ public function __invoke(PackageViewer $viewer, Git $git, Serializer $serializer $requirements = $this->getRequirements($packages, $metadata); // Render - $output = $viewer->render('requirements.markdown', [ + $output = $viewer->render('requirements.default', [ 'packages' => $packages, 'requirements' => $requirements, ]); diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php index 9314b556c..582b7d573 100644 --- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php +++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php @@ -122,7 +122,7 @@ public function process(string $path, string $target, Serializable $parameters): }); // Render - $template = 'document-list.'.($parameters->template ?: 'markdown'); + $template = "document-list.{$parameters->template}"; $list = $this->viewer->render($template, [ 'documents' => $documents, ]); diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Parameters.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Parameters.php index a20980785..9452a9286 100644 --- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Parameters.php +++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Parameters.php @@ -12,7 +12,7 @@ public function __construct( * @var array|string|int|null */ public readonly array|string|int|null $depth = 0, - public readonly ?string $template = null, + public readonly string $template = 'default', ) { // empty } diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php index bcd462293..cd96ed0a2 100644 --- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php +++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php @@ -141,7 +141,7 @@ public function process(string $path, string $target, Serializable $parameters): }); // Render - $template = 'package-list.'.($parameters->template ?: 'markdown'); + $template = "package-list.{$parameters->template}"; $list = $this->viewer->render($template, [ 'packages' => $packages, ]); diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php index 0de6863d4..2ea6eca43 100644 --- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php +++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php @@ -21,7 +21,7 @@ final class InstructionTest extends TestCase { /** * @dataProvider dataProviderProcess */ - public function testProcess(string $expected, ?string $template): void { + public function testProcess(string $expected, string $template): void { $path = self::getTestData()->file('Document.md')->getPathname(); $target = basename(self::getTestData()->path('/packages')); $params = new Parameters(template: $template); @@ -97,9 +97,8 @@ public function testProcessNoTitle(): void { */ public static function dataProviderProcess(): array { return [ - 'no template' => ['~markdown.md', null], - 'markdown' => ['~markdown.md', 'markdown'], - 'upgrade' => ['~upgrade.md', 'upgrade'], + 'default' => ['~default.md', 'default'], + 'upgrade' => ['~upgrade.md', 'upgrade'], ]; } // diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest~markdown.md b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest~default.md similarity index 100% rename from packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest~markdown.md rename to packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest~default.md diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Parameters.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Parameters.php index 681f8a16e..24347b023 100644 --- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Parameters.php +++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Parameters.php @@ -6,7 +6,7 @@ class Parameters implements Serializable { public function __construct( - public readonly ?string $template = null, + public readonly string $template = 'default', ) { // empty }