Skip to content

Conversation

@grynspan
Copy link
Contributor

@grynspan grynspan commented Nov 11, 2025

This PR adds prose documentation explaining how to create attachments and add them to tests.

Resolves #1143.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR adds prose documentation explaining how to create attachments and add
them to tests.

Resolves #1143.
@grynspan grynspan added this to the Swift 6.3.0 milestone Nov 11, 2025
@grynspan grynspan self-assigned this Nov 11, 2025
@grynspan grynspan added documentation 📚 Improvements or additions to documentation enhancement New feature or request attachments/activities 🖇️ Work related to attachments and/or activities image-attachments 📸 Work related to image attachments labels Nov 11, 2025
///
/// - ``Trait/savingAttachments(if:)``
///
/// By default, the testing library saves your attachments as soon as you call
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is all SPI.

@grynspan
Copy link
Contributor Author

Tracked internally as rdar://164478451.

Copy link
Contributor

@jerryjrchen jerryjrchen left a comment

Choose a reason for hiding this comment

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

Looks great!

Copy link

@jgmcnutt jgmcnutt left a comment

Choose a reason for hiding this comment

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

Some minor suggestions. Please let me know if you have any questions.

### Attach data or strings

If your test produces encoded data that you want to save as an attachment, you
can call ``Attachment/record(_:named:sourceLocation:)``:

Choose a reason for hiding this comment

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

Suggested change
can call ``Attachment/record(_:named:sourceLocation:)``:
can call ``Attachment/record(_:named:sourceLocation:)``.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using a colon here to introduce a code sample/snippet is pretty standard practice. Compare this (previously-reviewed) article: https://developer.apple.com/documentation/testing/enablinganddisabling

Since we're already doing it in other files, I'd prefer to remain consistent, but could I ask you to get a DevPubs verdict and, if changes are needed, we can apply them globally in another PR?

Copy link

@jgmcnutt jgmcnutt Nov 17, 2025

Choose a reason for hiding this comment

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

DevPubs verdict: We use the colon when we mention the snippet, such as "The following code example shows..." and "In the code below, X does Z....". If we don't mention the code, it isn't an introductory sentence and takes a period.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it sufficient to end the sentence(s) I have now and then add "For example:"? I do want to make sure it's clear that the following code is related to the preceding text and not just appearing out of nowhere.

If you can reliably estimate in advance how large the encoded representation
will be, implement ``Attachable/estimatedAttachmentByteCount``. The testing
library uses the value of this property as a hint to optimize memory and disk
usage:

Choose a reason for hiding this comment

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

Suggested change
usage:
usage.

Comment on lines +152 to +153
You can also implement ``Attachable/preferredName(for:basedOn:)`` if you wish to
customize the name of the attachment when it is saved:

Choose a reason for hiding this comment

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

Suggested change
You can also implement ``Attachable/preferredName(for:basedOn:)`` if you wish to
customize the name of the attachment when it is saved:
You can also implement ``Attachable/preferredName(for:basedOn:)`` if you want to
customize the name of the attachment when saving it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Holding for feedback on : vs .

grynspan and others added 12 commits November 17, 2025 11:39
…e.swift

Co-authored-by: jgmcnutt <jgmcnutt@me.com>
…e.swift

Co-authored-by: jgmcnutt <jgmcnutt@me.com>
…e.swift

Co-authored-by: jgmcnutt <jgmcnutt@me.com>
Co-authored-by: jgmcnutt <jgmcnutt@me.com>
Co-authored-by: jgmcnutt <jgmcnutt@me.com>
Co-authored-by: jgmcnutt <jgmcnutt@me.com>
Co-authored-by: jgmcnutt <jgmcnutt@me.com>
Co-authored-by: jgmcnutt <jgmcnutt@me.com>
Co-authored-by: jgmcnutt <jgmcnutt@me.com>
Co-authored-by: jgmcnutt <jgmcnutt@me.com>
@grynspan grynspan requested a review from jgmcnutt November 17, 2025 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

attachments/activities 🖇️ Work related to attachments and/or activities documentation 📚 Improvements or additions to documentation enhancement New feature or request image-attachments 📸 Work related to image attachments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write prose documentation for attachments

5 participants