Skip to content

Commit 07b22f6

Browse files
iCharlesHuheckj
andauthored
Apply documetation suggestions from code review
Co-authored-by: Joseph Heck <[email protected]>
1 parent 69920c1 commit 07b22f6

13 files changed

+142
-130
lines changed

Sources/Subprocess/API.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
// MARK: - Collected Result
1919

20-
/// Run an executable with given parameters asynchronously and returns a
21-
/// `CollectedResult` containing the output of the child process.
20+
/// Run an executable with given parameters asynchronously and return a
21+
/// collected result that contains the output of the child process.
2222
/// - Parameters:
2323
/// - executable: The executable to run.
2424
/// - arguments: The arguments to pass to the executable.
@@ -59,8 +59,8 @@ public func run<
5959
}
6060

6161
#if SubprocessSpan
62-
/// Run an executable with given parameters asynchronously and returns a
63-
/// `CollectedResult` containing the output of the child process.
62+
/// Run an executable with given parameters asynchronously and return a
63+
/// collected result that contains the output of the child process.
6464
/// - Parameters:
6565
/// - executable: The executable to run.
6666
/// - arguments: The arguments to pass to the executable.

Sources/Subprocess/AsyncBufferSequence.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
internal import Dispatch
2020
#endif
2121

22-
/// A synchronous sequence of `Buffer`s used to stream output from subprocess.
22+
/// A synchronous sequence of buffers used to stream output from subprocess.
2323
public struct AsyncBufferSequence: AsyncSequence, @unchecked Sendable {
24-
/// The failure type for this `AsyncSequence`
24+
/// The failure type for the asynchronous sequence.
2525
public typealias Failure = any Swift.Error
26-
/// The element type for this `AsyncSequence`
26+
/// The element type for the asynchronous sequence.
2727
public typealias Element = Buffer
2828

2929
#if SUBPROCESS_ASYNCIO_DISPATCH
@@ -37,7 +37,7 @@ public struct AsyncBufferSequence: AsyncSequence, @unchecked Sendable {
3737
/// Iterator for `AsyncBufferSequence`.
3838
@_nonSendable
3939
public struct Iterator: AsyncIteratorProtocol {
40-
/// The element type for this iterator
40+
/// The element type for the iterator.
4141
public typealias Element = Buffer
4242

4343
private let diskIO: DiskIO
@@ -48,8 +48,8 @@ public struct AsyncBufferSequence: AsyncSequence, @unchecked Sendable {
4848
self.buffer = []
4949
}
5050

51-
/// Retrieve the next `Buffer` in the sequence, nor `nil` if
52-
/// the sequence has ended,
51+
/// Retrieve the next buffer in the sequence, or `nil` if
52+
/// the sequence has ended.
5353
public mutating func next() async throws -> Buffer? {
5454
// If we have more left in buffer, use that
5555
guard self.buffer.isEmpty else {
@@ -89,12 +89,12 @@ public struct AsyncBufferSequence: AsyncSequence, @unchecked Sendable {
8989
self.diskIO = diskIO
9090
}
9191

92-
/// Creates a iterator for this `AsyncSequence`
92+
/// Creates a iterator for this asynchronous sequence.
9393
public func makeAsyncIterator() -> Iterator {
9494
return Iterator(diskIO: self.diskIO)
9595
}
9696

97-
/// Creates a line sequence to iterate through this `AsyncBufferSequence` line by line
97+
/// Creates a line sequence to iterate through this `AsyncBufferSequence` line by line.
9898
public func lines() -> LineSequence<UTF8> {
9999
return LineSequence(
100100
underlying: self,
@@ -103,7 +103,7 @@ public struct AsyncBufferSequence: AsyncSequence, @unchecked Sendable {
103103
)
104104
}
105105

106-
/// Creates a line sequence to iterate through this `AsyncBufferSequence` line by line
106+
/// Creates a line sequence to iterate through a `AsyncBufferSequence` line by line.
107107
/// - Parameters:
108108
/// - encoding: The taget encoding to encoding Strings to
109109
/// - bufferingPolicy: How should back-pressure be handled
@@ -118,19 +118,19 @@ public struct AsyncBufferSequence: AsyncSequence, @unchecked Sendable {
118118

119119
// MARK: - LineSequence
120120
extension AsyncBufferSequence {
121-
/// An asynchronous sequence of `String` which each String representing a line
122-
/// `LineSequence` parses and splits `AsyncBufferSequence` into lines. It is the
123-
/// preferred method to convert `Buffer` to `String`
121+
/// Line sequence parses and splits an asynchronous sequence of buffers into lines.
122+
///
123+
/// It is the preferred method to convert `Buffer` to `String`
124124
public struct LineSequence<Encoding: _UnicodeEncoding>: AsyncSequence, Sendable {
125-
/// The element type for this `AsyncSequence`
125+
/// The element type for the asynchronous sequence.
126126
public typealias Element = String
127127

128128
private let base: AsyncBufferSequence
129129
private let bufferingPolicy: BufferingPolicy
130130

131-
/// The iterator for `LineSequence`
131+
/// The iterator for line sequence.
132132
public struct AsyncIterator: AsyncIteratorProtocol {
133-
/// The element type for this Iterator
133+
/// The element type for this Iterator.
134134
public typealias Element = String
135135

136136
private var source: AsyncBufferSequence.AsyncIterator
@@ -152,7 +152,7 @@ extension AsyncBufferSequence {
152152
self.bufferingPolicy = bufferingPolicy
153153
}
154154

155-
/// Retrieve the next line
155+
/// Retrieves the next line, or returns nil if the sequence ends.
156156
public mutating func next() async throws -> String? {
157157

158158
func loadBuffer() async throws -> [Encoding.CodeUnit]? {
@@ -327,7 +327,7 @@ extension AsyncBufferSequence {
327327
}
328328
}
329329

330-
/// Creates a iterator for this `LineSequence`
330+
/// Creates a iterator for this line sequence.
331331
public func makeAsyncIterator() -> AsyncIterator {
332332
return AsyncIterator(
333333
underlyingIterator: self.base.makeAsyncIterator(),
@@ -347,7 +347,7 @@ extension AsyncBufferSequence {
347347
}
348348

349349
extension AsyncBufferSequence.LineSequence {
350-
/// A strategy that handles exhaustion of a buffer’s capacity.
350+
/// A strategy that handles the exhaustion of a buffer’s capacity.
351351
public enum BufferingPolicy: Sendable {
352352
/// Continue to add to the buffer, without imposing a limit
353353
/// on the number of buffered elements (line length).

Sources/Subprocess/Buffer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ extension AsyncBufferSequence.Buffer {
9595
// MARK: - Hashable, Equatable
9696
extension AsyncBufferSequence.Buffer: Equatable, Hashable {
9797
#if SUBPROCESS_ASYNCIO_DISPATCH
98-
/// Returns a Boolean value indicating whether two `AsyncBufferSequence.Buffer`s are equal.
98+
/// Returns a Boolean value that indicates whether two buffers are equal.
9999
public static func == (lhs: AsyncBufferSequence.Buffer, rhs: AsyncBufferSequence.Buffer) -> Bool {
100100
return lhs.data == rhs.data
101101
}

Sources/Subprocess/Configuration.swift

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ public struct Configuration: Sendable {
4141
/// The environment to use when running the executable.
4242
public var environment: Environment
4343
/// The working directory to use when running the executable.
44+
///
4445
/// If this property is `nil`, the subprocess will inherit
4546
/// the working directory from the parent process.
4647
public var workingDirectory: FilePath?
4748
/// The platform specific options to use when
4849
/// running the subprocess.
4950
public var platformOptions: PlatformOptions
5051

51-
/// Creates a Configuration with the given parameters
52+
/// Creates a Configuration with the parameters you provide.
5253
/// - Parameters:
5354
/// - executable: the executable to run
5455
/// - arguments: the arguments to pass to the executable.
@@ -127,7 +128,7 @@ public struct Configuration: Sendable {
127128
}
128129

129130
extension Configuration: CustomStringConvertible, CustomDebugStringConvertible {
130-
/// A textual representation of this `Configuration`.
131+
/// A textual representation of this configuration.
131132
public var description: String {
132133
return """
133134
Configuration(
@@ -140,7 +141,7 @@ extension Configuration: CustomStringConvertible, CustomDebugStringConvertible {
140141
"""
141142
}
142143

143-
/// A textual representation of this `Configuration`.
144+
/// A debug-oriented textual representation of this configuration.
144145
public var debugDescription: String {
145146
return """
146147
Configuration(
@@ -208,8 +209,7 @@ extension Configuration {
208209

209210
// MARK: - Executable
210211

211-
/// Executable defines how the executable should be
212-
/// looked up for execution.
212+
/// Executable defines how subprocess looks up the executable for execution.
213213
public struct Executable: Sendable, Hashable {
214214
internal enum Storage: Sendable, Hashable {
215215
case executable(String)
@@ -241,7 +241,7 @@ public struct Executable: Sendable, Hashable {
241241
}
242242

243243
extension Executable: CustomStringConvertible, CustomDebugStringConvertible {
244-
/// A textual representation of this `Executable`.
244+
/// A textual representation of this executable.
245245
public var description: String {
246246
switch storage {
247247
case .executable(let executableName):
@@ -251,7 +251,7 @@ extension Executable: CustomStringConvertible, CustomDebugStringConvertible {
251251
}
252252
}
253253

254-
/// A textual representation of this `Executable`.
254+
/// A debug-oriented textual representation of this executable.
255255
public var debugDescription: String {
256256
switch storage {
257257
case .executable(let string):
@@ -316,7 +316,7 @@ public struct Arguments: Sendable, ExpressibleByArrayLiteral, Hashable {
316316
self.executablePathOverride = nil
317317
}
318318
}
319-
/// Create an Arguments object using the given array
319+
/// Create an arguments object using the array you provide.
320320
public init(_ array: [[UInt8]]) {
321321
self.storage = array.map { .rawBytes($0) }
322322
self.executablePathOverride = nil
@@ -325,7 +325,7 @@ public struct Arguments: Sendable, ExpressibleByArrayLiteral, Hashable {
325325
}
326326

327327
extension Arguments: CustomStringConvertible, CustomDebugStringConvertible {
328-
/// A textual representation of this `Arguments`.
328+
/// A textual representation of the arguments.
329329
public var description: String {
330330
var result: [String] = self.storage.map(\.description)
331331

@@ -335,7 +335,7 @@ extension Arguments: CustomStringConvertible, CustomDebugStringConvertible {
335335
return result.description
336336
}
337337

338-
/// A textual representation of this `Arguments`.
338+
/// A debug-oriented textual representation of the arguments.
339339
public var debugDescription: String { return self.description }
340340
}
341341

@@ -379,7 +379,7 @@ public struct Environment: Sendable, Hashable {
379379
}
380380

381381
extension Environment: CustomStringConvertible, CustomDebugStringConvertible {
382-
/// A textual representation of this `Environment`.
382+
/// A textual representation of the environment.
383383
public var description: String {
384384
switch self.config {
385385
case .custom(let customDictionary):
@@ -402,7 +402,7 @@ extension Environment: CustomStringConvertible, CustomDebugStringConvertible {
402402
}
403403
}
404404

405-
/// A textual representation of this `Environment`.
405+
/// A debug-oriented textual representation of the environment.
406406
public var debugDescription: String {
407407
return self.description
408408
}
@@ -440,14 +440,14 @@ extension Environment: CustomStringConvertible, CustomDebugStringConvertible {
440440

441441
// MARK: - TerminationStatus
442442

443-
/// An exit status of a subprocess
443+
/// An exit status of a subprocess.
444444
@frozen
445445
public enum TerminationStatus: Sendable, Hashable {
446446
#if canImport(WinSDK)
447-
/// The type of status code
447+
/// The type of the status code.
448448
public typealias Code = DWORD
449449
#else
450-
/// The type of status code
450+
/// The type of the status code.
451451
public typealias Code = CInt
452452
#endif
453453

@@ -467,7 +467,7 @@ public enum TerminationStatus: Sendable, Hashable {
467467
}
468468

469469
extension TerminationStatus: CustomStringConvertible, CustomDebugStringConvertible {
470-
/// A textual representation of this `TerminationStatus`.
470+
/// A textual representation of this termination status.
471471
public var description: String {
472472
switch self {
473473
case .exited(let code):
@@ -477,7 +477,7 @@ extension TerminationStatus: CustomStringConvertible, CustomDebugStringConvertib
477477
}
478478
}
479479

480-
/// A textual representation of this `TerminationStatus`.
480+
/// A debug-oriented textual representation of this termination status.
481481
public var debugDescription: String {
482482
return self.description
483483
}
@@ -651,9 +651,11 @@ internal func _safelyClose(_ target: _CloseTarget) throws {
651651
}
652652
}
653653

654-
/// IODescriptor wraps platform-specific FileDescriptor, which is used to establish a
654+
/// An IO descriptor wraps platform-specific file descriptor, which establishes a
655655
/// connection to the standard input/output (IO) system during the process of
656-
/// spawning a child process. Unlike IODescriptor, the IODescriptor does not support
656+
/// spawning a child process.
657+
///
658+
/// Unlike a file descriptor, the `IODescriptor` does not support
657659
/// data read/write operations; its primary function is to facilitate the spawning of
658660
/// child processes by providing a platform-specific file descriptor.
659661
internal struct IODescriptor: ~Copyable {
@@ -965,10 +967,12 @@ extension Optional where Wrapped == String {
965967
}
966968
}
967969

968-
/// Runs `body`, and then runs `onCleanup` if `body` throws an error,
969-
/// or if the parent task is cancelled. In the latter case, `onCleanup`
970-
/// may be run concurrently with `body`. `body` is guaranteed to run exactly once.
971-
/// `onCleanup` is guaranteed to run only once, or not at all.
970+
/// Runs the body close, then runs the on-cleanup closure if the body closure throws an error
971+
/// or if the parent task is cancelled.
972+
///
973+
/// In the latter case, `onCleanup` may be run concurrently with `body`.
974+
/// The `body` closure is guaranteed to run exactly once.
975+
/// The `onCleanup` closure is guaranteed to run only once, or not at all.
972976
internal func withAsyncTaskCleanupHandler<Result>(
973977
_ body: () async throws -> Result,
974978
onCleanup handler: @Sendable @escaping () async -> Void,

Sources/Subprocess/Error.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extension SubprocessError {
5353
case invalidWindowsPath(String)
5454
}
5555

56-
/// The numeric value of this `Code`
56+
/// The numeric value of this code.
5757
public var value: Int {
5858
switch self.storage {
5959
case .spawnFailed:
@@ -99,7 +99,7 @@ extension SubprocessError {
9999

100100
// MARK: - Description
101101
extension SubprocessError: CustomStringConvertible, CustomDebugStringConvertible {
102-
/// A textual representation of this `SubprocessError`.
102+
/// A textual representation of this subprocess error.
103103
public var description: String {
104104
switch self.code.storage {
105105
case .spawnFailed:
@@ -135,7 +135,7 @@ extension SubprocessError: CustomStringConvertible, CustomDebugStringConvertible
135135
}
136136
}
137137

138-
/// A textual representation of this `SubprocessError`.
138+
/// A debug-oriented textual representation of this subprocess error.
139139
public var debugDescription: String { self.description }
140140
}
141141

@@ -145,14 +145,14 @@ extension SubprocessError {
145145
/// - On Windows, `UnderlyingError` wraps Windows Error code
146146
public struct UnderlyingError: Swift.Error, RawRepresentable, Hashable, Sendable {
147147
#if os(Windows)
148-
/// The type of raw value for this UnderlyingError
148+
/// The type for the raw value of the underlying error.
149149
public typealias RawValue = DWORD
150150
#else
151-
/// The type of raw value for this UnderlyingError
151+
/// The type for the raw value of the underlying error.
152152
public typealias RawValue = Int32
153153
#endif
154154

155-
/// The platform specific value for this `UnderlyingError`
155+
/// The platform specific value for this underlying error.
156156
public let rawValue: RawValue
157157
/// Initialize a `UnderlyingError` with given error value
158158
public init(rawValue: RawValue) {

0 commit comments

Comments
 (0)