Skip to content

Commit

Permalink
Use a set of languages (instead of language IDs) for more readable code
Browse files Browse the repository at this point in the history
  • Loading branch information
d-ronnqvist committed Nov 7, 2024
1 parent a2e6f5e commit 6939109
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,14 @@ public struct AutomaticCuration {
return nil
}

let variantLanguageIDs = Set(variantsTraits.compactMap(\.interfaceLanguage))
let variantLanguages = Set(variantsTraits.compactMap { traits in
traits.interfaceLanguage.map { SourceLanguage(id: $0) }
})

func isRelevant(_ filteredGroup: DocumentationContentRenderer.ReferenceGroup) -> Bool {
// Check if the task group is filtered to a subset of languages
if let languageFilter = filteredGroup.languageFilter,
!languageFilter.contains(where: { variantLanguageIDs.contains($0.id) })
languageFilter.isDisjoint(with: variantLanguages)
{
// This group is only applicable to other languages than the given variant traits.
return false
Expand All @@ -194,8 +196,8 @@ public struct AutomaticCuration {
// Don't include the current node.
reference != node.reference
&&
// Filter out nodes that aren't available in any of the given traits.
context.sourceLanguages(for: reference).contains(where: { variantLanguageIDs.contains($0.id) })
// Don't include nodes that aren't available in any of the given traits.
!context.sourceLanguages(for: reference).isDisjoint(with: variantLanguages)
}
// Don't create too long See Also sections
.prefix(automaticSeeAlsoLimit)
Expand Down

0 comments on commit 6939109

Please sign in to comment.