diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/kotlin/DokkaBootstrapImpl.kt | 3 | ||||
-rw-r--r-- | core/src/main/kotlin/Generation/configurationImpl.kt | 3 | ||||
-rw-r--r-- | core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 9 | ||||
-rw-r--r-- | core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt | 10 | ||||
-rw-r--r-- | core/src/test/kotlin/TestAPI.kt | 3 |
5 files changed, 18 insertions, 10 deletions
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index 593c6db1..b4af636a 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -63,7 +63,8 @@ class DokkaBootstrapImpl : DokkaBootstrap { impliedPlatforms, perPackageOptions, externalDocumentationLinks, - noStdlibLink + noStdlibLink, + cacheRoot ) ) } diff --git a/core/src/main/kotlin/Generation/configurationImpl.kt b/core/src/main/kotlin/Generation/configurationImpl.kt index cdc9752d..9b4013ad 100644 --- a/core/src/main/kotlin/Generation/configurationImpl.kt +++ b/core/src/main/kotlin/Generation/configurationImpl.kt @@ -52,4 +52,5 @@ data class DokkaConfigurationImpl(override val moduleName: String, override val impliedPlatforms: List<String>, override val perPackageOptions: List<PackageOptionsImpl>, override val externalDocumentationLinks: List<ExternalDocumentationLinkImpl>, - override val noStdlibLink: Boolean) : DokkaConfiguration
\ No newline at end of file + override val noStdlibLink: Boolean, + override val cacheRoot: String?) : DokkaConfiguration
\ No newline at end of file diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index c258ef2c..824d74bb 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.resolve.source.getPsi import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf import org.jetbrains.kotlin.types.typeUtil.supertypes +import java.nio.file.Path import java.nio.file.Paths import com.google.inject.name.Named as GuiceNamed @@ -47,7 +48,7 @@ class DocumentationOptions(val outputDir: String, perPackageOptions: List<PackageOptions> = emptyList(), externalDocumentationLinks: List<ExternalDocumentationLink> = emptyList(), noStdlibLink: Boolean, - val cacheRoot: String = Paths.get(System.getProperty("user.home"), ".cache", "dokka").toString()) { + cacheRoot: String? = null) { init { if (perPackageOptions.any { it.prefix == "" }) throw IllegalArgumentException("Please do not register packageOptions with all match pattern, use global settings instead") @@ -67,6 +68,12 @@ class DocumentationOptions(val outputDir: String, } val externalDocumentationLinks = defaultLinks + externalDocumentationLinks + + val cacheRoot: Path? = when { + cacheRoot == "default" -> Paths.get(System.getProperty("user.home"), ".cache", "dokka") + cacheRoot != null -> Paths.get(cacheRoot) + else -> null + } } private fun isExtensionForExternalClass(extensionFunctionDescriptor: DeclarationDescriptor, diff --git a/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt b/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt index bdf426e0..84d83c73 100644 --- a/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt +++ b/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt @@ -17,7 +17,6 @@ import java.io.ByteArrayOutputStream import java.io.PrintWriter import java.net.URL import java.nio.file.Path -import java.nio.file.Paths import java.security.MessageDigest fun ByteArray.toHexString() = this.joinToString(separator = "") { "%02x".format(it) } @@ -33,8 +32,7 @@ class ExternalDocumentationLinkResolver @Inject constructor( class ExternalDocumentationRoot(val rootUrl: URL, val resolver: InboundExternalLinkResolutionService, val locations: Map<String, String>) - // TODO: Make configurable - val cacheDir: Path = Paths.get(options.cacheRoot, "packageListCache").apply { createDirectories() } + val cacheDir: Path? = options.cacheRoot?.resolve("packageListCache")?.apply { createDirectories() } val cachedProtocols = setOf("http", "https", "ftp") @@ -43,11 +41,11 @@ class ExternalDocumentationLinkResolver @Inject constructor( val packageListUrl = link.packageListUrl val needsCache = packageListUrl.protocol in cachedProtocols - val packageListStream = if (needsCache) { - val text = packageListUrl.toExternalForm() + val packageListStream = if (cacheDir != null && needsCache) { + val packageListLink = packageListUrl.toExternalForm() val digest = MessageDigest.getInstance("SHA-256") - val hash = digest.digest(text.toByteArray(Charsets.UTF_8)).toHexString() + val hash = digest.digest(packageListLink.toByteArray(Charsets.UTF_8)).toHexString() val cacheEntry = cacheDir.resolve(hash) if (cacheEntry.exists()) { diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt index 2d937679..e11274ea 100644 --- a/core/src/test/kotlin/TestAPI.kt +++ b/core/src/test/kotlin/TestAPI.kt @@ -33,7 +33,8 @@ fun verifyModel(vararg roots: ContentRoot, includeRootPackage = true, sourceLinks = listOf<SourceLinkDefinition>(), generateIndexPages = false, - noStdlibLink = true) + noStdlibLink = true, + cacheRoot = "default") appendDocumentation(documentation, *roots, withJdk = withJdk, |