-
Notifications
You must be signed in to change notification settings - Fork 146
Formally deprecate additionalSymbolGraphFiles
property
#777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dc5e2a5
7ac0e4c
3251c2c
776656b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ extension ConvertAction { | |
// into a dictionary. This will throw with a descriptive error upon failure. | ||
let parsedPlatforms = try PlatformArgumentParser.parse(convert.platforms) | ||
|
||
let additionalSymbolGraphFiles = convert.additionalSymbolGraphFiles + symbolGraphFiles( | ||
let additionalSymbolGraphFiles = (convert as _DeprecatedSymbolGraphFilesAccess).additionalSymbolGraphFiles + symbolGraphFiles( | ||
in: convert.additionalSymbolGraphDirectory | ||
) | ||
|
||
|
@@ -100,3 +100,8 @@ private func symbolGraphFiles(in directory: URL?) -> [URL] { | |
return subpaths.map { directory.appendingPathComponent($0) } | ||
.filter { DocumentationBundleFileTypes.isSymbolGraphFile($0) } | ||
} | ||
|
||
private protocol _DeprecatedSymbolGraphFilesAccess { | ||
var additionalSymbolGraphFiles: [URL] { get } | ||
} | ||
extension Docc.Convert: _DeprecatedSymbolGraphFilesAccess {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And, how does this actually work? By extending Docc.Convert so it conforms to a private protocol, are we preventing any other code from using the attributes ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC the aim here is to force There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That leaves us with 3 choices:
I opted for the third choice. The way this private protocol avoids the deprecation warning works in 3 steps:
It looks rather strange but it allows us to internally call the deprecated API without warnings about it being deprecated. I know that there aren't other places who access |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a common Swift idiom?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. Normally there's no need to cast a value to one of the protocols that it's known to conform to but here I'm leveraging the downcast to shadow the deprecated API with a non-deprecated API to avoid a deprecation warning. This comment explains how it works in more detail.