aboutsummaryrefslogtreecommitdiff
path: root/plugins/javadoc
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/javadoc')
-rw-r--r--plugins/javadoc/build.gradle.kts3
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAccessorNamingTest.kt80
2 files changed, 83 insertions, 0 deletions
diff --git a/plugins/javadoc/build.gradle.kts b/plugins/javadoc/build.gradle.kts
index 9e737bc9..28c2fdeb 100644
--- a/plugins/javadoc/build.gradle.kts
+++ b/plugins/javadoc/build.gradle.kts
@@ -11,6 +11,9 @@ dependencies {
val coroutines_version: String by project
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
+
+ val jsoup_version: String by project
+ testImplementation("org.jsoup:jsoup:$jsoup_version")
}
registerDokkaArtifactPublication("javadocPlugin") {
diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAccessorNamingTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAccessorNamingTest.kt
new file mode 100644
index 00000000..edb0bd6b
--- /dev/null
+++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAccessorNamingTest.kt
@@ -0,0 +1,80 @@
+package org.jetbrains.dokka.javadoc
+
+import org.jsoup.Jsoup
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.Assertions.assertEquals
+import utils.*
+
+internal class JavadocAccessorNamingTest : AbstractJavadocTemplateMapTest() {
+
+ val configuration = dokkaConfiguration {
+ suppressObviousFunctions = true
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/main/kotlin")
+ }
+ }
+ }
+
+ /**
+ * This is a quick sanity check for the AccessorMethodNamingTest
+ */
+ @Test
+ fun verifySpecialIsRuleIsApplied() {
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ """
+ /src/main/kotlin/sample/TestCase.kt
+ package sample
+
+ /**
+ * Test links:
+ * - [TestCase.issuesFetched]
+ * - [TestCase.isFoo]
+ */
+ data class TestCase(
+ var issuesFetched: Int,
+ var isFoo: String,
+ )
+ """.trimIndent(),
+ configuration,
+ cleanupOutput = false,
+ pluginOverrides = listOf(writerPlugin, JavadocPlugin())
+ ) {
+ renderingStage = { _, _ ->
+ val html = writerPlugin.writer.contents["sample/TestCase.html"].let { Jsoup.parse(it) }
+ val props = html
+ .select("#memberSummary_tabpanel")
+ .select("th[scope=row].colSecond")
+ .select("code")
+ .map { it.text() }
+ .toSet()
+
+ assertEquals(setOf(
+ "getIssuesFetched()",
+ "setIssuesFetched(Integer issuesFetched)",
+ "isFoo()",
+ "setFoo(String isFoo)",
+ ), props)
+
+ val descriptionLinks = html
+ .select("div.description")
+ .select("p")
+ .select("a")
+ .eachAttr("href")
+ .map { a -> a.takeLastWhile { it != '#' } }
+
+ assertEquals(setOf(
+ "issuesFetched",
+ "isFoo()",
+ ), descriptionLinks.toSet())
+
+ // Make sure that the ids from above actually exist
+ assertEquals(1, html.select("[id = isFoo()]").size)
+ // Bug! Nothing in the doc has the right id
+ assertEquals(0, html.select("[id = issuesFetched]").size)
+ }
+ }
+ }
+} \ No newline at end of file