Skip to content

Conversation

@d-ronnqvist
Copy link
Contributor

@d-ronnqvist d-ronnqvist commented Nov 14, 2025

Bug/issue #, if applicable:

Summary

This starts adopting Swift Concurrency in two places of SwiftDocC.

  • Using async let bindings during context initialization simplifies this pattern

    var someResult: Something!
    
    discoveryGroup.async(queue: discoveryQueue) { [unowned self] in
        do {
            someResult = try doSomeWork()
        } catch {
            discoveryError.sync({
                if $0 == nil { $0 = error }
            })
        }
    }

    to something like

    async let someResult = try doSomeWork()
  • Using a throwing task group for rendering (turning documentation nodes into render nodes) allows that code to throw errors instead of turning them into fake Diagnostic values. This simplifies the calling code by not having it mix user-facing issues and unexpected errors (like failing to write a file to disk).

    Additionally, with the task groups code extracting it's easier to check for cancellations which enables docc preview to refresh faster when making edits in quick succession on larger projects.

    As a future direction we can build on the extracted task group code to update our concurrentMap and concurrentPerform helpers. However, their callers are somewhat deep and would need to be marked async which would need to propane up through their callers and their callers until reaching an already async method. For this reason, it might be better to work top-down instead until we reach these callers.

Dependencies

None

Testing

Nothing in particular. This isn't a user-facing change.

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • Updated documentation if necessary

@d-ronnqvist d-ronnqvist added the code cleanup Code cleanup *without* user facing changes label Nov 14, 2025
@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code cleanup Code cleanup *without* user facing changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant