Skip to content

Commit c8f8e59

Browse files
authored
Merge pull request #9698 from natecook1000/nc-fixes-75-2
[stdlib] Documentation revisions
2 parents 4cce46d + 817a1ef commit c8f8e59

14 files changed

+216
-157
lines changed

stdlib/public/SDK/Foundation/NSStringAPI.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,8 @@ extension String {
267267
/// strings. See the `getLineStart(_:end:contentsEnd:for:)` method for
268268
/// additional information.
269269
///
270-
/// Case transformations aren't guaranteed to be symmetrical or to produce
271-
/// strings of the same lengths as the originals. See lowercased for an
272-
/// example.
270+
/// Case transformations aren’t guaranteed to be symmetrical or to produce
271+
/// strings of the same lengths as the originals.
273272
public var capitalized: String {
274273
return _ns.capitalized as String
275274
}
@@ -626,7 +625,7 @@ extension String {
626625

627626
// @property NSStringEncoding fastestEncoding;
628627

629-
/// The fastest encoding to which the string may be converted without loss
628+
/// The fastest encoding to which the string can be converted without loss
630629
/// of information.
631630
public var fastestEncoding: Encoding {
632631
return Encoding(rawValue: _ns.fastestEncoding)
@@ -825,10 +824,11 @@ extension String {
825824
// encoding:(NSStringEncoding)encoding
826825
// freeWhenDone:(BOOL)flag
827826

828-
/// Creates a new string that contains the specified number of bytes
829-
/// from the given buffer interpreted
830-
/// in the specified encoding, and optionally frees the buffer. WARNING:
831-
/// this initializer is not memory-safe!
827+
/// Creates a new string that contains the specified number of bytes from the
828+
/// given buffer, interpreted in the specified encoding, and optionally
829+
/// frees the buffer.
830+
///
831+
/// - Warning: This initializer is not memory-safe!
832832
public init?(
833833
bytesNoCopy bytes: UnsafeMutableRawPointer, length: Int,
834834
encoding: Encoding, freeWhenDone flag: Bool
@@ -862,8 +862,8 @@ extension String {
862862
// length:(NSUInteger)length
863863
// freeWhenDone:(BOOL)flag
864864

865-
/// Creates a new string that contains the specified
866-
/// number of characters from a given array of UTF-16 Code Units
865+
/// Creates a new string that contains the specified number of characters
866+
/// from the given C array of UTF-16 code units.
867867
public init(
868868
utf16CodeUnitsNoCopy: UnsafePointer<unichar>,
869869
count: Int,
@@ -1715,7 +1715,7 @@ extension String {
17151715
/// Locale-independent case-insensitive operation, and other needs, can be
17161716
/// achieved by calling `range(of:options:range:locale:)`.
17171717
///
1718-
/// Equivalent to
1718+
/// Equivalent to:
17191719
///
17201720
/// range(of: other, options: .caseInsensitiveSearch,
17211721
/// locale: Locale.current) != nil

stdlib/public/core/Arrays.swift.gyb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,15 +1677,15 @@ extension ${Self} {
16771677
/// }
16781678
/// // 'sum' == 9
16791679
///
1680-
/// The pointer passed as an argument to `body` is valid only for the
1681-
/// lifetime of the closure. Do not escape it from the closure for later
1682-
/// use.
1680+
/// The pointer passed as an argument to `body` is valid only during the
1681+
/// execution of `withUnsafeBufferPointer(_:)`. Do not store or return the
1682+
/// pointer for later use.
16831683
///
16841684
/// - Parameter body: A closure with an `UnsafeBufferPointer` parameter that
16851685
/// points to the contiguous storage for the array. ${contiguousCaveat} If
16861686
/// `body` has a return value, it is used as the return value for the
16871687
/// `withUnsafeBufferPointer(_:)` method. The pointer argument is valid
1688-
/// only for the duration of the closure's execution.
1688+
/// only for the duration of the method's execution.
16891689
/// - Returns: The return value of the `body` closure parameter, if any.
16901690
///
16911691
/// - SeeAlso: `withUnsafeMutableBufferPointer`, `UnsafeBufferPointer`
@@ -1716,9 +1716,9 @@ extension ${Self} {
17161716
/// print(numbers)
17171717
/// // Prints "[2, 1, 4, 3, 5]"
17181718
///
1719-
/// The pointer passed as an argument to `body` is valid only for the
1720-
/// lifetime of the closure. Do not escape it from the closure for later
1721-
/// use.
1719+
/// The pointer passed as an argument to `body` is valid only during the
1720+
/// execution of `withUnsafeMutableBufferPointer(_:)`. Do not store or
1721+
/// return the pointer for later use.
17221722
///
17231723
/// - Warning: Do not rely on anything about the array that is the target of
17241724
/// this method during execution of the `body` closure; it might not
@@ -1729,7 +1729,7 @@ extension ${Self} {
17291729
/// parameter that points to the contiguous storage for the array.
17301730
/// ${contiguousCaveat} If `body` has a return value, it is used as the
17311731
/// return value for the `withUnsafeMutableBufferPointer(_:)` method. The
1732-
/// pointer argument is valid only for the duration of the closure's
1732+
/// pointer argument is valid only for the duration of the method's
17331733
/// execution.
17341734
/// - Returns: The return value of the `body` closure parameter, if any.
17351735
///

stdlib/public/core/Character.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
/// A single extended grapheme cluster, which approximates a user-perceived
13+
/// A single extended grapheme cluster that approximates a user-perceived
1414
/// character.
1515
///
1616
/// The `Character` type represents a character made up of one or more Unicode

stdlib/public/core/Codable.swift

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,39 @@
1414
// Codable
1515
//===----------------------------------------------------------------------===//
1616

17-
/// Conformance to `Encodable` indicates that a type can encode itself to an external representation.
17+
/// A type that can encode itself to an external representation.
1818
public protocol Encodable {
19-
/// Encodes `self` into the given encoder.
19+
/// Encodes this value into the given encoder.
2020
///
21-
/// If `self` fails to encode anything, `encoder` will encode an empty keyed container in its place.
21+
/// If the value fails to encode anything, `encoder` will encode an empty
22+
/// keyed container in its place.
2223
///
23-
/// - parameter encoder: The encoder to write data to.
24-
/// - throws: An error if any values are invalid for `encoder`'s format.
24+
/// This function throws an error if any values are invalid for the given
25+
/// encoder's format.
26+
///
27+
/// - Parameter encoder: The encoder to write data to.
2528
func encode(to encoder: Encoder) throws
2629
}
2730

28-
/// Conformance to `Decodable` indicates that a type can decode itself from an external representation.
31+
/// A type that can decode itself from an external representation.
2932
public protocol Decodable {
30-
/// Initializes `self` by decoding from `decoder`.
33+
/// Creates a new instance by decoding from the given decoder.
34+
///
35+
/// This initializer throws an error if reading from the decoder fails, or
36+
/// if the data read is corrupted or otherwise invalid.
3137
///
32-
/// - parameter decoder: The decoder to read data from.
33-
/// - throws: An error if reading from the decoder fails, or if read data is corrupted or otherwise invalid.
38+
/// - Parameter decoder: The decoder to read data from.
3439
init(from decoder: Decoder) throws
3540
}
3641

37-
/// Conformance to `Codable` indicates that a type can convert itself into and out of an external representation.
42+
/// A type that can convert itself into and out of an external representation.
3843
public typealias Codable = Encodable & Decodable
3944

4045
//===----------------------------------------------------------------------===//
4146
// CodingKey
4247
//===----------------------------------------------------------------------===//
4348

44-
/// Conformance to `CodingKey` indicates that a type can be used as a key for encoding and decoding.
49+
/// A type that can be used as a key for encoding and decoding.
4550
public protocol CodingKey {
4651
/// The string to use in a named collection (e.g. a string-keyed dictionary).
4752
var stringValue: String { get }
@@ -66,7 +71,7 @@ public protocol CodingKey {
6671
// Encoder & Decoder
6772
//===----------------------------------------------------------------------===//
6873

69-
/// An `Encoder` is a type which can encode values into a native format for external representation.
74+
/// A type that can encode values into a native format for external representation.
7075
public protocol Encoder {
7176
/// The path of coding keys taken to get to this point in encoding.
7277
/// A `nil` value indicates an unkeyed container.
@@ -99,7 +104,7 @@ public protocol Encoder {
99104
func singleValueContainer() -> SingleValueEncodingContainer
100105
}
101106

102-
/// A `Decoder` is a type which can decode values from a native format into in-memory representations.
107+
/// A type that can decode values from a native format into in-memory representations.
103108
public protocol Decoder {
104109
/// The path of coding keys taken to get to this point in decoding.
105110
/// A `nil` value indicates an unkeyed container.
@@ -132,9 +137,11 @@ public protocol Decoder {
132137
// Keyed Encoding Containers
133138
//===----------------------------------------------------------------------===//
134139

135-
/// Conformance to `KeyedEncodingContainerProtocol` indicates that a type provides a view into an `Encoder`'s storage and is used to hold the encoded properties of an `Encodable` type in a keyed manner.
140+
/// A type that provides a view into an encoder's storage and is used to hold
141+
/// the encoded properties of an encodable type in a keyed manner.
136142
///
137-
/// Encoders should provide types conforming to `KeyedEncodingContainerProtocol` for their format.
143+
/// Encoders should provide types conforming to
144+
/// `KeyedEncodingContainerProtocol` for their format.
138145
public protocol KeyedEncodingContainerProtocol {
139146
associatedtype Key : CodingKey
140147

@@ -286,7 +293,9 @@ public protocol KeyedEncodingContainerProtocol {
286293
}
287294

288295
// An implementation of _KeyedEncodingContainerBase and _KeyedEncodingContainerBox are given at the bottom of this file.
289-
/// `KeyedEncodingContainer` is a type-erased box for `KeyedEncodingContainerProtocol` types, similar to `AnyCollection` and `AnyHashable`. This is the type which consumers of the API interact with directly.
296+
297+
/// A concrete container that provides a view into an encoder's storage, making
298+
/// the encoded properties of an encodable type accessible by keys.
290299
public struct KeyedEncodingContainer<K : CodingKey> {
291300
public typealias Key = K
292301

@@ -488,9 +497,11 @@ public struct KeyedEncodingContainer<K : CodingKey> {
488497
}
489498
}
490499

491-
/// Conformance to `KeyedDecodingContainerProtocol` indicates that a type provides a view into a `Decoder`'s storage and is used to hold the encoded properties of a `Decodable` type in a keyed manner.
500+
/// A type that provides a view into a decoder's storage and is used to hold
501+
/// the encoded properties of a decodable type in a keyed manner.
492502
///
493-
/// Decoders should provide types conforming to `UnkeyedDecodingContainer` for their format.
503+
/// Decoders should provide types conforming to `UnkeyedDecodingContainer` for
504+
/// their format.
494505
public protocol KeyedDecodingContainerProtocol {
495506
associatedtype Key : CodingKey
496507

@@ -845,7 +856,9 @@ public protocol KeyedDecodingContainerProtocol {
845856
}
846857

847858
// An implementation of _KeyedDecodingContainerBase and _KeyedDecodingContainerBox are given at the bottom of this file.
848-
/// `KeyedDecodingContainer` is a type-erased box for `KeyedDecodingContainerProtocol` types, similar to `AnyCollection` and `AnyHashable`. This is the type which consumers of the API interact with directly.
859+
860+
/// A concrete container that provides a view into an decoder's storage, making
861+
/// the encoded properties of an decodable type accessible by keys.
849862
public struct KeyedDecodingContainer<K : CodingKey> : KeyedDecodingContainerProtocol {
850863
public typealias Key = K
851864

@@ -1107,9 +1120,11 @@ public struct KeyedDecodingContainer<K : CodingKey> : KeyedDecodingContainerProt
11071120
// Unkeyed Encoding Containers
11081121
//===----------------------------------------------------------------------===//
11091122

1110-
/// Conformance to `UnkeyedEncodingContainer` indicates that a type provides a view into an `Encoder`'s storage and is used to hold the encoded properties of an `Encodable` type sequentially, without keys.
1123+
/// A type that provides a view into an encoder's storage and is used to hold
1124+
/// the encoded properties of an encodable type sequentially, without keys.
11111125
///
1112-
/// Encoders should provide types conforming to `UnkeyedEncodingContainer` for their format.
1126+
/// Encoders should provide types conforming to `UnkeyedEncodingContainer` for
1127+
/// their format.
11131128
public protocol UnkeyedEncodingContainer {
11141129
/// The path of coding keys taken to get to this point in encoding.
11151130
/// A `nil` value indicates an unkeyed container.
@@ -1322,9 +1337,11 @@ public protocol UnkeyedEncodingContainer {
13221337
mutating func superEncoder() -> Encoder
13231338
}
13241339

1325-
/// Conformance to `UnkeyedDecodingContainer` indicates that a type provides a view into a `Decoder`'s storage and is used to hold the encoded properties of a `Decodable` type sequentially, without keys.
1340+
/// A type that provides a view into a decoder's storage and is used to hold
1341+
/// the encoded properties of a decodable type sequentially, without keys.
13261342
///
1327-
/// Decoders should provide types conforming to `UnkeyedDecodingContainer` for their format.
1343+
/// Decoders should provide types conforming to `UnkeyedDecodingContainer` for
1344+
/// their format.
13281345
public protocol UnkeyedDecodingContainer {
13291346
/// The path of coding keys taken to get to this point in decoding.
13301347
/// A `nil` value indicates an unkeyed container.
@@ -1615,7 +1632,8 @@ public protocol UnkeyedDecodingContainer {
16151632
// Single Value Encoding Containers
16161633
//===----------------------------------------------------------------------===//
16171634

1618-
/// A `SingleValueEncodingContainer` is a container which can support the storage and direct encoding of a single non-keyed value.
1635+
/// A container that can support the storage and direct encoding of a single
1636+
/// non-keyed value.
16191637
public protocol SingleValueEncodingContainer {
16201638
/// Encodes a single value of the given type.
16211639
///
@@ -1821,7 +1839,7 @@ public protocol SingleValueDecodingContainer {
18211839
// User Info
18221840
//===----------------------------------------------------------------------===//
18231841

1824-
/// Represents a user-defined key for providing context for encoding and decoding.
1842+
/// A user-defined key for providing context during encoding and decoding.
18251843
public struct CodingUserInfoKey : RawRepresentable, Equatable, Hashable {
18261844
public typealias RawValue = String
18271845

@@ -1853,7 +1871,7 @@ public struct CodingUserInfoKey : RawRepresentable, Equatable, Hashable {
18531871
// Errors
18541872
//===----------------------------------------------------------------------===//
18551873

1856-
/// An `EncodingError` indicates that something has gone wrong during encoding of a value.
1874+
/// An error that occurs during the encoding of a value.
18571875
public enum EncodingError : Error {
18581876
/// The context in which the error occurred.
18591877
public struct Context {
@@ -1879,7 +1897,7 @@ public enum EncodingError : Error {
18791897
case invalidValue(Any, Context)
18801898
}
18811899

1882-
/// A `DecodingError` indicates that something has gone wrong during decoding of a value.
1900+
/// An error that occurs during the decoding of a value.
18831901
public enum DecodingError : Error {
18841902
/// The context in which the error occurred.
18851903
public struct Context {

stdlib/public/core/KeyPath.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ internal func _abstract(
2727

2828
// MARK: Type-erased abstract base classes
2929

30+
/// A type-erased key path, from any root type to any resulting value type.
3031
public class AnyKeyPath: Hashable, _AppendKeyPath {
32+
/// The root type for this key path.
3133
@_inlineable
3234
public static var rootType: Any.Type {
3335
return _rootAndValueType.root
3436
}
3537

38+
/// The value type for this key path.
3639
@_inlineable
3740
public static var valueType: Any.Type {
3841
return _rootAndValueType.value
@@ -138,11 +141,14 @@ public class AnyKeyPath: Hashable, _AppendKeyPath {
138141
}
139142
}
140143

144+
/// A partially type-erased key path, from a concrete root type to any
145+
/// resulting value type.
141146
public class PartialKeyPath<Root>: AnyKeyPath { }
142147

143148
// MARK: Concrete implementations
144149
internal enum KeyPathKind { case readOnly, value, reference }
145150

151+
/// A key path from a specific root type to a specific resulting value type.
146152
public class KeyPath<Root, Value>: PartialKeyPath<Root> {
147153
public typealias _Root = Root
148154
public typealias _Value = Value
@@ -219,6 +225,7 @@ public class KeyPath<Root, Value>: PartialKeyPath<Root> {
219225
}
220226
}
221227

228+
/// A key path that supports reading from and writing to the resulting value.
222229
public class WritableKeyPath<Root, Value>: KeyPath<Root, Value> {
223230
// MARK: Implementation detail
224231

@@ -268,6 +275,8 @@ public class WritableKeyPath<Root, Value>: KeyPath<Root, Value> {
268275

269276
}
270277

278+
/// A key path that supports reading from and writing to the resulting value
279+
/// with reference semantics.
271280
public class ReferenceWritableKeyPath<Root, Value>: WritableKeyPath<Root, Value> {
272281
// MARK: Implementation detail
273282

0 commit comments

Comments
 (0)