Repository navigation
Conversation
c67f2f9 to
b72303d
Compare
| // A page without any availability information (for example a module without default availability) | ||
| // isn't deprecated. Without this check, `allSatisfy` returns true, which reflects the content as deprecated. | ||
| let hasAnyAvailabilityInformation = (knownPlatforms + customPlatformsByName.values).contains { $0.source != .initialValue } | ||
| guard hasAnyAvailabilityInformation else { | ||
| return false | ||
| } |
There was a problem hiding this comment.
I think that I'd prefer to fix this by populating the module's availability instead so that it behaves the same as all the other symbols.
If you replace https://github.com/swiftlang/swift-docc/blob/main/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift#L1315-L1322 with
var symbolBaseAvailability = Availability(defaultAvailability: inputs.info.defaultAvailability?.modules[moduleName])
symbolBaseAvailability.markAllEncounteredPlatforms(in: unifiedGraph)
documentationCache.reference(symbolID: moduleName).map { moduleReference in
var moduleAvailability = symbolBaseAvailability
if let moduleSymbol = documentationCache[moduleReference]?.unifiedSymbol {
for language in moduleSymbol.sourceLanguages {
moduleAvailability.addInSourceAvailability(from: moduleSymbol, matchingLanguage: language)
}
}
moduleAvailability.finalizePlatformFallbacks()
(documentationCache[moduleReference]?.semantic as! Symbol).consolidatedAvailability = .init(defaultVariantValue: moduleAvailability)
}the new test passes for me
There was a problem hiding this comment.
totally works for me, thank you! Let me circle that up and replace this PR's implementation. Any strong preference on breaking out that repeatable validation logic? Happy to do the lifting to make the tests better structured - slapped this out primarily to just show the issue and work it.
There was a problem hiding this comment.
Do you mean sharing it for those two callers in that one test or are you thinking that there would additional callers in other tests?
There was a problem hiding this comment.
no strong opinion here - was more just looking for high level guidance for when you thought it was worthwhile to break out a validation bit like we did here.
|
I applied your path and it brought up a complication in an existing test. Kinda need your input on the follow up, as I wasn't sure which way made more sense and don't know all the implications. When there's an Info.plist default with no version, this would overwrite that availability. Setup: the Info.plist declares iOS with no version, and the symbol graph is for iOS.
My read of the flow that gets us here:
A symbol with no in-source availability goes through the same steps and shows no platforms. With that, the module matches symbols, but it loses the Info.plist default. Which behavior do we want?
|
b72303d to
c6270f4
Compare
That's an annoying inconsistency in behavior between the module's page and other symbol pages that I had previously missed. In that case it might be better to start out with an What's important is that we capture both behaviors as new tests in
|
Use `String(contentsOf:encoding:)` instead of `String(contentsOf:)` and mark `PartialCopyFileManager` as final.
…marked deprecated A module that has no default availability, in-source availability, or `@Available` directive is incorrectly marked as deprecated in its topic render reference.
…cated Availability.isDeprecated used allSatisfy over the platforms. When no platform had any information, every platform was still unavailable, so allSatisfy was vacuously true and the page was marked deprecated. This affected modules without default availability from the Info.plist, which then showed a Deprecated badge where they're curated. Return false when no platform has any availability information.
…ated Build the module symbol's availability the same way as other symbols: mark the encountered platforms and add the module's in-source availability before finalizing platform fallbacks. Remove the isDeprecated guard that worked around the empty availability. Tighten the test: use an iOS symbol graph, and verify both the render node and the render reference for the module and the symbol.
The module page now gets the same iOS and iPadOS entries from the iOS symbol graph as symbols do, so list them in the expected platforms. testInheritDefaultAvailabilityOptions still fails. A module with a versionless iOS default availability no longer displays any platforms. Leave it failing until the maintainers decide how this should behave.
Cover modules with and without Info.plist default availability across symbol graph platforms, in-source availability on the module symbol, and multiple modules. Share the deprecation assertions between module and symbol checks. A module that is found in a symbol graph for a platform with a versionless default now displays the same platforms as symbols do. Update testInheritDefaultAvailabilityOptions to match.
Summary
fixes: #1704
A page with no availability information is incorrectly reported as deprecated. I think this is a regression from #1686.
Availability.isDeprecatedusesallSatisfyover the platforms, and every platform starts as.unavailable. If nothing ever adds information,allSatisfyis vacuously true. The page's topic render reference gets"deprecated": true. DocC-Render then strikes it through and adds a "Deprecated" badge wherever it's curated.Modules are the common case. A module's availability only comes from the Info.plist defaults. A module without defaults gets no other information.
isDeprecatednow returnsfalsewhen no platform, known or custom, has any availability information. A platform that is explicitly unavailable still counts as information, so symbols that are obsoleted or unavailable everywhere keep their current behavior.Dependencies
None.
Testing
Steps:
swift test --filter moduleWithoutAvailabilityInformationIsNotConsideredDeprecated. It fails because the module and its symbol are reported deprecated.docc converton a catalog with one module symbol graph and no Info.plist availability. Then checkreferencesin the module's render JSON for adeprecatedflag. The steps are in deprecated content regression in docc-main #1704.Checklist
./bin/testscript and it succeeded. I ranswift test(all Swift Testing and XCTest suites pass), but not the full script.