aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test
diff options
context:
space:
mode:
authorVadim Mishenev <vad-mishenev@yandex.ru>2022-10-26 21:07:09 +0300
committerGitHub <noreply@github.com>2022-10-26 21:07:09 +0300
commitd1b24984fdf6d2f383697b557086c62c94e4eee0 (patch)
tree037cd0ed9deafd2a174535458f3b5c0ab9b1635b /plugins/base/src/test
parent4c122a4d46f9f100e1508b602942c571067a1d88 (diff)
downloaddokka-d1b24984fdf6d2f383697b557086c62c94e4eee0.tar.gz
dokka-d1b24984fdf6d2f383697b557086c62c94e4eee0.tar.bz2
dokka-d1b24984fdf6d2f383697b557086c62c94e4eee0.zip
Fix source link to the line with name (#2724)
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r--plugins/base/src/test/kotlin/enums/JavaEnumsTest.kt5
-rw-r--r--plugins/base/src/test/kotlin/enums/KotlinEnumsTest.kt5
-rw-r--r--plugins/base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt67
3 files changed, 75 insertions, 2 deletions
diff --git a/plugins/base/src/test/kotlin/enums/JavaEnumsTest.kt b/plugins/base/src/test/kotlin/enums/JavaEnumsTest.kt
index e8b9e92b..b3d56d2e 100644
--- a/plugins/base/src/test/kotlin/enums/JavaEnumsTest.kt
+++ b/plugins/base/src/test/kotlin/enums/JavaEnumsTest.kt
@@ -47,6 +47,9 @@ class JavaEnumsTest : BaseAbstractTest() {
|/src/main/java/basic/JavaEnum.java
|package testpackage
|
+ |/**
+ |* doc
+ |*/
|public enum JavaEnum {
| ONE, TWO, THREE
|}
@@ -62,7 +65,7 @@ class JavaEnumsTest : BaseAbstractTest() {
assertEquals(
- "https://github.com/user/repo/tree/master/src/main/java/basic/JavaEnum.java#L3",
+ "https://github.com/user/repo/tree/master/src/main/java/basic/JavaEnum.java#L6",
sourceLink
)
}
diff --git a/plugins/base/src/test/kotlin/enums/KotlinEnumsTest.kt b/plugins/base/src/test/kotlin/enums/KotlinEnumsTest.kt
index 655a8b82..58cb3f9f 100644
--- a/plugins/base/src/test/kotlin/enums/KotlinEnumsTest.kt
+++ b/plugins/base/src/test/kotlin/enums/KotlinEnumsTest.kt
@@ -398,6 +398,9 @@ class KotlinEnumsTest : BaseAbstractTest() {
|/src/main/kotlin/basic/KotlinEnum.kt
|package testpackage
|
+ |/**
+ |* Doc
+ |*/
|enum class KotlinEnum {
| ONE, TWO, THREE
|}
@@ -412,7 +415,7 @@ class KotlinEnumsTest : BaseAbstractTest() {
.attr("href")
assertEquals(
- "https://github.com/user/repo/tree/master/src/main/kotlin/basic/KotlinEnum.kt#L3",
+ "https://github.com/user/repo/tree/master/src/main/kotlin/basic/KotlinEnum.kt#L6",
sourceLink
)
}
diff --git a/plugins/base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt b/plugins/base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt
new file mode 100644
index 00000000..81b4db69
--- /dev/null
+++ b/plugins/base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt
@@ -0,0 +1,67 @@
+package transformers
+
+import org.jetbrains.dokka.SourceLinkDefinitionImpl
+import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
+import org.junit.jupiter.api.Test
+import signatures.renderedContent
+import utils.TestOutputWriterPlugin
+import java.net.URL
+import kotlin.test.assertEquals
+import org.jsoup.nodes.Element
+
+class SourceLinkTransformerTest : BaseAbstractTest() {
+
+ private fun Element.getSourceLink() = select(".symbol .floating-right")
+ .select("a[href]")
+ .attr("href")
+
+ @Test
+ fun `source link should lead to name`() {
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/")
+ sourceLinks = listOf(
+ SourceLinkDefinitionImpl(
+ localDirectory = "src/main/kotlin",
+ remoteUrl = URL("https://github.com/user/repo/tree/master/src/main/kotlin"),
+ remoteLineSuffix = "#L"
+ )
+ )
+ }
+ }
+ }
+
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ """
+ |/src/main/kotlin/basic/Deprecated.kt
+ |package testpackage
+ |
+ |/**
+ |* Marks the annotated declaration as deprecated. ...
+ |*/
+ |@Target(CLASS, FUNCTION, PROPERTY, ANNOTATION_CLASS, CONSTRUCTOR, PROPERTY_SETTER, PROPERTY_GETTER, TYPEALIAS)
+ |@MustBeDocumented
+ |public annotation class Deprecated(
+ | val message: String,
+ | val replaceWith: ReplaceWith = ReplaceWith(""),
+ | val level: DeprecationLevel = DeprecationLevel.WARNING
+ |)
+ """.trimMargin(),
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ val page = writerPlugin.writer.renderedContent("root/testpackage/-deprecated/index.html")
+ val sourceLink = page.getSourceLink()
+
+ assertEquals(
+ "https://github.com/user/repo/tree/master/src/main/kotlin/basic/Deprecated.kt#L8",
+ sourceLink
+ )
+ }
+ }
+ }
+} \ No newline at end of file