-
Notifications
You must be signed in to change notification settings - Fork 166
Add a precondition for declaring a node as beta. #1055
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
Add a precondition for declaring a node as beta. #1055
Conversation
For a node to be declared as beta it has to contain at least a single availability item that contains all the already defined characteristics. This code adds a precondition where at least the node needs to have one availability item to be considered as potentially in beta. Before this change, if at somewhere in the code, the availability items got removed from the node, the node would be considered as beta. rdar://137762221
Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift
Outdated
Show resolved
Hide resolved
| ]) | ||
| let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) | ||
| let node = try context.entity(with: reference) | ||
| (node.semantic as? Symbol)?.availability = SymbolGraph.Symbol.Availability(availability: []) |
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 is not a blocking comment but something to keep in mind.
Modifying a page after the context has fully registered the data provider assumes that there are no derivatives of the original value elsewhere that was created while the context registered the data provider.
This means that the test could be exercising a different behavior than a real build would and could pass even though a real build would have a bug.
I think that there are no derivates of the availability information today, but there could be in the future in which case this test could hide a bug because it passes and there's no other test that exercises the real-build behavior.
Because of this, it's preferred to modify the inputs before they're registered with the context.
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.
It's true that data could be modified after the fact, but although this generally shouldn't be done, having this precondition adds an extra layer of security to the code.
….swift Co-authored-by: David Rönnqvist <[email protected]>
|
@swift-ci please test |
|
@swift-ci please test |
Bug/issue #, if applicable: rdar://137762221
Summary
A node can only be declared as beta if it contains at least one availability item that includes all the defined characteristics. This code introduces a precondition requiring the node to have at least one availability item to be considered as potentially in beta.
Before this change, a node would be considered as beta when its availability set was empty.
Dependencies
N/A
Testing
Review unit tests.
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/testscript and it succeeded