Skip to content

Commit 8da6282

Browse files
authored
doc(README): added HelperCoders usage (#38)
1 parent e256e12 commit 8da6282

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MetaCodable
22

3-
[![API Docs](http://img.shields.io/badge/Read_the-docs-2196f3.svg)](https://swiftylab.github.io/MetaCodable/documentation/metacodable/)
3+
[![API Docs](http://img.shields.io/badge/Read_the-docs-2196f3.svg)](https://swiftpackageindex.com/SwiftyLab/MetaCodable/main/documentation/metacodable)
44
[![Swift Package Manager Compatible](https://img.shields.io/github/v/tag/SwiftyLab/MetaCodable?label=SPM&color=orange)](https://badge.fury.io/gh/SwiftyLab%2FMetaCodable)
55
[![Swift](https://img.shields.io/badge/Swift-5.9+-orange)](https://img.shields.io/badge/Swift-5-DE5D43)
66
[![Platforms](https://img.shields.io/badge/Platforms-all-sucess)](https://img.shields.io/badge/Platforms-all-sucess)
@@ -21,7 +21,7 @@ Supercharge `Swift`'s `Codable` implementations with macros.
2121
- Allows to create flattened model for nested `CodingKey` values with ``CodedAt(_:)`` and ``CodedIn(_:)``.
2222
- Allows to create composition of multiple `Codable` types with ``CodedAt(_:)`` passing no arguments.
2323
- Allows to provide default value in case of decoding failures with ``Default(_:)``.
24-
- Allows to create custom decoding/encoding strategies with ``HelperCoder`` and using them with ``CodedBy(_:)``. i.e. ``LossySequenceCoder`` etc.
24+
- Allows to create custom decoding/encoding strategies with ``HelperCoder`` and using them with ``CodedBy(_:)``. i.e. ``LossySequenceCoder`` and types from ``HelperCoders`` module.
2525
- Allows to ignore specific properties from decoding/encoding with ``IgnoreCoding()``, ``IgnoreDecoding()`` and ``@IgnoreEncoding()``.
2626
- Allows to use camel-case names for variables according to [Swift API Design Guidelines](https://www.swift.org/documentation/api-design-guidelines/#general-conventions), while enabling a type to work with different case style keys with ``CodingKeys(_:)``.
2727
- Allows to ignore all initialized properties of a type from decoding/encoding with ``IgnoreCodingInitialized()`` unless explicitly asked to decode/encode by attaching any coding attributes, i.e. ``CodedIn(_:)``, ``CodedAt(_:)``,
@@ -219,7 +219,23 @@ init(field: String = "some") {
219219

220220
</details>
221221

222-
See the full [documentation](https://swiftylab.github.io/MetaCodable/documentation/metacodable/) for API details and advanced use cases.
222+
<details>
223+
<summary>Use or create custom helpers to provide custom decoding/encoding.</summary>
224+
225+
Library provides following helpers that address common custom decoding/encoding needs:
226+
227+
- `LossySequenceCoder` to decode only valid data while ignopring invalid data in a sequence, instead of traditional way of failing decoding entirely.
228+
- `ValueCoder` to decode `Bool`, `Int`, `Double`, `String` etc. basic types even if they are represented in some other type, i.e decoding `Int` from `"1"`, decoding boolean from `"yes"` etc.
229+
- Custom Date decoding/encoding with UNIX timestamp (`Since1970DateCoder`) or date formatters (`DateCoder`, `ISO8601DateCoder`).
230+
- `Base64Coder` to decode/encode data in base64 string representation.
231+
232+
And more, see the full documentation for [`HelperCoders`](https://swiftpackageindex.com/SwiftyLab/MetaCodable/main/documentation/helpercoders) for more deatils.
233+
234+
You can even create your own by conforming to `HelperCoder`.
235+
236+
</details>
237+
238+
See the full documentation for [`MetaCodable`](https://swiftpackageindex.com/SwiftyLab/MetaCodable/main/documentation/metacodable) and [`HelperCoders`](https://swiftpackageindex.com/SwiftyLab/MetaCodable/main/documentation/helpercoders), for API details and advanced use cases.
223239

224240
## Contributing
225241

Sources/HelperCoders/PropertyWrapperCoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MetaCodable
55
///
66
/// This type can be used to reuse existing property
77
/// wrappers with custom decoding/encoding with
8-
/// ``MetaCodable`` generated implementations.
8+
/// ``/MetaCodable`` generated implementations.
99
public struct PropertyWrapperCoder<Wrapper: PropertyWrappable>: HelperCoder {
1010
/// Creates a new instance of ``/MetaCodable/HelperCoder`` that decodes/encodes
1111
/// using existing property wrappers.

Sources/MetaCodable/HelperCoders/HelperCoder.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,14 @@ public extension HelperCoder {
218218
try self.encode(value, to: encoder)
219219
}
220220

221-
/// Encodes given value of the ``Coded`` type to the provided `container`
221+
/// Encodes given value of the ``HelperCoder/Coded`` type to the provided `container`
222222
/// at the specified `key`.
223223
///
224-
/// By default, of the ``Coded`` value confirms to `Encodable`, then
224+
/// By default, of the ``HelperCoder/Coded`` value confirms to `Encodable`, then
225225
/// encoding is performed. Otherwise no data written to the encoder.
226226
///
227227
/// - Parameters:
228-
/// - value: The ``Coded`` value to encode.
228+
/// - value: The ``HelperCoder/Coded`` value to encode.
229229
/// - container: The container to write data to.
230230
/// - key: The key to write data at.
231231
///
@@ -239,14 +239,14 @@ public extension HelperCoder {
239239
try self.encode(value, to: container.superEncoder(forKey: key))
240240
}
241241

242-
/// Encodes given optional value of the ``Coded`` type to the provided
242+
/// Encodes given optional value of the ``HelperCoder/Coded`` type to the provided
243243
/// `container` at the specified `key`, if it is not `nil`.
244244
///
245-
/// By default, of the ``Coded`` value confirms to `Encodable`, then
245+
/// By default, of the ``HelperCoder/Coded`` value confirms to `Encodable`, then
246246
/// encoding is performed. Otherwise no data written to the encoder.
247247
///
248248
/// - Parameters:
249-
/// - value: The optional ``Coded`` value to encode.
249+
/// - value: The optional ``HelperCoder/Coded`` value to encode.
250250
/// - container: The container to write data to.
251251
/// - key: The key to write data at.
252252
///

0 commit comments

Comments
 (0)