-
Notifications
You must be signed in to change notification settings - Fork 710
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
More control delegated for external link resolvers #2066
More control delegated for external link resolvers #2066
Conversation
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 like the idea of giving more control here... a few comments, and a question:
Why should code have access to the reflection containing the link when resolving a link to something outside of the documentation?
src/lib/converter/converter.ts
Outdated
part?: CommentDisplayPart, | ||
refl?: Reflection |
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.
Shouldn't these be non-optional, given your changes the array type above?
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.
It was made optional because of usage of this function in LinkResolverPlugin
(line 53). I didn't catch the purpose of using this function there, and for safety decided to change resolveExternalLink
signature in order to avoid modifying of this code.
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.
That is for links to types declared outside of the project, e.g.:
import { Bar } from "external-lib"
export function foo(bar: Bar) {}
There might be a legitimate use case for this, but I'm not seeing it. Why should code intended to resolve links to pages outside the documentation have this? |
In my case, we have few libraries, which have imports between them, but typedoc combines them all into one useful documentation (by another plugin). With current logic, typedoc resolves links to our own entities like it is external. But in fact, somewhere in reflections tree is a reflection that contains information about this entity, and I passes reflection, where link is located, to build relative links between these entities. |
That shouldn't be necessary in an ideal world... but given how much time I'm spending here... probably not going to be fixed soon, and this isn't a huge wart. I guess I'm fine with it. |
Also swap argument order so that the possibly undefined parameter is last.
Thanks! I'll get this released by Monday at the latest. |
Adding external link resolvers was a great idea, but in fact, it is useless for
{@link} tags which cannot be resolved
(from documentation), becauselinkResolver
passes into external resolvers onlyDeclarationReference
, that will be invalid for links in formats that is not supported. So external resolver will know about fact that some link can't be resolved, but can't do anythingabout it.
I offer an improvement:
part: CommentDisplayPart
andreflection: Reflection
) to external resolverExternalResolveAttempt
andExternalResolveResult
types as API for external resolver