Repository: kotlin/dokka
Issue: Sources tab is not displayed in dokkaHtml format

Bug is regression. Build to reproduce: 1.4.0-dev-44. Works fine in 1.4.0-rc
Configuration:
```
            named("main") {
                sourceLink{
                    localDirectory.set(file("src/main/kotlin"))
                    remoteUrl.set(URL("https://github.com/kamilok1965/dokka-example/tree/master/src/jvmMain/kotlin"))
                    remoteLineSuffix.set("#L")
                }
            }
```
I've attached the project to reproduce.
[App.zip](https://github.com/Kotlin/dokka/files/5108691/App.zip)


Changed files:
testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt
plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt

diff --git a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
index 8eb7208bd..8f6f09fbf 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
@@ -16,6 +16,7 @@ import org.jetbrains.dokka.transformers.pages.PageTransformer
 import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithSource
 import org.jetbrains.kotlin.resolve.source.getPsi
 import org.jetbrains.kotlin.utils.addToStdlib.cast
+import java.io.File
 
 class SourceLinksTransformer(val context: DokkaContext, val builder: PageContentBuilder) : PageTransformer {
 
@@ -35,7 +36,7 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent
 
     private fun resolveSources(documentable: WithExpectActual) = documentable.sources
         .mapNotNull { entry ->
-            getSourceLinks().find { entry.value.path.contains(it.path) && it.sourceSetData == entry.key }?.let {
+            getSourceLinks().find { File(entry.value.path).startsWith(it.path) && it.sourceSetData == entry.key }?.let {
                 Pair(
                     entry.key,
                     entry.value.toLink(it)
@@ -74,6 +75,9 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent
     }
 
     private fun DocumentableSource.toLink(sourceLink: SourceLink): String {
+        val sourcePath = File(this.path).canonicalPath.replace("\\\\", "/")
+        val sourceLinkPath = File(sourceLink.path).canonicalPath.replace("\\\\", "/")
+
         val lineNumber = when (this) {
             is DescriptorDocumentableSource -> this.descriptor
                 .cast<DeclarationDescriptorWithSource>()
@@ -83,7 +87,7 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent
             else -> null
         }
         return sourceLink.url +
-                this.path.split(sourceLink.path)[1] +
+                sourcePath.split(sourceLinkPath)[1] +
                 sourceLink.lineSuffix +
                 "${lineNumber ?: 1}"
     }
diff --git a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
index 4a7e059c9..952780c73 100644
--- a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
+++ b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
@@ -72,7 +72,7 @@ class LinkableContentTest : AbstractCoreTest() {
                     sourceRoots = listOf("$testDataDir/jsMain/kotlin")
                     sourceLinks = listOf(
                         SourceLinkDefinitionImpl(
-                            localDirectory = "jsMain/kotlin",
+                            localDirectory = "$testDataDir/jsMain/kotlin",
                             remoteUrl = URL("https://github.com/user/repo/tree/master/src/jsMain/kotlin"),
                             remoteLineSuffix = "#L"
                         )
@@ -85,7 +85,7 @@ class LinkableContentTest : AbstractCoreTest() {
                     sourceRoots = listOf("$testDataDir/jvmMain/kotlin")
                     sourceLinks = listOf(
                         SourceLinkDefinitionImpl(
-                            localDirectory = "jvmMain/kotlin",
+                            localDirectory = "$testDataDir/jvmMain/kotlin",
                             remoteUrl = URL("https://github.com/user/repo/tree/master/src/jvmMain/kotlin"),
                             remoteLineSuffix = "#L"
                         )
@@ -221,7 +221,10 @@ class LinkableContentTest : AbstractCoreTest() {
                     child?.text == "S"
                 }?.safeAs<ContentDRILink>()
 
-                Assertions.assertEquals((sample.documentable as WithGenerics).generics.first().dri, returnTypeNode?.address)
+                Assertions.assertEquals(
+                    (sample.documentable as WithGenerics).generics.first().dri,
+                    returnTypeNode?.address
+                )
             }
         }
     }
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt
index a271e810c..e84bfd2c6 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt
@@ -27,7 +27,7 @@ class GradleSourceLinkBuilder(
 
     override fun build(): SourceLinkDefinitionImpl {
         return SourceLinkDefinitionImpl(
-            localDirectory = localDirectory.getSafe()?.absolutePath ?: project.projectDir.absolutePath,
+            localDirectory = localDirectory.getSafe()?.canonicalPath ?: project.projectDir.canonicalPath,
             remoteUrl = checkNotNull(remoteUrl.getSafe()) { "missing remoteUrl on source link" },
             remoteLineSuffix = remoteLineSuffix.getSafe()
         )
diff --git a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt
index 333642b1c..a23c27137 100644
--- a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt
+++ b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt
@@ -72,6 +72,11 @@ abstract class AbstractCoreTest(
                     }.toSet(),
                     suppressedFiles = sourceSet.suppressedFiles.map { file ->
                         testDirPath.toFile().resolve(file)
+                    }.toSet(),
+                    sourceLinks = sourceSet.sourceLinks.map { link ->
+                        link.copy(
+                            localDirectory = testDirPath.toFile().resolve(link.localDirectory).canonicalPath
+                        )
                     }.toSet()
                 )
             }