Skip to content

Commit

Permalink
feat(documentator)!: Markdown Document mutations (#180)
Browse files Browse the repository at this point in the history
Further improvements of #179. Added mutation concept and few useful mutations:

- `FootnotesPrefix` - Adds unique prefix for all footnotes.
- `FootnotesRemove` - Removes all footnotes.
- `Move` - Changes path and updates all relative links.
- `ReferencesInline` - Inlines all references.
- `ReferencesPrefix` - Adds unique prefix for all references.
  • Loading branch information
LastDragon-ru authored Aug 13, 2024
2 parents cbb7458 + dcf573d commit 0e2b70d
Show file tree
Hide file tree
Showing 35 changed files with 2,108 additions and 684 deletions.
14 changes: 14 additions & 0 deletions packages/documentator/src/Markdown/Contracts/Mutation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php declare(strict_types = 1);

namespace LastDragon_ru\LaraASP\Documentator\Markdown\Contracts;

use LastDragon_ru\LaraASP\Documentator\Markdown\Document;
use LastDragon_ru\LaraASP\Documentator\Markdown\Location\Location;
use League\CommonMark\Node\Block\Document as DocumentNode;

interface Mutation {
/**
* @return array<array-key, array{Location, ?string}>
*/
public function __invoke(Document $document, DocumentNode $node): array;
}
22 changes: 22 additions & 0 deletions packages/documentator/src/Markdown/Data/BlockPadding.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php declare(strict_types = 1);

namespace LastDragon_ru\LaraASP\Documentator\Markdown\Data;

use Override;

/**
* @internal
* @implements Value<int>
*/
readonly class BlockPadding implements Value {
public function __construct(
private int $value,
) {
// empty
}

#[Override]
public function get(): mixed {
return $this->value;
}
}
22 changes: 22 additions & 0 deletions packages/documentator/src/Markdown/Data/Length.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php declare(strict_types = 1);

namespace LastDragon_ru\LaraASP\Documentator\Markdown\Data;

use Override;

/**
* @internal
* @implements Value<int>
*/
readonly class Length implements Value {
public function __construct(
private int $value,
) {
// empty
}

#[Override]
public function get(): mixed {
return $this->value;
}
}
Loading

0 comments on commit 0e2b70d

Please sign in to comment.