Skip to content

Commit

Permalink
refactor(documentator)!: Instruction templates reorganization.
Browse files Browse the repository at this point in the history
  • Loading branch information
LastDragon-ru committed Jan 18, 2024
1 parent 9c8a066 commit f4a00ee
Show file tree
Hide file tree
Showing 13 changed files with 11 additions and 10 deletions.
2 changes: 2 additions & 0 deletions packages/documentator/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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\<name>\Instruction` namespace.

* [ ] If you are extending built-in templates, they were renamed from `markdown.blade.php` to `default.blade.php`.
2 changes: 1 addition & 1 deletion packages/documentator/src/Commands/Commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
Expand Down
2 changes: 1 addition & 1 deletion packages/documentator/src/Commands/Requirements.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct(
* @var array<array-key, string|int>|string|int|null
*/
public readonly array|string|int|null $depth = 0,
public readonly ?string $template = null,
public readonly string $template = 'default',
) {
// empty
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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'],
];
}
// </editor-fold>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Parameters implements Serializable {
public function __construct(
public readonly ?string $template = null,
public readonly string $template = 'default',
) {
// empty
}
Expand Down

0 comments on commit f4a00ee

Please sign in to comment.