-
Notifications
You must be signed in to change notification settings - Fork 128
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
[external-links] Display frameworks as beta only if all platforms are beta #938
Conversation
a50e773
to
0cab664
Compare
@swift-ci please test |
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.
Looks good - just wondering if this is the right time for a larger refactoring to avoid duplicating more code like this. Maybe we merge this and then take on the larger work in another PR?
@@ -182,6 +182,15 @@ private extension Sequence<DeclarationRenderSection.Token> { | |||
// MARK: ExternalEntity | |||
|
|||
private extension LinkDestinationSummary { | |||
/// A value that indicates whether this symbol is under development and likely to change. |
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.
Looks like you're adding exactly the same code to both LinkDestinationSummary
and OutOfProcessReferenceResolver.ResolvedInformation
- would it be worth introducing a protocol?
Actually I just saw this comment:
public struct ResolvedInformation: Codable {
// This type is duplicating the information from LinkDestinationSummary with some minor differences.
// Changes generally need to be made in both places. It would be good to replace this with LinkDestinationSummary.
// FIXME: https://github.com/apple/swift-docc/issues/802
Is this a good time to take on this refactoring work?
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.
Yes that comment was exactly my reasoning for duplicating the API as closely as possible, thanks for calling that out!
I'll look into refactoring the code to see how much of a code change it would be to unify the code paths.
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.
The change to unify the code paths appears to be quite involved, I'll look into it further tomorrow but I think we should tackle that as a separate PR regardless.
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.
That's definitely for a separate PR. It's would both be quite involved and a bit of a risky change.
#802
Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift
Outdated
Show resolved
Hide resolved
Tests/SwiftDocCTests/Test Bundles/AvailabilityBetaBundle.docc/Info.plist
Outdated
Show resolved
Hide resolved
Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift
Outdated
Show resolved
Hide resolved
Changes the behaviour of external link resolution in `OutOfProcessReferenceResolver` to only display a framework to be in beta if all the platforms its supported in are in beta. This makes it match the behaviour for internal link resolution, so that the behaviour is consistent whether you're linking to a symbol internally within a framework or externally from another framework. Resolves rdar://128997995.
Makes changes to `OutOfProcessReferenceResolver .ResolvedInformation` so that it can be replaced by `LinkDestinationSummary` at some point in the future. Both `OutOfProcessReferenceResolver .ResolvedInformation` and `LinkDestinationSummary` now contain information about whether the resolved external link points to a symbol in beta or not, using equivalent API. This is an attempt at keeping both of the logics about whether an external symbol is in beta in sync with each other. Hopefully in the future we can unify and have the same code path for both, but right now the logic is duplicated (and equal). Resolves rdar://128997995.
Adds a unit test which verifies that the logic for determining whether a symbol is in beta when using `ExternalPathHierarchyResolver` is as expected. Resolves rdar://128997995.
0cab664
to
d25a051
Compare
Test file `OutOfProcessReferenceResolverTests` had inconsistent and confusing formatting, particularly with how the type of `makeResolver` was being defined across multiple lines in a way inconsistent with the rest of the codebase. `makeResolver` is now declared as a one-liner and fixes other minor formatting/spacing issues.
The file isn't needed, so removing it.
We want to avoid spreading the configure context parameter to the other test helpers, as we're slowly working to make the context not be configured after creation. Instead, `ExternalPathHierarchyResolverTests` now calls the underlying `loadBundle(from:configureContext:)` directly,
@swift-ci please test |
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.
This looks great. Thank you
… beta (swiftlang#938) * Display frameworks as beta only if all platforms are beta Changes the behaviour of external link resolution in `OutOfProcessReferenceResolver` to only display a framework to be in beta if all the platforms its supported in are in beta. This makes it match the behaviour for internal link resolution, so that the behaviour is consistent whether you're linking to a symbol internally within a framework or externally from another framework. * Refactor code to have same behaviour in both external link resolvers Makes changes to `OutOfProcessReferenceResolver .ResolvedInformation` so that it can be replaced by `LinkDestinationSummary` at some point in the future. Both `OutOfProcessReferenceResolver .ResolvedInformation` and `LinkDestinationSummary` now contain information about whether the resolved external link points to a symbol in beta or not, using equivalent API. This is an attempt at keeping both of the logics about whether an external symbol is in beta in sync with each other. Hopefully in the future we can unify and have the same code path for both, but right now the logic is duplicated (and equal). * Add a test for beta logic in ExternalPathHierarchyResolver Adds a unit test which verifies that the logic for determining whether a symbol is in beta when using `ExternalPathHierarchyResolver` is as expected. * Fix formatting Test file `OutOfProcessReferenceResolverTests` had inconsistent and confusing formatting, particularly with how the type of `makeResolver` was being defined across multiple lines in a way inconsistent with the rest of the codebase. `makeResolver` is now declared as a one-liner and fixes other minor formatting/spacing issues. * Remove noop Info.plist The file isn't needed, so removing it. * Remove changes to testBundleAndContext helpers We want to avoid spreading the configure context parameter to the other test helpers, as we're slowly working to make the context not be configured after creation. Instead, `ExternalPathHierarchyResolverTests` now calls the underlying `loadBundle(from:configureContext:)` directly. --- Resolves rdar://128997995.
Bug/issue #, if applicable: rdar://128997995
Summary
Symbols can have an availability per platform (iOS, macOS, etc), each of which can be marked as "beta" by providing some metadata when invoking
docc
:A top-level badge is sometimes rendered for a symbol, depending on its platform availability.
Currently there is a mismatch in behaviour where:
https://github.com/apple/swift-docc/blob/8f1a9d206ed6cdcf3dccb091fa57216c6d546f21/Sources/SwiftDocC/Infrastructure/External%20Data/OutOfProcessReferenceResolver.swift#L158
https://github.com/apple/swift-docc/blob/8f1a9d206ed6cdcf3dccb091fa57216c6d546f21/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift#L208-L240
This behaviour is inconsistent and can be confusing for documentation writers. This PR proposes unifying the behaviour so that a symbol is shown as beta if all of its available platforms are in beta.
Implementation
Changes the behaviour of external link resolution in
OutOfProcessReferenceResolver
to only display a framework to be in beta if all the platforms its supported in are in beta.This makes it match the behaviour for internal link resolution, so that the behaviour is consistent whether you're linking to a symbol internally within a framework or externally from another framework.
Also modifies
LinkDestinationSummary
to keep both of the external symbol resolution code paths in sync with each other. Hopefully in the future we can unify and have the same code path for both, but right now the logic is duplicated (and equal).Dependencies
N/A.
Testing
You can set up a link resolver locally which has beta platform information in order to verify this fix:
link-resolver.zip
Excerpt:
TestPackage.zip
Steps:
link-resolver
andTestPackage
.Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/test
script and it succeededVerification
Unit tests
Added unit tests for
OutOfProcessReferenceResolver
andExternalPathHierarchyResolver
since these changes affect both types of external link resolution.Ran
./bin/test
:Site rendering
Documentation
As far as I can tell, no changes to the documentation are needed.