Skip to content

Conversation

iCharlesHu
Copy link
Contributor

@iCharlesHu iCharlesHu commented Aug 29, 2025

This PR improves documentation throughout the code base. It also turns on AllPublicDeclarationsHaveDocumentation to enforce that all public symbols have proper documentation.

While I was here
I noticed the Documentation option isn't showing up for swift-subprocess on Swift Package Index. Hopefully, the edit to .spy.yml will fix that.

@iCharlesHu iCharlesHu force-pushed the charles/documentation-update branch from eb8b169 to 69920c1 Compare August 29, 2025 05:22
Copy link
Member

@heckj heckj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll come back through and add more suggestions to help out, need to pause for now, so submitting this where it is.

Comment on lines 36 to 37
/// InputProtocol defines the `write(with:)` method that a type must
/// implement to serve as the input source for a subprocess.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// InputProtocol defines the `write(with:)` method that a type must
/// implement to serve as the input source for a subprocess.
/// InputProtocol defines a type that serves as the input source for a subprocess.
///
/// The protocol defines the `write(with:)` method that a type must
/// implement to serve as the input source.

In general, abstracts for symbols should be a single sentence that doesn't use code voice (symbol references or monospaced fonts). Breaking it up with a line break in between drops the detail about the method that must be provided (which the protocol conformance enforces) into the discussion section for the type. The abstract (that first line) is propagated and shown alongside the content anywhere the symbol is referenced.

Comment on lines 44 to 47
/// A concrete input type for subprocesses that indicates the absence
/// of input to the subprocess. On Unix-like systems, `NoInput`
/// redirects the standard input of the subprocess to /dev/null,
/// while on Windows, it redirects to `NUL`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A concrete input type for subprocesses that indicates the absence
/// of input to the subprocess. On Unix-like systems, `NoInput`
/// redirects the standard input of the subprocess to /dev/null,
/// while on Windows, it redirects to `NUL`.
/// A concrete input type for subprocesses that indicates the absence
/// of input to the subprocess.
///
/// On Unix-like systems, `NoInput` redirects the standard input of the subprocess to /dev/null,
/// while on Windows, it redirects to `NUL`.

Comment on lines 62 to 63
/// Asynchronously write the input to the subprocess using the
/// write file descriptor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Asynchronously write the input to the subprocess using the
/// write file descriptor
/// Asynchronously write the input to the subprocess that uses the
/// write file descriptor.

Comment on lines 71 to 74
/// A concrete input type for subprocesses that reads input from a
/// specified FileDescriptor. Developers have the option to
/// instruct the Subprocess to automatically close the provided
/// FileDescriptor after the subprocess is spawned.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A concrete input type for subprocesses that reads input from a
/// specified FileDescriptor. Developers have the option to
/// instruct the Subprocess to automatically close the provided
/// FileDescriptor after the subprocess is spawned.
/// A concrete input type for subprocesses that reads input from a specified FileDescriptor.
///
/// Developers have the option to instruct the Subprocess to automatically close the provided
/// FileDescriptor after the subprocess is spawned.

Comment on lines 94 to 95
/// Asynchronously write the input to the subprocess using the
/// write file descriptor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Asynchronously write the input to the subprocess using the
/// write file descriptor
/// Asynchronously write the input to the subprocess that use the
/// write file descriptor.

Comment on lines 119 to 120
/// Asynchronously write the input to the subprocess using the
/// write file descriptor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Asynchronously write the input to the subprocess using the
/// write file descriptor
/// Asynchronously write the input to the subprocess that use the
/// write file descriptor.

/// - Parameter span: The span to write
/// - Returns number of bytes written
#if SubprocessSpan
/// Write a `RawSpan` to the standard input of the subprocess.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Write a `RawSpan` to the standard input of the subprocess.
/// Write a raw span to the standard input of the subprocess.
///

#endif

/// Write a StringProtocol to the standard input of the subprocess.
/// Write a `StringProtocol` to the standard input of the subprocess.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Write a `StringProtocol` to the standard input of the subprocess.
/// Write a type that conforms to StringProtocol to the standard input of the subprocess.

Comment on lines 26 to 30
/// `OutputProtocol` specifies the set of methods that a type must implement to
/// serve as the output target for a subprocess. Instead of developing custom
/// implementations of `OutputProtocol`, it is recommended to utilize the
/// default implementations provided by the `Subprocess` library to specify the
/// output handling requirements.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// `OutputProtocol` specifies the set of methods that a type must implement to
/// serve as the output target for a subprocess. Instead of developing custom
/// implementations of `OutputProtocol`, it is recommended to utilize the
/// default implementations provided by the `Subprocess` library to specify the
/// output handling requirements.
/// Output protocol specifies the set of methods that a type must implement to
/// serve as the output target for a subprocess.
/// Instead of developing custom implementations of `OutputProtocol`, use the
/// default implementations provided by the `Subprocess` library to specify the
/// output handling requirements.

