Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Dokka Accepting Directories for classpath/includes/sourcesRoots/suppressedFiles #3864

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ internal object DokkaSourceSetBuilder {
sourceSetID = build(spec.sourceSetId.get()),

// files
classpath = spec.classpath.files.toList(),
includes = spec.includes.files,
samples = spec.samples.files,
classpath = spec.classpath.asFileTree.files.toList(),
includes = spec.includes.asFileTree.files,
samples = spec.samples.asFileTree.files,
sourceRoots = spec.sourceRoots.files,
suppressedFiles = spec.suppressedFiles.files,
suppressedFiles = spec.suppressedFiles.asFileTree.files,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import io.kotest.core.spec.style.FunSpec
import io.kotest.engine.spec.tempdir
import io.kotest.inspectors.shouldForAll
import io.kotest.matchers.collections.shouldBeSingleton
import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder
import io.kotest.matchers.equals.shouldNotBeEqual
import io.kotest.matchers.shouldBe
import io.kotest.matchers.string.shouldContain
Expand All @@ -25,6 +26,54 @@ import java.net.URI

class DokkaSourceSetBuilderTest : FunSpec({

context("when building a DokkaSourceSetSpec") {
val project = createProject()
test("resolve classpath, includes, samples, sourceRoots, and suppressedFiles recursively") {
fun File.ensureDirExists() = also { it.mkdirs() }
fun File.subdirWithFile() = resolve("subdir").also { it.mkdirs() }.resolve("test-file")
fun File.createFile() = also { it.createNewFile() }

val tempDir = tempdir()

val classpathDir = tempDir.resolve("classpath").ensureDirExists()
val classpathFile = classpathDir.resolve("test-file").createFile()
val classpathSubFile = classpathDir.subdirWithFile().createFile()

val includesDir = tempDir.resolve("includes").ensureDirExists()
val includesFile = includesDir.resolve("test-file").createFile()
val includesSubFile = includesDir.subdirWithFile().createFile()

val samplesDir = tempDir.resolve("samples").ensureDirExists()
val samplesFile = samplesDir.resolve("test-file").createFile()
val samplesSubFile = samplesDir.subdirWithFile().createFile()

val rootsDir = tempDir.resolve("roots").ensureDirExists()
rootsDir.resolve("test-file").createFile()
rootsDir.subdirWithFile().createFile()

val suppressedDir = tempDir.resolve("suppressed").ensureDirExists()
val suppressedFile = suppressedDir.resolve("test-file").createFile()
val suppressedSubFile = suppressedDir.subdirWithFile().createFile()


val sourceSetSpec = project.createDokkaSourceSetSpec("testRemoteLineSuffixOptional") {
classpath.from(classpathDir)
includes.from(includesDir)
samples.from(samplesDir)
sourceRoots.from(rootsDir)
suppressedFiles.from(suppressedDir)
}

val sourceSet = DokkaSourceSetBuilder.buildAll(setOf(sourceSetSpec)).single()

sourceSet.classpath shouldContainExactlyInAnyOrder listOf(classpathFile, classpathSubFile)
sourceSet.includes shouldContainExactlyInAnyOrder listOf(includesFile, includesSubFile)
sourceSet.samples shouldContainExactlyInAnyOrder listOf(samplesFile, samplesSubFile)
sourceSet.sourceRoots shouldContainExactlyInAnyOrder listOf(rootsDir)
sourceSet.suppressedFiles shouldContainExactlyInAnyOrder listOf(suppressedFile, suppressedSubFile)
}
}

context("when building a ExternalDocumentationLinkSpec") {
val project = createProject()

Expand Down