aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
authorBłażej Kardyś <bkardys@virtuslab.com>2021-01-05 17:59:38 +0100
committerGitHub <noreply@github.com>2021-01-05 17:59:38 +0100
commit1618e552c136e25d86bf0708e0d760841c77c139 (patch)
treec608ce91b020bb0ecbfe75d0f456a0eae84b4c51 /plugins/base
parentef98e4b6505c3fdd192b1d5057c718079d27b972 (diff)
downloaddokka-1618e552c136e25d86bf0708e0d760841c77c139.tar.gz
dokka-1618e552c136e25d86bf0708e0d760841c77c139.tar.bz2
dokka-1618e552c136e25d86bf0708e0d760841c77c139.zip
Versioning (#1654)
* Adding versioning mechanism for multimodule * Versioning improvement * Refactor configuration, add ordering * Fix integration tests * Change packages, unignore test Co-authored-by: Marcin Aman <marcin.aman@gmail.com>
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/base-test-utils/build.gradle.kts1
-rw-r--r--plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt18
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt8
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt2
-rw-r--r--plugins/base/src/main/kotlin/templating/InsertTemplateExtra.kt12
-rw-r--r--plugins/base/src/test/kotlin/resourceLinks/ResourceLinksTest.kt2
6 files changed, 36 insertions, 7 deletions
diff --git a/plugins/base/base-test-utils/build.gradle.kts b/plugins/base/base-test-utils/build.gradle.kts
index 1de0ac0f..5515c965 100644
--- a/plugins/base/base-test-utils/build.gradle.kts
+++ b/plugins/base/base-test-utils/build.gradle.kts
@@ -2,4 +2,5 @@ dependencies {
compileOnly(project(":plugins:base"))
implementation(project(":core:test-api"))
implementation("org.jsoup:jsoup:1.12.1")
+ implementation(kotlin("test-junit"))
}
diff --git a/plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt b/plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt
new file mode 100644
index 00000000..f8ef8a41
--- /dev/null
+++ b/plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt
@@ -0,0 +1,18 @@
+package utils
+
+import junit.framework.Assert.assertEquals
+import org.jsoup.Jsoup
+
+/**
+ * Parses it using JSOUP, trims whitespace at the end of the line and asserts if they are equal
+ * parsing is required to unify the formatting
+ */
+fun assertHtmlEqualsIgnoringWhitespace(expected: String, actual: String) {
+ assertEquals(
+ Jsoup.parse(expected).outerHtml().trimSpacesAtTheEndOfLine(),
+ Jsoup.parse(actual).outerHtml().trimSpacesAtTheEndOfLine()
+ )
+}
+
+private fun String.trimSpacesAtTheEndOfLine(): String =
+ replace(" \n", "\n") \ No newline at end of file
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 1584df02..5c877f03 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -11,6 +11,7 @@ import org.jetbrains.dokka.base.renderers.isImage
import org.jetbrains.dokka.base.renderers.pageId
import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint
import org.jetbrains.dokka.base.resolvers.local.DokkaBaseLocationProvider
+import org.jetbrains.dokka.base.templating.InsertTemplateExtra
import org.jetbrains.dokka.base.templating.PathToRootSubstitutionCommand
import org.jetbrains.dokka.base.templating.ResolveLinkCommand
import org.jetbrains.dokka.links.DRI
@@ -107,6 +108,7 @@ open class HtmlRenderer(
node.hasStyle(TextStyle.Paragraph) -> p(additionalClasses) { childrenCallback() }
node.hasStyle(TextStyle.Block) -> div(additionalClasses) { childrenCallback() }
node.isAnchorable -> buildAnchor(node.anchor!!, node.anchorLabel!!, node.sourceSetsFilters) { childrenCallback() }
+ node.extra[InsertTemplateExtra] != null -> node.extra[InsertTemplateExtra]?.let { templateCommand(it.command) } ?: Unit
else -> childrenCallback()
}
}
@@ -800,11 +802,7 @@ open class HtmlRenderer(
}
}
} else a {
- href = pathToRoot.split("/")
- .filter { it.isNotBlank() }
- .drop(1).takeIf { it.isNotEmpty() }
- ?.joinToString(separator = "/", postfix = "/index.html")
- ?: "index.html"
+ href = pathToRoot + "index.html"
div {
id = "logo"
}
diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
index c10029bc..5488f754 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
@@ -25,7 +25,7 @@ open class DokkaLocationProvider(
page.children.forEach { registerPath(it, prefix) }
} else {
val newPrefix = prefix + page.pathName
- put(page, newPrefix)
+ put(page, if (page is ModulePageNode) prefix else newPrefix)
page.children.forEach { registerPath(it, newPrefix) }
}
diff --git a/plugins/base/src/main/kotlin/templating/InsertTemplateExtra.kt b/plugins/base/src/main/kotlin/templating/InsertTemplateExtra.kt
new file mode 100644
index 00000000..b2e883f0
--- /dev/null
+++ b/plugins/base/src/main/kotlin/templating/InsertTemplateExtra.kt
@@ -0,0 +1,12 @@
+package org.jetbrains.dokka.base.templating
+
+import org.jetbrains.dokka.model.properties.ExtraProperty
+import org.jetbrains.dokka.pages.ContentNode
+
+data class InsertTemplateExtra(val command: Command) : ExtraProperty<ContentNode> {
+
+ companion object : ExtraProperty.Key<ContentNode, InsertTemplateExtra>
+
+ override val key: ExtraProperty.Key<ContentNode, *>
+ get() = Companion
+} \ No newline at end of file
diff --git a/plugins/base/src/test/kotlin/resourceLinks/ResourceLinksTest.kt b/plugins/base/src/test/kotlin/resourceLinks/ResourceLinksTest.kt
index 57345f5c..709274f2 100644
--- a/plugins/base/src/test/kotlin/resourceLinks/ResourceLinksTest.kt
+++ b/plugins/base/src/test/kotlin/resourceLinks/ResourceLinksTest.kt
@@ -62,7 +62,7 @@ class ResourceLinksTest : BaseAbstractTest() {
r -> assert(it.`is`("[href=$r], [src=$r]"))
}
relativeResources.forEach {
- r -> assert(it.`is`("[href=../$r] , [src=../$r]"))
+ r -> assert(it.`is`("[href=$r] , [src=$r]"))
}
}
}