Skip to content

Commit 106c297

Browse files
committed
feat: update documentation
1 parent 6b149c5 commit 106c297

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ targets: [
230230
[available-strategies]: https://swiftpackageindex.com/pointfreeco/swift-snapshot-testing/main/documentation/snapshottesting/snapshotting
231231
[defining-strategies]: https://swiftpackageindex.com/pointfreeco/swift-snapshot-testing/main/documentation/snapshottesting/customstrategies
232232

233-
## Plug-ins
233+
## Strategies / Plug-ins
234234

235235
- [AccessibilitySnapshot](https://github.com/cashapp/AccessibilitySnapshot) adds easy regression
236236
testing for iOS accessibility.
@@ -273,6 +273,18 @@ targets: [
273273
- [SnapshotVision](https://github.com/gregersson/swift-snapshot-testing-vision) adds snapshot
274274
strategy for text recognition on views and images. Uses Apples Vision framework.
275275

276+
- [ImageSerializer HEIC](https://github.com/mackoj/swift-snapshot-testing-plugin-heic) make all the
277+
strategy that create image as output to store them in `.heic` storage format which reduces file sizes
278+
in comparison to PNG.
279+
280+
- [ImageSerializer WEBP](https://github.com/mackoj/swift-snapshot-testing-plugin-heic) make all the
281+
strategy that create image as output to store them in `.webp` storage format which reduces file sizes
282+
in comparison to PNG.
283+
284+
- [ImageSerializer JXL](https://github.com/mackoj/swift-snapshot-testing-plugin-heic) make all the
285+
strategy that create image as output to store them in `.jxl` storage format which reduces file sizes
286+
in comparison to PNG.
287+
276288
Have you written your own SnapshotTesting plug-in?
277289
[Add it here](https://github.com/pointfreeco/swift-snapshot-testing/edit/master/README.md) and
278290
submit a pull request!
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Plugins
2+
3+
SnapshotTesting offers a wide range of built-in snapshot strategies, and over the years, third-party developers have introduced new ones. However, when there’s a need for functionality that spans multiple strategies, plugins become essential.
4+
5+
## Overview
6+
7+
Plugins provide greater flexibility and extensibility by enabling shared behavior across different strategies without the need to duplicate code or modify each strategy individually. They can be dynamically discovered, registered, and executed at runtime, making them ideal for adding new functionality without altering the core system. This architecture promotes modularity and decoupling, allowing features to be easily added or swapped out without impacting existing functionality.
8+
9+
### Plugin architecture
10+
11+
The plugin architecture is designed around the concept of **dynamic discovery and registration**. Plugins conform to specific protocols, such as `SnapshotTestingPlugin`, and are registered automatically by the `PluginRegistry`. This registry manages plugin instances, allowing them to be retrieved by identifier or filtered by the protocols they conform to.
12+
13+
The primary components of the plugin system include:
14+
15+
- **Plugin Protocols**: Define the behavior that plugins must implement.
16+
- **PluginRegistry**: Manages plugin discovery, registration, and retrieval.
17+
- **Objective-C Runtime Integration**: Allows automatic discovery of plugins that conform to specific protocols.
18+
19+
The `PluginRegistry` is a singleton that registers plugins during its initialization. Plugins can be retrieved by their identifier or cast to specific types, allowing flexible interaction.
20+
21+
## ImageSerializer
22+
23+
The `ImageSerializer` is a plugin-based system that provides support for encoding and decoding images. It leverages the plugin architecture to extend its support for different image formats without needing to modify the core system.
24+
25+
Plugins that conform to the `ImageSerializationPlugin` protocol can be registered into the `PluginRegistry` and used to encode or decode images in different formats, such as PNG, JPEG, WebP, HEIC, and more.
26+
27+
When a plugin supporting a specific image format is available, the `ImageSerializer` can dynamically choose the correct plugin based on the image format required, ensuring modularity and scalability in image handling.

Sources/SnapshotTesting/Documentation.docc/SnapshotTesting.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Powerfully flexible snapshot testing.
2323
- ``withSnapshotTesting(record:diffTool:operation:)-2kuyr``
2424
- ``SnapshotTestingConfiguration``
2525

26+
### Plugins
27+
28+
- <doc:Plugins>
29+
2630
### Deprecations
2731

2832
- <doc:SnapshotTestingDeprecations>

0 commit comments

Comments
 (0)