func taskGroups()

in Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift [423:476]


    func taskGroups(for reference: ResolvedTopicReference) -> [ReferenceGroup]? {
        guard let node = try? documentationContext.entity(with: reference) else { return nil }
        
        let groups: [TaskGroup]?
        switch node.semantic {
        case let symbol as Symbol:
            groups = symbol.topics?.taskGroups
        case let article as Article:
            groups = article.topics?.taskGroups
        default:
            // No other semantic entities have topic groups.
            return nil
        }
        
        guard let taskGroups = groups, !taskGroups.isEmpty else { return nil }

        // Find the linking group
        var resolvedTaskGroups = [ReferenceGroup]()

        for group in taskGroups {
            let resolvedReferences = group.links.compactMap { link -> ResolvedTopicReference? in
                guard let destination = link.destination.flatMap(URL.init(string:)),
                    destination.scheme != nil,
                    let linkHost = destination.host else {
                    // Probably an unresolved/invalid URL, ignore.
                    return nil
                }
                
                // For external links, verify they've resolved successfully and return `nil` otherwise.
                if linkHost != reference.bundleIdentifier {
                    let externalReference = ResolvedTopicReference(
                        bundleIdentifier: linkHost,
                        path: destination.path,
                        sourceLanguages: node.availableSourceLanguages
                    )
                    if documentationContext.externallyResolvedSymbols.contains(externalReference) {
                        return externalReference
                    }
                    return nil
                }
                return ResolvedTopicReference(
                    bundleIdentifier: reference.bundleIdentifier,
                    path: destination.path,
                    sourceLanguages: node.availableSourceLanguages
                )
            }
            
            resolvedTaskGroups.append(
                ReferenceGroup(title: group.heading!.plainText, references: resolvedReferences)
            )
        }
        
        return resolvedTaskGroups
    }