-
Notifications
You must be signed in to change notification settings - Fork 1
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
Handle api links #32
base: parser
Are you sure you want to change the base?
Handle api links #32
Conversation
85fbb3d
to
23cb79d
Compare
7df7d05
to
9af2950
Compare
23cb79d
to
6475e0d
Compare
9af2950
to
dfa2760
Compare
dfa2760
to
ee01134
Compare
I tried to find out why (only some of) the (proper?) DRIs are not being resolved to the links. override fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode?): String? =
sourceSets.ifEmpty { setOf(null) }.mapNotNull { sourceSet ->
val driWithSourceSet = DRIWithSourceSet(dri, sourceSet)
getLocalLocation(driWithSourceSet, context)
?: getLocalLocation(driWithSourceSet.copy(dri = dri.copy(target = PointingToDeclaration)), context)
// Not found in PageGraph, that means it's an external link
?: getExternalLocation(dri, sourceSets)
?: getExternalLocation(dri.copy(target = PointingToDeclaration), sourceSets)
}.distinct().singleOrNull() To be precise... @romanowski do you have any ideas? |
|
||
}.let(allDRIs::get) | ||
|
||
private fun String.resolveLinkToApi() = when { |
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 will work only partially for Kotlin
since DRIs are a bir more complicated. @Kordyjan @kamildoleglo could you help here? Maybe we can reuse dokka code?
We should also create extension point to that will alow users to provide its own mapping String -> DRI?
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.
TBH I'd personally discourage creating DRIs
by hand if possible. Reusing the IntelliJ resolveKDocLink
method feels more correct here. It will certainly limit the types of links possible (eg. no linking to overloaded methods, because the KDoc specification does not allow it for now), but will be more fail-proof.
If you have to create the DRIs
manually though, the JavaClassReference
looks wrong for starters (not really sure what issue it resolves in Dokka TBH, I'll try to find out). Moreover, toplevel methods (classes, etc.) should have a null
packageName
, not a blank one. Also looks like it's going to fail for elements with generic attributes, because you're not creating TypeReferences
anywhere and for extension methods (and properties), because you're not setting the receiver
anywhere
ee01134
to
d6e65ec
Compare
I did not manage to handle top level functions and functions with params (?) yetI think that the DRI resolution for API links works fine now however there are still a few cases that do not work 😕
"bad" link resolution gives smth like: