aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Locations/SingleFolderLocationService.kt
blob: e313ac28c448ae3685db834c3962a5feb501a09a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package org.jetbrains.dokka

import com.google.inject.Inject
import com.google.inject.name.Named
import java.io.File

public fun SingleFolderLocationService(root: String): SingleFolderLocationService = SingleFolderLocationService(File(root), "")
public class SingleFolderLocationService @Inject constructor(@Named("outputDir") val rootFile: File, val extension: String) : FileLocationService {
    override fun withExtension(newExtension: String): FileLocationService =
        SingleFolderLocationService(rootFile, newExtension)

    override fun location(qualifiedName: List<String>, hasMembers: Boolean): FileLocation {
        val filename = qualifiedName.map { identifierToFilename(it) }.joinToString("-")
        return FileLocation(File(rootFile, filename).appendExtension(extension))
    }

    override val root: Location
        get() = FileLocation(rootFile)
}