-
Notifications
You must be signed in to change notification settings - Fork 167
Register references resolved by fallback resolvers #135
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
Register references resolved by fallback resolvers #135
Conversation
|
@swift-ci please test |
When resolving a link via a fallback resolver (i.e., a resolver that resolves additional content for the bundle's identifier), register the reference in the documentation context so that it can be looked up via its absolute URL string. This is important for subsequent link resolution requests, in order for the reference to be looked up in the context rather than getting resolved again. rdar://91545038
1812a24 to
6cb8142
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.
As a follow up it would be nice to rename registerReference(_:) and referenceIndex to be more specific. These have broad sounding names but are used for a more narrow purpose (only for local symbol references from what I could tell).
|
I'm not entirely following what's happening here, but this is concerning:
Using a fully-qualified url including the scheme is invalid within double-backtick symbol links; only paths should be allowed there. |
I don't see where percent-encoding is happening that PR. In any case, why is it correct to percent-encode symbol links? |
|
Yes, having a full URL with a host is odd to have in a symbol link. DocC is correctly percent-encoding the symbol link destination so that's it's a valid URL path. This stems from |
|
@swift-ci please test |
When resolving a link via a fallback resolver (i.e., a resolver that resolves additional content for the bundle's identifier), register the reference in the documentation context so that it can be looked up via its absolute URL string. This is important for subsequent link resolution requests, in order for the reference to be looked up in the context rather than getting resolved again. rdar://91545038
When resolving a link via a fallback resolver (i.e., a resolver that resolves additional content for the bundle's identifier), register the reference in the documentation context so that it can be looked up via its absolute URL string. This is important for subsequent link resolution requests, in order for the reference to be looked up in the context rather than getting resolved again. rdar://91545038
When resolving a link via a fallback resolver (i.e., a resolver that resolves additional content for the bundle's identifier), register the reference in the documentation context so that it can be looked up via its absolute URL string. This is important for subsequent link resolution requests, in order for the reference to be looked up in the context rather than getting resolved again. rdar://91545038
Bug/issue #, if applicable: rdar://91545038
Summary
Resolves an issue when using
ConvertServicewhere link resolution fails in doc comments of top-level symbols. For example, in:The link to
bar()does not resolve.The issue started appearing with #74, where DocC started (correctly) percent-encoding
:characters in symbol links. The reason is that whenReferenceResolverresolves symbol links, it rewrites them with their full absolute link:``Foo/bar()``becomes``doc://org.swift.example/documentation/Foo/bar()``.When resolving the link again (in
RenderNodeTranslator) during a compilation build (notConvertService), the URL of the symbol link is looked up inDocumentationContext.referencesIndex, which contains an absolute URL -> resolved reference mapping. This mapping is populated during bundle registration.However, when using
ConvertService, externally-resolved references that are members of the bundle being compiled were not getting added to thereferencesIndexmapping. This meant that the reference was getting resolved externally again rather than being looked up in the index.Then, with #74,
``doc://org.swift.example/documentation/Foo/bar() ``(correctly) became a URL with pathdoc://org.swift.example/documentation/Foo/bar()rather than a URL with path/documentation/Foo/bar(). Hence, the resolution request being made was fordoc://org.swift.example+ the path, i.e.,doc://org.swift.example/doc://org.swift.example/documentation/Foo/bar(), which is invalid. This was never an issue for regulardocc-based compilations, because the reference was looked up inDocumentationContext.referencesIndexand never re-resolved.This PR aligns the
ConvertServiceanddocc-based compilations by registering references resolved by fallback resolvers in the documentation context, so that they can be looked up for subsequent resolutions.Dependencies
None.
Testing
Build documentation for the Swift example shown above using
ConvertServiceand verify that the link resolves.Checklist
./bin/testscript and it succeeded