-
Notifications
You must be signed in to change notification settings - Fork 166
Fix api collection icon rendering #1343
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
base: main
Are you sure you want to change the base?
Conversation
patshaughnessy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks good.
There are many different DocumentationNode.Kind values... have we tested if any other icons are incorrect?
9213698 to
b385a24
Compare
|
Hi Pat, I made some changes to address the radar concerns for cross-framework API collection icons, can you please take another look?
This radar is specific for API Collections, if more icons appear incorrect, we should fix them too, but probably in different PRs. :) Thanks! |
patshaughnessy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor suggestions. Thanks for the fix!
Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift
Outdated
Show resolved
Hide resolved
Tests/SwiftDocCTests/Rendering/DocumentationContentRendererTests.swift
Outdated
Show resolved
Hide resolved
d-ronnqvist
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't rely on the task groups information for this. Is there some other information that indicates that a external page is an API collection?
Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift
Outdated
Show resolved
Hide resolved
| /// Create a topic render render reference for this link summary and its content variants. | ||
| func makeTopicRenderReference() -> TopicRenderReference { | ||
| let (kind, role) = DocumentationContentRenderer.renderKindAndRole(kind, semantic: nil) | ||
| let (kind, role) = DocumentationContentRenderer.renderKindAndRole(kind, semantic: nil, linkSummary: self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Is there some other value about the link summary that we can use to determine if it's an API collection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After analyzing the LinkDestinationSummary structure and the actual Apple documentation data, I found that there are no reliable alternatives to taskGroups for identifying API Collections in external references. The available fields (title patterns, URL patterns, abstract content, references) would all be fragile heuristics.
We could add an optional role to LinkDestinationSummary, but that would be a much larger change. Would you prefer that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The taskGroup information isn't a reliable source for this information. It's not requited for documentation sources to include it and we are also talking about removing it because the link summary isn't meant to be a representation of the documentation hierarchy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there another DocumentationNode.Kind value that API collection pages should be using? I see that we have both collection and collectionGroup but I don't recall what either of those are meant to represent. If not, should we introduce a dedicated "API Collection" kind and use that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe collection is the root/framework page, and collectionGroup are API Collections or pages that groups symbol pages together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading the kind values documentation I would think that a framework would use module. Regardless, if we have a kind value that represents API collections then it sounds like we should use that to identify API collections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, both! I spoke with @d-ronnqvist and ended up taking a different approach, let me know your thoughts. :)
Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift
Outdated
Show resolved
Hide resolved
Adds test to verify that API Collections (articles with Topics sections) are correctly identified as .collectionGroup kind in linkable entities, ensuring cross-framework references display the correct icon. The test is temporarily skipped until the fix is implemented in the next commit. rdar://135837611
Ensures API Collections are correctly identified as collectionGroup kind in linkable entities by using DocumentationContentRenderer.roleForArticle logic. This fixes cross-framework references where API Collections were incorrectly showing Article icons instead of Collection Group icons. rdar://135837611
b385a24 to
c7d498f
Compare
Bug/issue: rdar://135837611
Summary
This PR addresses an issue where API Collections were displaying incorrect icons in external references. The issue occurred when external references to API Collections were rendering with
"role": "article"instead of"role": "collectionGroup", causing them to display article icons instead of the proper collection icons.The implementation adds the missing
.collectionGroupcase to therenderKindAndRolefunction to ensure API Collections render consistently as articles with the collectionGroup role, displaying the correct collection icon in both main documents and external references.Dependencies
None.
Testing
The functionality can be tested using the provided test case in
DocumentationContentRendererTests.swift:Checklist
./bin/testscript and it succeeded