Documentation curation - FoundationEssentials - #2209
Draft
invalidname wants to merge 33 commits into
Draft
Conversation
parkera
reviewed
Aug 26, 2026
| /// | ||
| /// ```swift | ||
| /// attributedString.foregroundColor = .green | ||
| /// attributedString.link = URL(string:"https://example.com") |
Contributor
There was a problem hiding this comment.
Suggested change
| /// attributedString.link = URL(string:"https://example.com") | |
| /// attributedString.link = URL(string: "https://example.com") |
Note, though, that this initializer has an optional result. Not sure how you want to handle it here.
Author
There was a problem hiding this comment.
Ow. Good point. I want to replace the UIKit/SwiftUI attribute from the previous docs with something that exists within FoundationAttributes and is interesting, but you're right that all three of these snippets (all the way back to line 40) need to deal with the optional from URL(string:).
Author
There was a problem hiding this comment.
Update: I still need to address this. I think it's reasonable to just force-unwrap in this case, since we can visually inspect the string and verify that it will parse correctly.
Also removed public mentions of Objective-C interoperability. Left them in for code that's under the control of conditional compilation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds out the
.docccatalog with curation for all types in FoundationEssentials, to provide a browsable version of the documentation.Tip: Reviewers may find it easier to review the browsable preview rather than combing through the raw
.mdfiles directly.Motivation:
This is the first step to hosting swift-foundation documentation on docs.swift.org, much the same way the Swift Standard Library documentation is now hosted there.
@parkera migrated much of the developer.apple.com documentation for Foundation to source files in #1917. However, if you build documentation today, all the top-level symbols would simply appear in a long list of "Classes", "Protocols", etc., without semantic organization.
This PR adds curation to the
.docccatalog, which organizes all the symbols into topics, which makes the docs browsable. You can learn more about DocC curation in Adding Structure to Your Documentation Pages.Modifications:
This PR adds several hundred
.mdfiles toFoundationEssentials.doccto provide the curation. It also corrects mistakes in the source doc comments copied over from Apple's Foundation, mostly to fix links that don't resolve, which is often due to the partitioning of swift-foundation into separate modules for FoundationEssentials and FoundationInternationalization.Result:
Building out the curation in the
.docccatalog allows you to drill down by topic: look in "Strings and Text" forAttributedStringor "Dates and Times" forCalendar.You can browse a preview of documentation built from this branch here.
Also, this PR curates the extensions that FoundationEssentials makes to types in the Standard Library, such as adding
filter(_:)andsort(_:)methods toSequencethat take a FoundationPredicateandComparator, respectively. Since the docs-building process for the Standard Library knows nothing about the extensions that swift-foundation makes to stdlib, this is the only place we can document those extensions (short of some completely out-of-band solution, like writing pages by hand).This PR is mostly limited to FoundationEssentials. A later PR will curate FoundationInternationalization. When both are merged into a release branch, we'll be able to host these docs on swift.org.
Some symbols lack documentation; adding DocC comments to those symbols can happen in subsequent PRs, and we appreciate any contributions.
Testing:
Does not require testing. The only changes are to documentation comments in source and Markdown curation files in the
.docccatalog.