From 56199ef712c442a960e11ec9a7bff6de4bc4a532 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Fri, 28 Aug 2020 13:15:46 +0200 Subject: Missing javadoc resources on windows --- .../JavadocContentToTemplateMapTranslator.kt | 3 +- .../javadoc/JavadocLocationTemplateMapTest.kt | 38 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocLocationTemplateMapTest.kt diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToTemplateMapTranslator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToTemplateMapTranslator.kt index 88bd90c3..46cad6f5 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToTemplateMapTranslator.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToTemplateMapTranslator.kt @@ -13,6 +13,7 @@ import org.jetbrains.dokka.model.InheritedFunction import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.utilities.formatToEndWithHtml +import java.io.File import java.nio.file.Paths internal class JavadocContentToTemplateMapTranslator( @@ -47,7 +48,7 @@ internal class JavadocContentToTemplateMapTranslator( else -> run { val link = locationProvider.resolve(node, skipExtension = true) val dir = Paths.get(link).parent?.toNormalized().orEmpty() - return dir.split("/").filter { it.isNotEmpty() }.joinToString("/") { ".." }.let { + return dir.split(File.separator).filter { it.isNotEmpty() }.joinToString("/") { ".." }.let { if (it.isNotEmpty()) "$it/" else it } } diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocLocationTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocLocationTemplateMapTest.kt new file mode 100644 index 00000000..ce14d675 --- /dev/null +++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocLocationTemplateMapTest.kt @@ -0,0 +1,38 @@ +package org.jetbrains.dokka.javadoc + +import org.jetbrains.dokka.javadoc.pages.JavadocClasslikePageNode +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test + +internal class JavadocLocationTemplateMapTest : AbstractJavadocTemplateMapTest() { + @Test + fun `should have correct location to root from class`(){ + dualTestTemplateMapInline( + kotlin = + """ + /src/source0.kt + package com.test.package0 + /** + * Documentation for TestClass + */ + class TestClass + """, + java = + """ + /src/com/test/package0/TestClass.java + package com.test.package0; + /** + * Documentation for TestClass + */ + public final class TestClass {} + """ + ) { + val map = singlePageOfType().templateMap + assertEquals("TestClass", map["name"]) + assertEquals("TestClass", map["title"]) + //This is taken from the expected location of files based on the package, so: + //com -> test -> package0 + assertEquals("../../../", map["pathToRoot"]) + } + } +} \ No newline at end of file -- cgit