Skip to content

Commit 3f87100

Browse files
authored
doc: added tutorials for helper and dynamic decoding/encoding (#64)
1 parent 5a91b99 commit 3f87100

File tree

124 files changed

+1498
-42
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+1498
-42
lines changed

.github/config/spellcheck-wordlist.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ HelperCoders
99
JSON
1010
LossySequenceCoder
1111
Codable
12+
Encodable
13+
Decodable
1214
MetaCodable
15+
MetaProtocolCodable
1316
Midbin
1417
README
1518
Refactorings
@@ -56,3 +59,6 @@ enums
5659
conformances
5760
Podfile
5861
cocoapods
62+
DocumentationExtension
63+
mergeBehavior
64+
lowercasing

Sources/HelperCoders/Base64Coder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22
import MetaCodable
33

4-
/// An ``/MetaCodable/HelperCoder`` that helps decoding/encoding
4+
/// An `HelperCoder` that helps decoding/encoding
55
/// base64 data.
66
///
77
/// This type can be used to decode/encode base64 data
@@ -12,7 +12,7 @@ public struct Base64Coder: HelperCoder {
1212
/// The options to use when encoding data.
1313
private let encodeOptions: Data.Base64EncodingOptions
1414

15-
/// Creates a new instance of ``/MetaCodable/HelperCoder`` that decodes/encodes
15+
/// Creates a new instance of `HelperCoder` that decodes/encodes
1616
/// base64 data.
1717
///
1818
/// - Parameters:

Sources/HelperCoders/ConditionalCoder.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
11
import MetaCodable
22

3-
/// An ``/MetaCodable/HelperCoder`` that helps decoding/encoding
4-
/// with two separate ``/MetaCodable/HelperCoder``s.
3+
/// An `HelperCoder` that helps decoding/encoding
4+
/// with two separate `HelperCoder`s.
55
///
6-
/// This type can be used to use separate ``/MetaCodable/HelperCoder``s
6+
/// This type can be used to use separate `HelperCoder`s
77
/// for decoding and encoding.
88
public struct ConditionalCoder<D: HelperCoder, E: HelperCoder>: HelperCoder
99
where D.Coded == E.Coded {
10-
/// The ``/MetaCodable/HelperCoder`` used for decoding.
10+
/// The `HelperCoder` used for decoding.
1111
@usableFromInline
1212
internal let decoder: D
13-
/// The ``/MetaCodable/HelperCoder`` used for encoding.
13+
/// The `HelperCoder` used for encoding.
1414
@usableFromInline
1515
internal let encoder: E
1616

17-
/// Creates a new instance of ``/MetaCodable/HelperCoder`` that decodes/encodes
17+
/// Creates a new instance of `HelperCoder` that decodes/encodes
1818
/// conditionally with provided decoder/encoder respectively.
1919
///
2020
/// The provided decoder is used only for decoding
2121
/// and encoder only for encoding.
2222
///
2323
/// - Parameters:
24-
/// - decoder: The ``/MetaCodable/HelperCoder`` used for decoding.
25-
/// - encoder: The ``/MetaCodable/HelperCoder`` used for encoding.
24+
/// - decoder: The `HelperCoder` used for decoding.
25+
/// - encoder: The `HelperCoder` used for encoding.
2626
public init(decoder: D, encoder: E) {
2727
self.decoder = decoder
2828
self.encoder = encoder
2929
}
3030

31-
/// Decodes using the decode specific ``/MetaCodable/HelperCoder``
31+
/// Decodes using the decode specific `HelperCoder`
3232
/// from the given `decoder`.
3333
///
3434
/// - Parameter decoder: The decoder to read data from.
3535
/// - Returns: The decoded value.
36-
/// - Throws: If the underlying ``/MetaCodable/HelperCoder`` throws error.
36+
/// - Throws: If the underlying `HelperCoder` throws error.
3737
@inlinable
3838
public func decode(from decoder: Decoder) throws -> D.Coded {
3939
return try self.decoder.decode(from: decoder)
4040
}
4141

4242
/// Decodes optional value using the decode specific
43-
/// ``/MetaCodable/HelperCoder`` from the given `decoder`.
43+
/// `HelperCoder` from the given `decoder`.
4444
///
4545
/// - Parameter decoder: The decoder to read data from.
4646
/// - Returns: The decoded optional value.
47-
/// - Throws: If the underlying ``/MetaCodable/HelperCoder`` throws error.
47+
/// - Throws: If the underlying `HelperCoder` throws error.
4848
@inlinable
4949
public func decodeIfPresent(from decoder: Decoder) throws -> D.Coded? {
5050
return try self.decoder.decodeIfPresent(from: decoder)
5151
}
5252

53-
/// Encodes using the encode specific ``/MetaCodable/HelperCoder``
53+
/// Encodes using the encode specific `HelperCoder`
5454
/// from the given `encoder`.
5555
///
5656
/// - Parameters:
5757
/// - value: The value to encode.
5858
/// - encoder: The encoder to write data to.
5959
///
60-
/// - Throws: If the underlying ``/MetaCodable/HelperCoder`` throws error.
60+
/// - Throws: If the underlying `HelperCoder` throws error.
6161
@inlinable
6262
public func encode(_ value: E.Coded, to encoder: Encoder) throws {
6363
try self.encoder.encode(value, to: encoder)
6464
}
6565

6666
/// Encodes optional value using the encode specific
67-
/// ``/MetaCodable/HelperCoder`` from the given `encoder`.
67+
/// `HelperCoder` from the given `encoder`.
6868
///
6969
/// - Parameters:
7070
/// - value: The value to encode.
7171
/// - encoder: The encoder to write data to.
7272
///
73-
/// - Throws: If the underlying ``/MetaCodable/HelperCoder`` throws error.
73+
/// - Throws: If the underlying `HelperCoder` throws error.
7474
@inlinable
7575
public func encodeIfPresent(_ value: E.Coded?, to encoder: Encoder) throws {
7676
try self.encoder.encodeIfPresent(value, to: encoder)

Sources/HelperCoders/DateCoders/DateCoder.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import MetaCodable
88
/// represented in **ISO 8601** text format.
99
public typealias ISO8601DateCoder = DateCoder<ISO8601DateFormatter>
1010

11-
/// An ``/MetaCodable/HelperCoder`` that helps decoding/encoding
11+
/// An `HelperCoder` that helps decoding/encoding
1212
/// formatted date representation.
1313
///
1414
/// This type can be used to decode/encode dates
@@ -18,7 +18,7 @@ public struct DateCoder<Formatter: DateFormatConverter>: HelperCoder {
1818
@usableFromInline
1919
internal let formatter: Formatter
2020

21-
/// Creates a new instance of ``/MetaCodable/HelperCoder`` that decodes/encodes
21+
/// Creates a new instance of `HelperCoder` that decodes/encodes
2222
/// formatted date representation.
2323
///
2424
/// Created instance can be used to decode/encode dates
@@ -29,7 +29,7 @@ public struct DateCoder<Formatter: DateFormatConverter>: HelperCoder {
2929
self.formatter = formatter
3030
}
3131

32-
/// Creates a new instance of ``/MetaCodable/HelperCoder`` that decodes/encodes
32+
/// Creates a new instance of `HelperCoder` that decodes/encodes
3333
/// **ISO 8601** formatted date representation.
3434
///
3535
/// Created instance can be used to decode/encode dates

Sources/HelperCoders/DateCoders/Since1970DateCoder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22
import MetaCodable
33

4-
/// An ``/MetaCodable/HelperCoder`` that helps decoding/encoding
4+
/// An `HelperCoder` that helps decoding/encoding
55
/// UNIX timestamp.
66
///
77
/// This type can be used to decode/encode dates
@@ -47,7 +47,7 @@ public struct Since1970DateCoder: HelperCoder {
4747
@usableFromInline
4848
internal let type: IntervalType
4949

50-
/// Creates a new instance of ``/MetaCodable/HelperCoder`` that decodes/encodes
50+
/// Creates a new instance of `HelperCoder` that decodes/encodes
5151
/// UNIX timestamp.
5252
///
5353
/// Created instance can be used to decode/encode dates

Sources/HelperCoders/HelperCoders.docc/HelperCoders.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@Available(swift, introduced: "5.9")
55
}
66

7-
Level up ``/MetaCodable``'s generated implementations with helpers assisting common decoding/encoding requirements.
7+
Level up `MetaCodable`'s generated implementations with helpers assisting common decoding/encoding requirements.
88

99
## Overview
1010

Sources/HelperCoders/NonConformingCoder.swift

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

3-
/// An ``/MetaCodable/HelperCoder`` that helps decoding/encoding
3+
/// An `HelperCoder` that helps decoding/encoding
44
/// non-confirming floating point values.
55
///
66
/// This type can be used to decode/encode exceptional
@@ -14,7 +14,7 @@ where Float: FloatingPoint & Codable & LosslessStringConvertible {
1414
/// The value representing not-a-number.
1515
private let nan: String
1616

17-
/// Creates a new instance of ``/MetaCodable/HelperCoder`` that decodes/encodes
17+
/// Creates a new instance of `HelperCoder` that decodes/encodes
1818
/// exceptional floating-point values matching provided
1919
/// string representations.
2020
///

Sources/HelperCoders/PropertyWrapperCoder.swift

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

3-
/// An ``/MetaCodable/HelperCoder`` that helps decoding/encoding
3+
/// An `HelperCoder` that helps decoding/encoding
44
/// using existing property wrappers.
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 {
10-
/// Creates a new instance of ``/MetaCodable/HelperCoder`` that decodes/encodes
10+
/// Creates a new instance of `HelperCoder` that decodes/encodes
1111
/// using existing property wrappers.
1212
///
1313
/// - Returns: A new property wrapper based decoder/encoder.

Sources/HelperCoders/SequenceCoder/DefaultSequenceElementCoding.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import MetaCodable
22

3-
/// An ``/MetaCodable/HelperCoder`` that performs default decoding/encoding.
3+
/// An `HelperCoder` that performs default decoding/encoding.
44
///
55
/// This type doesn't provide any customization and used only to opt out of
66
/// decoding/encoding customizations.

Sources/HelperCoders/SequenceCoder/SequenceCoder.swift

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

3-
/// An ``/MetaCodable/HelperCoder`` that helps decoding/encoding sequence.
3+
/// An `HelperCoder` that helps decoding/encoding sequence.
44
///
55
/// This type tries to decode and encode a sequence according to provided
6-
/// ``Configuration-swift.struct`` and element ``/MetaCodable/HelperCoder``.
6+
/// ``Configuration-swift.struct`` and element `HelperCoder`.
77
///
88
/// `DefaultSequenceElementCoding` can be used as element
9-
/// ``/MetaCodable/HelperCoder``, if on configuration based.
9+
/// `HelperCoder`, if on configuration based.
1010
/// decoding/encoding needed
1111
public struct SequenceCoder<Sequence, ElementHelper>: HelperCoder
1212
where
1313
Sequence: SequenceInitializable, ElementHelper: HelperCoder,
1414
Sequence.Element == ElementHelper.Coded
1515
{
16-
/// The ``/MetaCodable/HelperCoder`` for element.
16+
/// The `HelperCoder` for element.
1717
///
1818
/// Each element is decoded/encoded using this.
1919
public let elementHelper: ElementHelper
@@ -28,7 +28,7 @@ where
2828
///
2929
/// - Parameters:
3030
/// - output: The resulting sequence type.
31-
/// - elementHelper: The ``/MetaCodable/HelperCoder`` for element.
31+
/// - elementHelper: The `HelperCoder` for element.
3232
/// - configuration: The configuration for decoding and encoding.
3333
public init(
3434
output: Sequence.Type, elementHelper: ElementHelper,
@@ -43,7 +43,7 @@ where
4343
/// Sequence type is inferred from provided configuration.
4444
///
4545
/// - Parameters:
46-
/// - elementHelper: The ``/MetaCodable/HelperCoder`` for element.
46+
/// - elementHelper: The `HelperCoder` for element.
4747
/// - configuration: The configuration for decoding and encoding.
4848
public init(
4949
elementHelper: ElementHelper, configuration: Configuration
@@ -92,7 +92,7 @@ where
9292
/// By default, no additional customizations configuration is used.
9393
///
9494
/// - Parameters:
95-
/// - elementHelper: The ``/MetaCodable/HelperCoder`` for element.
95+
/// - elementHelper: The `HelperCoder` for element.
9696
/// - configuration: The configuration for decoding and encoding.
9797
public init(
9898
elementHelper: ElementHelper, configuration: Configuration = .init()

0 commit comments

Comments
 (0)