-
Notifications
You must be signed in to change notification settings - Fork 418
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
all-modules-page: Validate cross-module links during resolution #2901
all-modules-page: Validate cross-module links during resolution #2901
Conversation
The existing behavior was just taking the first module that includes the package name of a given reference, so this resulted in broken links when a package is split across multiple modules. This change checks to ensure the resolved file exists before choosing it as the target for the resolved link. Signed-off-by: Eddie Ringle <[email protected]>
val modulePath = context.configuration.outputDir.absolutePath | ||
val validLink = resolvedLinks.firstOrNull { | ||
val absolutePath = File(modulePath + it) | ||
absolutePath.isFile |
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 checks assumes that dependee submodules have been already processed but that is upto process order
in all-modules-page
plugin. For our project it lead to situation where same DRI was sometimes resolved and sometimes not.
I workaround it by checking paths against Dokka's output in submodules since partial tasks will be done before multimodule starts but that is not clean solution.
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 agree. Thank you for noticing it. The workaround is correct, but it should not depend on particular paths like build/dokka/htmlMultiModule
or build/dokka/htmlPartial/
. It would be great to use module.sourceOutputDirectory
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 so much for your contribution and sorry for the delay. The issue is very painful for Dokka.
I left the comments in the review.
Could you rebase on master
? I'm afraid some files have been moved.
val validLink = resolvedLinks.firstOrNull { | ||
val absolutePath = File(modulePath + it) | ||
absolutePath.isFile | ||
} ?: return null |
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.
Will it not work for the non-local external package-list
at all? See the example with the serialization
library from External documentation links configuration. Can you fix it, please?
It is nice to fix the issue at least for cross-module links.
A check of existing external URLs online can be excessive and Dokka can be run without access to the Internet.
Also, I think the fix should check links only if resolvedLinks
has more than one link. What do you think? It can help avoid unexpected behaviour with resolving cross-module links.
This fix is local and temporary. We have a long-term plan #3368.
@@ -56,7 +56,7 @@ class ResolveLinkCommandResolutionTest : MultiModuleAbstractTest() { | |||
} | |||
} | |||
|
|||
val contentFile = setup(link) | |||
val contentFile = setup(link, testedDri) |
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.
Fixes #2272. There is a situation where 2 (or more) gradle modules have the same package and dokka doesn’t know where to link. E.g. The class com.example.classA is in moduleA and com.example.classB is in moduleB moduleC depends on moduleA and moduleB. In moduleC: there is a link [com.example.classB]. Having only package-list, dokka doesn’t know where to link, since the package com.example is in both modules. This is short-term and temporary solution of #3368 to cover a case of links between only local modules in a project. It is based on #2901 from @EddieRingle. It generates an external link depending on a check if the local link exists. The check works only when the number of possible resolved links are more than one. * all-modules-page: Validate cross-module links during resolution The existing behavior was just taking the first module that includes the package name of a given reference, so this resulted in broken links when a package is split across multiple modules. This change checks to ensure the resolved file exists before choosing it as the target for the resolved link. Signed-off-by: Eddie Ringle <[email protected]> * Check links only if resolved links has more than one link * Add integration test * Refactor * Add comment --------- Signed-off-by: Eddie Ringle <[email protected]> Co-authored-by: Eddie Ringle <[email protected]>
Fixes #2272. There is a situation where 2 (or more) gradle modules have the same package and dokka doesn’t know where to link. E.g. The class com.example.classA is in moduleA and com.example.classB is in moduleB moduleC depends on moduleA and moduleB. In moduleC: there is a link [com.example.classB]. Having only package-list, dokka doesn’t know where to link, since the package com.example is in both modules. This is short-term and temporary solution of #3368 to cover a case of links between only local modules in a project. It is based on #2901 from @EddieRingle. It generates an external link depending on a check if the local link exists. The check works only when the number of possible resolved links are more than one. * all-modules-page: Validate cross-module links during resolution The existing behavior was just taking the first module that includes the package name of a given reference, so this resulted in broken links when a package is split across multiple modules. This change checks to ensure the resolved file exists before choosing it as the target for the resolved link. Signed-off-by: Eddie Ringle <[email protected]> * Check links only if resolved links has more than one link * Add integration test * Refactor * Add comment --------- Signed-off-by: Eddie Ringle <[email protected]> Co-authored-by: Eddie Ringle <[email protected]> (cherry picked from commit 6904571)
Fixes #2272. There is a situation where 2 (or more) gradle modules have the same package and dokka doesn’t know where to link. E.g. The class com.example.classA is in moduleA and com.example.classB is in moduleB moduleC depends on moduleA and moduleB. In moduleC: there is a link [com.example.classB]. Having only package-list, dokka doesn’t know where to link, since the package com.example is in both modules. This is short-term and temporary solution of #3368 to cover a case of links between only local modules in a project. It is based on #2901 from @EddieRingle. It generates an external link depending on a check if the local link exists. The check works only when the number of possible resolved links are more than one. * all-modules-page: Validate cross-module links during resolution The existing behavior was just taking the first module that includes the package name of a given reference, so this resulted in broken links when a package is split across multiple modules. This change checks to ensure the resolved file exists before choosing it as the target for the resolved link. Signed-off-by: Eddie Ringle <[email protected]> * Check links only if resolved links has more than one link * Add integration test * Refactor * Add comment --------- Signed-off-by: Eddie Ringle <[email protected]> Co-authored-by: Eddie Ringle <[email protected]>
I scanned the list of open issues but didn't spot one that matched my experience directly, but the closest might be #2037 or #2272. I'm not sure if this is necessarily the correct or ideal fix, and the underlying wider issue of supporting split packages probably requires further changes, but I did want to at least share this as it makes Dokka usable for our use-cases.
From commit message: