Skip to content

Fix a crash when linking to a symbol that doesn't have a page #617

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

Merged

Conversation

d-ronnqvist
Copy link
Contributor

@d-ronnqvist d-ronnqvist commented Jun 8, 2023

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

Summary

This fixes a crash when writing a symbol link to a symbol that doesn't have a page.

The hierarchy based link resolver used to assume that every symbol from the symbol graph files could be linked to but that isn't true. Some default implementation symbols don't have pages in the documentation build and aren't available for linking.

With this change, the link resolver detects that there is no page for the found symbol and raises a specific error message.

Dependencies

None

Testing

In a project where extension symbols are disabled (DOCC_EXTRACT_EXTENSION_SYMBOLS = NO in Xcode, --exclude-extended-types with the Swift-DocC plugin

  • Extend an external protocol with a new public symbol. For example

    extension Identifiable {
        public func something() {}
    }
  • Link to the symbol on the extended type. For example

    /// ``Identifiable/something()``
    public struct Something { }

Instead of crashing, DocC should warn that the symbol has no page and isn't available for linking.

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
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist d-ronnqvist merged commit cf83a80 into swiftlang:main Jun 8, 2023
@d-ronnqvist d-ronnqvist deleted the link-to-symbol-without-page branch June 8, 2023 23:09
d-ronnqvist added a commit to d-ronnqvist/swift-docc that referenced this pull request Jun 8, 2023
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