Comment on lines 51 to 55
/// A concrete `Output` type for subprocesses that indicates that the
/// `Subprocess` should not collect or redirect output from the child
/// process. On Unix-like systems, `DiscardedOutput` redirects the
/// standard output of the subprocess to `/dev/null`, while on Windows,
/// redirects the output to `NUL`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A concrete `Output` type for subprocesses that indicates that the
/// `Subprocess` should not collect or redirect output from the child
/// process. On Unix-like systems, `DiscardedOutput` redirects the
/// standard output of the subprocess to `/dev/null`, while on Windows,
/// redirects the output to `NUL`.
/// A concrete output type for subprocesses that indicates that the
/// subprocess should not collect or redirect output from the child
/// process.
/// On Unix-like systems, `DiscardedOutput` redirects the
/// standard output of the subprocess to `/dev/null`, while on Windows,
/// redirects the output to `NUL`.

/// standard output of the subprocess to `/dev/null`, while on Windows,
/// redirects the output to `NUL`.
public struct DiscardedOutput: OutputProtocol {
/// The output type for this output option
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The output type for this output option
/// The type for the output.

return self.description(withIndent: 0)
}

/// A textual representation of this `PlatformOptions`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A textual representation of this `PlatformOptions`.
/// A debug oriented textual representation of the platform options.

// MARK: - ProcessIdentifier

/// A platform independent identifier for a Subprocess.
/// A platform-independent identifier for a Subprocess
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A platform-independent identifier for a Subprocess
/// A platform-independent identifier for a Subprocess.

/// The platform specific process identifier value
public let value: pid_t

/// Initialize a `ProcessIdentifier` with the given value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Initialize a `ProcessIdentifier` with the given value
/// Initialize a process identifier with the value you provide.

}

extension ProcessIdentifier: CustomStringConvertible, CustomDebugStringConvertible {
/// A textual representation of this `ProcessIdentifier`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A textual representation of this `ProcessIdentifier`.
/// A textual representation of the process identifier.

/// A textual representation of this `ProcessIdentifier`.
public var description: String { "\(self.value)" }

/// A textual representation of this `ProcessIdentifier`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A textual representation of this `ProcessIdentifier`.
/// A debug-oriented textual representation of the process identifier.

// MARK: - ProcessIdentifier

/// A platform independent identifier for a Subprocess.
/// A platform-independent identifier for a Subprocess
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A platform-independent identifier for a Subprocess
/// A platform-independent identifier for a subprocess.

public let value: pid_t

#if os(Linux) || os(Android) || os(FreeBSD)
/// Process file Descriptor (pidfd) for the running execution
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Process file Descriptor (pidfd) for the running execution
/// The process file descriptor (pidfd) for the running execution.

}

extension ProcessIdentifier: CustomStringConvertible, CustomDebugStringConvertible {
/// A textual representation of this `ProcessIdentifier`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A textual representation of this `ProcessIdentifier`.
/// A textual representation of the process identifier.

/// A textual representation of this `ProcessIdentifier`.
public var description: String { "\(self.value)" }

/// A textual representation of this `ProcessIdentifier`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A textual representation of this `ProcessIdentifier`.
/// A debug-oriented textual representation of the process identifier.

/// Always ends in sending a `.kill` signal at the end.
public var teardownSequence: [TeardownStep] = []

/// Initialize a `PlatformOptions` with default options.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Initialize a `PlatformOptions` with default options.
/// Create platform options with the default values.

public let processIdentifier: ProcessIdentifier
/// The termination status of the executed subprocess
public let terminationStatus: TerminationStatus
/// The captured standard output of the executed subprocess
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The captured standard output of the executed subprocess
/// The captured standard output of the executed subprocess.


extension CollectedResult: CustomStringConvertible
where Output.OutputType: CustomStringConvertible, Error.OutputType: CustomStringConvertible {
/// A textual representation of this `CollectedResult`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A textual representation of this `CollectedResult`.
/// A textual representation of the collected result.


extension CollectedResult: CustomDebugStringConvertible
where Output.OutputType: CustomDebugStringConvertible, Error.OutputType: CustomDebugStringConvertible {
/// A textual representation of this `CollectedResult`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A textual representation of this `CollectedResult`.
/// A debug-oriented textual representation of the collected result.

extension ExecutionResult: Hashable where Result: Hashable {}

extension ExecutionResult: CustomStringConvertible where Result: CustomStringConvertible {
/// A textual representation of this `ExecutionResult`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A textual representation of this `ExecutionResult`.
/// A textual representation of the execution result.

}

extension ExecutionResult: CustomDebugStringConvertible where Result: CustomDebugStringConvertible {
/// A textual representation of this `ExecutionResult`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A textual representation of this `ExecutionResult`.
/// A debug-oriented textual representation of this execution result.

@iCharlesHu
Copy link
Contributor Author

Thanks so much for looking into this @heckj !!

@iCharlesHu iCharlesHu force-pushed the charles/documentation-update branch from 138fcdd to 7b577a7 Compare September 2, 2025 21:03
@iCharlesHu iCharlesHu force-pushed the charles/documentation-update branch from 762dbc1 to cdb9e21 Compare September 3, 2025 03:52
@iCharlesHu iCharlesHu merged commit ae75fdf into swiftlang:main Sep 3, 2025
39 checks passed
@iCharlesHu iCharlesHu deleted the charles/documentation-update branch September 3, 2025 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants