Skip to content
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

Finalize the diagnostic engine if an error is thrown #637

Conversation

d-ronnqvist
Copy link
Contributor

Bug/issue #, if applicable: rdar://110782381

Summary

If an error is thrown before the documentation converter completes successfully, the diagnostic engine is never finalized. This means that diagnostic consumers that gather and write diagnostic as two separate steps won't write any diagnostics.

This PR changes that so that the diagnostic engine is finalized before the documentation converter returns from convert(...). It also makes the finalization synchronous so that callers can rely on any diagnostics having been written after `convert(...) ends—either successfully or with a thrown error.

Dependencies

None

Testing

  • Run docc convert with a --diagnostics-file /path/to/some-file.json and some content that result in an unexpected error (for example a symbol graph file with relationships but no symbols).

  • After the failed documentation build, the diagnostic file should have been created.

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

This ensures that any gathered diagnostics are printed before exiting.

rdar://110782381
@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist d-ronnqvist merged commit 477e491 into swiftlang:main Jun 22, 2023
@d-ronnqvist d-ronnqvist deleted the finalize-diagnostic-engine-when-error-is-thrown branch June 22, 2023 21:24
d-ronnqvist added a commit to d-ronnqvist/swift-docc that referenced this pull request Jun 26, 2023
This ensures that any gathered diagnostics are printed before exiting.

rdar://110782381
franklinsch pushed a commit that referenced this pull request Jun 28, 2023
This ensures that any gathered diagnostics are printed before exiting.

rdar://110782381
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants