aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-09-07 14:31:53 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-09-10 13:13:21 +0200
commit825d8fd3bc868d8d9a80a354cd3fae95adceb7ac (patch)
tree3c873863d62931d7ca579bd2c84f65d86dd22ae2 /plugins
parenta5434ae0141ac1a3d150f76937b0456ad15030e0 (diff)
downloaddokka-825d8fd3bc868d8d9a80a354cd3fae95adceb7ac.tar.gz
dokka-825d8fd3bc868d8d9a80a354cd3fae95adceb7ac.tar.bz2
dokka-825d8fd3bc868d8d9a80a354cd3fae95adceb7ac.zip
Add escaping the at sign in modules and packages
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/main/kotlin/parsers/Parser.kt6
-rw-r--r--plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt39
-rw-r--r--plugins/base/src/test/resources/linkable/includes/include1.md9
3 files changed, 51 insertions, 3 deletions
diff --git a/plugins/base/src/main/kotlin/parsers/Parser.kt b/plugins/base/src/main/kotlin/parsers/Parser.kt
index 706f093b..894fa82f 100644
--- a/plugins/base/src/main/kotlin/parsers/Parser.kt
+++ b/plugins/base/src/main/kotlin/parsers/Parser.kt
@@ -43,7 +43,9 @@ abstract class Parser {
private fun jkdocToListOfPairs(javadoc: String): List<Pair<String, String>> =
"description $javadoc"
.split("\n@")
- .map {
- it.substringBefore(' ') to it.substringAfter(' ')
+ .map { content ->
+ val contentWithEscapedAts = content.replace("\\@", "@")
+ val (tag, body) = contentWithEscapedAts.split(" ", limit = 2)
+ tag to body
}
}
diff --git a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
index f8eba2fe..f67d73bb 100644
--- a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
+++ b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
@@ -7,6 +7,7 @@ import org.jetbrains.dokka.base.transformers.pages.sourcelinks.SourceLinksTransf
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.model.WithGenerics
import org.jetbrains.dokka.model.dfs
+import org.jetbrains.dokka.model.doc.Text
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
@@ -273,4 +274,42 @@ class LinkableContentTest : AbstractCoreTest() {
}
}
}
+
+ @Test
+ fun `Include module and package documentation with codeblock`() {
+
+ val testDataDir = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath()
+ val includesDir = getTestDataDir("linkable/includes").toAbsolutePath()
+
+ val configuration = dokkaConfiguration {
+ moduleName = "example"
+ sourceSets {
+ sourceSet {
+ analysisPlatform = "js"
+ sourceRoots = listOf("jsMain", "commonMain", "jvmAndJsSecondCommonMain").map {
+ Paths.get("$testDataDir/$it/kotlin").toString()
+ }
+ name = "js"
+ includes = listOf(Paths.get("$includesDir/include2.md").toString())
+ }
+ sourceSet {
+ analysisPlatform = "jvm"
+ sourceRoots = listOf("jvmMain", "commonMain", "jvmAndJsSecondCommonMain").map {
+ Paths.get("$testDataDir/$it/kotlin").toString()
+ }
+ name = "jvm"
+ includes = listOf(Paths.get("$includesDir/include1.md").toString())
+ }
+ }
+ }
+
+ testFromData(configuration) {
+ documentablesMergingStage = {
+ Assertions.assertNotEquals(null, it.packages.first().documentation.values.single().dfs {
+ (it as? Text)?.body?.contains("@SqlTable") ?: false
+ })
+ }
+ }
+
+ }
}
diff --git a/plugins/base/src/test/resources/linkable/includes/include1.md b/plugins/base/src/test/resources/linkable/includes/include1.md
index 03d9037d..09882ec1 100644
--- a/plugins/base/src/test/resources/linkable/includes/include1.md
+++ b/plugins/base/src/test/resources/linkable/includes/include1.md
@@ -4,4 +4,11 @@ This is JVM documentation for module example
# Package example
-This is JVM documentation for package example \ No newline at end of file
+This is JVM documentation for package example
+
+## Example
+
+```kotlin
+\@SqlTable(People::class)
+class Person(val name: String, uuid: UUID = UUID.randomUUID()) : Entity(uuid)
+```