Skip to content

Include symbols without common lang in navigator #1269

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

snprajwal
Copy link

@snprajwal snprajwal commented Aug 4, 2025

Bug/issue #, if applicable:

rdar://155522179

Summary

The Topics section has a filtering logic to ensure that it displays the correct variant of a referenced symbol (e.g. the Objective-C variant of the symbol is shown only for the Objective-C version of a page). If the page and symbol have no languages in common, the symbol will be shown anyway in order to not drop the reference completely. For example, if a Swift-only symbol is curated under an Objective-C only page, the symbol will be shown in the Topics section even though their languages don't match.

The navigator also has a similar filtering logic to display all references present in the Topics section. However, it drops a reference if the pages don't have any source languages in common. This results in cases where the navigator is incorrectly missing references that are present in the Topics section. This issue can be reproduced with the MixedLanguageFrameworkSingleLanguageCuration.docc test bundle by running xcrun docc preview Tests/SwiftDocCTests/Test\ Bundles/MixedLanguageFrameworkSingleLanguageCuration.docc and viewing the navigator in the preview.

This patch updates the navigator's filtering logic to include references if they do not share a common language with the relevant page.

Dependencies

None

Testing

  • Run swift docc preview Tests/SwiftDocCTests/Test\ Bundles/MixedLanguageFrameworkSingleLanguageCuration.docc
  • View the navigator in the preview and ensure that it shows the Objective-C-only symbols under the Swift-only symbol SwiftOnlyStruct2.

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

The Topics section has a filtering logic to ensure that it displays the correct variant of a referenced symbol (e.g. the Objective-C variant of the symbol is shown only for the Objective-C version of a page). If the page and symbol have no languages in common, the symbol will be shown anyway in order to not drop the reference completely. For example, if a Swift-only symbol is curated under an Objective-C only page, the symbol will be shown in the Topics section even though their languages don't match.

The navigator also has a similar filtering logic to display all references present in the Topics section. However, it drops a reference if the pages don't have any source languages in common. This results in cases where the navigator is incorrectly missing references that are present in the Topics section. This issue can be reproduced with the `MixedLanguageFrameworkSingleLanguageCuration.docc` test bundle by running `xcrun docc preview Tests/SwiftDocCTests/Test\ Bundles/MixedLanguageFrameworkSingleLanguageCuration.docc` and viewing the navigator in the preview.

This patch updates the navigator's filtering logic to include references if they do not share a common language with the relevant page.

rdar://155522179
@snprajwal
Copy link
Author

@swift-ci please test

Copy link
Contributor

@d-ronnqvist d-ronnqvist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless there's some information that I'm missing, this change in behavior feels like it's incorrect to me.

Comment on lines +911 to +914
.children
.first { $0.item.title == "SwiftOnlyStruct2" }?
.children
.contains { $0.item.title == "ObjectiveCOnlyClass" },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This behavior doesn't seem correct to me.

If I was browsing the Swift version of this documentation I would expect to not see any symbols that don't have Swift representations.

Similarly, if I was browsing the Objective-C version of this documentation I would expect to not see any symbols that don't have an Objective-C representation. Curating a symbol under a page that it has no overlapping languages with, like this, feels like something we should raise a warning about if we don't already.

IMO if a symbol is only curated in a location that is has no overlapping languages with, we should treat it as uncrated and fall back to the automatic default curation for that symbol.

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