Skip to content

Commit

Permalink
Add documentation to sample test functions
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnatBeresnev committed Oct 18, 2023
1 parent b6a6ca8 commit 9910be9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import org.jetbrains.dokka.analysis.test.api.parse
import kotlin.test.Test
import kotlin.test.assertEquals

class JavaAnalysisTest {
class SampleJavaAnalysisTest {

/**
* Used as a sample for [javaTestProject]
*/
@Test
fun javaTestProject() {
fun sample() {
val testProject = javaTestProject {
dokkaConfiguration {
moduleName = "java-module-name-for-unit-test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,24 @@ import org.jetbrains.dokka.analysis.test.api.parse
import kotlin.test.Test
import kotlin.test.assertEquals

class KotlinJvmAnalysisTest {
class SampleKotlinJvmAnalysisTest {

/**
* Used as a sample for [kotlinJvmTestProject]
*/
@Test
fun kotlinJvmTestProject() {
fun sample() {
val testProject = kotlinJvmTestProject {
dokkaConfiguration {
moduleName = "kotlin-jvm-module-name-for-unit-test"
}
ktFile(pathFromSrc = "org/jetbrains/dokka/test/kotlin/MyFile.kt") {
+"public class Foo {}"
}
}

val module = testProject.parse()
assertEquals("kotlin-jvm-module-name-for-unit-test", module.name)
assertEquals(1, module.packages.size)

val pckg = module.packages[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@ import org.jetbrains.dokka.analysis.test.api.parse
import kotlin.test.Test
import kotlin.test.assertEquals

class MixedJvmAnalysisTest {
class SampleMixedJvmAnalysisTest {

/**
* Used as a sample for [mixedJvmTestProject]
*/
@Test
fun mixedJvmTestProject() {
fun sample() {
val testProject = mixedJvmTestProject {
dokkaConfiguration {
moduleName = "mixed-project-module-name-for-unit-test"
}

kotlinSourceSet {
ktFile(pathFromSrc = "test/MyFile.kt") {
+"fun foo(): String = \"Foo\""
Expand Down Expand Up @@ -46,6 +53,7 @@ class MixedJvmAnalysisTest {
}

val module = testProject.parse()
assertEquals("mixed-project-module-name-for-unit-test", module.name)
assertEquals(1, module.packages.size)

val pckg = module.packages[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.jetbrains.dokka.analysis.test.api.util.AnalysisTestDslMarker
*
* See [parse] and [useServices] functions to learn how to run Dokka with this project as input.
*
* @sample org.jetbrains.dokka.analysis.test.jvm.kotlin.KotlinJvmAnalysisTest.kotlinJvmTestProject
* @sample org.jetbrains.dokka.analysis.test.jvm.kotlin.SampleKotlinJvmAnalysisTest.sample
*/
fun kotlinJvmTestProject(init: (@AnalysisTestDslMarker KotlinJvmTestProject).() -> Unit): TestProject {
val testData = KotlinJvmTestProject()
Expand All @@ -38,7 +38,7 @@ fun kotlinJvmTestProject(init: (@AnalysisTestDslMarker KotlinJvmTestProject).()
*
* See [parse] and [useServices] functions to learn how to run Dokka with this project as input.
*
* @sample org.jetbrains.dokka.analysis.test.jvm.java.JavaAnalysisTest.javaTestProject
* @sample org.jetbrains.dokka.analysis.test.jvm.java.SampleJavaAnalysisTest.sample
*/
fun javaTestProject(init: (@AnalysisTestDslMarker JavaTestProject).() -> Unit): TestProject {
val testData = JavaTestProject()
Expand All @@ -58,7 +58,7 @@ fun javaTestProject(init: (@AnalysisTestDslMarker JavaTestProject).() -> Unit):
*
* See [parse] and [useServices] functions to learn how to run Dokka with this project as input.
*
* @sample org.jetbrains.dokka.analysis.test.jvm.mixed.MixedJvmAnalysisTest.mixedJvmTestProject
* @sample org.jetbrains.dokka.analysis.test.jvm.mixed.SampleMixedJvmAnalysisTest.sample
*/
fun mixedJvmTestProject(init: (@AnalysisTestDslMarker MixedJvmTestProject).() -> Unit): TestProject {
val testProject = MixedJvmTestProject()
Expand Down

0 comments on commit 9910be9

Please sign in to comment.