-
Notifications
You must be signed in to change notification settings - Fork 163
Index external entities after local entities #1328
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
Index external entities after local entities #1328
Conversation
|
Open question: Do we need any further logging / assertions / checking logic when we skip a node when building the navigator? swift-docc/Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift Lines 711 to 713 in b27288d
|
ee44242 to
9967d12
Compare
|
@swift-ci please test |
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.
This fix looks good to me but I think it'd be good to find a different location for this test and see if it can use TestExternalReferenceResolver instead of a real on-disk script.
9967d12 to
61f5c90
Compare
|
@d-ronnqvist I've moved the test to |
61f5c90 to
0bbd9b8
Compare
|
@swift-ci please test |
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.
This looks good to me.
I think the test can be simplified by reusing an existing test resolver kind but we can make that change in a follow up PR at some points.
The navigation indexing code skips all further nodes after it has already indexed a node with a given identifier [1]. This can result in an odd interaction when there is an external link which is resolved to a path that the bundle serves itself (or more colloquially, a catalog has an external link to itself). Since external entities are indexed before local entities, they were always be preferred over local entities, resulting in local entities mistakenly being dropped from the navigator altogether. The resulting navigator is incorrect and missing nodes, due to external entities not having hierarchy information. This issue was introduced when support for external links in the navigator was introduced. This commit updates `ConvertActionConverter` to always index local entities first. If any external entities clash with local entities, they will be resolved as the local entity (including its hierarchy) in the navigator. Fixes rdar://163018922. [1]: https://github.com/swiftlang/swift-docc/blob/b27288dd99b0e2715ed1a2d5720cd0f23118c030/Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift#L711-L713 [2]: swiftlang@65aaf92
0bbd9b8 to
30101c9
Compare
|
@swift-ci please test |
Bug/issue #, if applicable: rdar://163018922
Summary
The navigation indexing code skips all further nodes after it has already indexed a node with a given identifier 1.
This can result in an odd interaction when there is an external link which is resolved to a path that the bundle serves itself (or more colloquially, a catalog has an external link to itself).
Since external entities are indexed before local entities, they were always be preferred over local entities, resulting in local entities mistakenly being dropped from the navigator altogether. The resulting navigator is incorrect and missing nodes, due to external entities not having hierarchy information. This issue was introduced when support for external links in the navigator was introduced.
This PR updates
ConvertActionConverterto always index local entities first. If any external entities clash with local entities, they will be resolved as the local entity (including its hierarchy) in the navigator.Dependencies
N/A
Testing
Use the test bundle from Example.zip.
Steps:
DOCC_LINK_RESOLVER_EXECUTABLE=Example/test-data-external-resolver swift run docc preview Example/Example.doccArticleC, curated in local nodeArticleB.This can in general be verified by adding an external link to a page's content, which links to an entity that resolves to the same relative presentation URL of a local entity. If the resulting navigator is unchanged when adding this external links vs removing it, then the code is working as expected.
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/testscript and it succeeded[ ] Updated documentation if necessaryN/A