aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraleksZubakov <aleks.zubakov@gmail.com>2018-08-01 19:48:45 +0300
committeraleksZubakov <aleks.zubakov@gmail.com>2018-08-01 19:48:45 +0300
commit052a218dcf8bc565d5e78dc900a9647f0da5350a (patch)
tree7f63b95ea16c4de5fc241cfcb384cc8d337f7310
parent899c11d36f565cd192945573860568ff62c16ef2 (diff)
downloaddokka-052a218dcf8bc565d5e78dc900a9647f0da5350a.tar.gz
dokka-052a218dcf8bc565d5e78dc900a9647f0da5350a.tar.bz2
dokka-052a218dcf8bc565d5e78dc900a9647f0da5350a.zip
Refactoring, replace DocumentationOption with PassConfiguration
-rw-r--r--core/src/main/kotlin/DokkaBootstrapImpl.kt32
-rw-r--r--core/src/main/kotlin/Generation/DokkaGenerator.kt58
-rw-r--r--core/src/main/kotlin/Generation/FileGenerator.kt5
-rw-r--r--core/src/main/kotlin/Generation/configurationImpl.kt70
-rw-r--r--core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt25
-rw-r--r--core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt4
-rw-r--r--core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt2
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt108
-rw-r--r--core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt13
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt2
-rw-r--r--core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt2
-rw-r--r--core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt4
-rw-r--r--core/src/main/kotlin/Utilities/DokkaModules.kt18
-rw-r--r--core/src/main/kotlin/javadoc/dokka-adapters.kt9
-rw-r--r--core/src/test/kotlin/TestAPI.kt44
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt19
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt22
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt36
-rw-r--r--integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt71
-rw-r--r--runners/ant/src/main/kotlin/ant/dokka.kt49
-rw-r--r--runners/cli/src/main/kotlin/cli/main.kt36
-rw-r--r--runners/maven-plugin/src/main/kotlin/DokkaMojo.kt47
22 files changed, 323 insertions, 353 deletions
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt
index e18ab6cf..ccafcd12 100644
--- a/core/src/main/kotlin/DokkaBootstrapImpl.kt
+++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt
@@ -2,7 +2,6 @@ package org.jetbrains.dokka
import org.jetbrains.dokka.DokkaConfiguration.PackageOptions
import ru.yole.jkid.deserialization.deserialize
-import java.io.File
import java.util.function.BiConsumer
@@ -44,36 +43,7 @@ class DokkaBootstrapImpl : DokkaBootstrap {
= configure(DokkaProxyLogger(logger), deserialize<DokkaConfigurationImpl>(serializedConfigurationJSON))
fun configure(logger: DokkaLogger, configuration: DokkaConfiguration) = with(configuration) {
- generator = DokkaGenerator(
- logger,
- classpath,
- sourceRoots,
- samples,
- includes,
- moduleName,
- DocumentationOptions(
- outputDir = outputDir,
- outputFormat = format,
- includeNonPublic = includeNonPublic,
- includeRootPackage = includeRootPackage,
- reportUndocumented = reportUndocumented,
- skipEmptyPackages = skipEmptyPackages,
- skipDeprecated = skipDeprecated,
- jdkVersion = jdkVersion,
- generateIndexPages = generateIndexPages,
- sourceLinks = sourceLinks,
- impliedPlatforms = impliedPlatforms,
- perPackageOptions = perPackageOptions,
- externalDocumentationLinks = externalDocumentationLinks,
- noStdlibLink = noStdlibLink,
- noJdkLink = noJdkLink,
- languageVersion = languageVersion,
- apiVersion = apiVersion,
- cacheRoot = cacheRoot,
- suppressedFiles = suppressedFiles.map { File(it) }.toSet(),
- collectInheritedExtensionsFromLibraries = collectInheritedExtensionsFromLibraries
- )
- )
+ generator = DokkaGenerator(configuration, logger)
}
override fun generate() = generator.generate()
diff --git a/core/src/main/kotlin/Generation/DokkaGenerator.kt b/core/src/main/kotlin/Generation/DokkaGenerator.kt
index 0c4b3b7e..2e46d908 100644
--- a/core/src/main/kotlin/Generation/DokkaGenerator.kt
+++ b/core/src/main/kotlin/Generation/DokkaGenerator.kt
@@ -2,13 +2,11 @@ package org.jetbrains.dokka
import com.google.inject.Guice
import com.google.inject.Injector
-import com.intellij.openapi.application.PathManager
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiJavaFile
import com.intellij.psi.PsiManager
-import org.jetbrains.dokka.DokkaConfiguration.SourceRoot
import org.jetbrains.dokka.Utilities.DokkaAnalysisModule
import org.jetbrains.dokka.Utilities.DokkaOutputModule
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
@@ -18,7 +16,6 @@ import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot
import org.jetbrains.kotlin.config.JVMConfigurationKeys
-import org.jetbrains.kotlin.config.KotlinSourceRoot
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer
import org.jetbrains.kotlin.resolve.TopDownAnalysisMode
@@ -26,56 +23,49 @@ import org.jetbrains.kotlin.utils.PathUtil
import java.io.File
import kotlin.system.measureTimeMillis
-class DokkaGenerator(val logger: DokkaLogger,
- val classpath: List<String>,
- val sources: List<SourceRoot>,
- val samples: List<String>,
- val includes: List<String>,
- val moduleName: String,
- val options: DocumentationOptions) {
+class DokkaGenerator(val dokkaConfiguration: DokkaConfiguration,
+ val logger: DokkaLogger) {
private val documentationModules: MutableList<DocumentationModule> = mutableListOf()
- fun generate() {
- val sourcesGroupedByPlatform = sources.groupBy { it.platforms.firstOrNull() to it.analysisPlatform }
- for ((platformsInfo, roots) in sourcesGroupedByPlatform) {
- val (platform, analysisPlatform) = platformsInfo
- val documentationModule = DocumentationModule(moduleName)
- appendSourceModule(platform, analysisPlatform, roots, documentationModule)
+ fun generate() = with(dokkaConfiguration) {
+
+
+ for (pass in passesConfigurations) {
+ val documentationModule = DocumentationModule(pass.moduleName)
+ appendSourceModule(pass, documentationModule)
documentationModules.add(documentationModule)
}
val totalDocumentationModule = DocumentationMerger(documentationModules).merge()
- totalDocumentationModule.prepareForGeneration(options)
+ totalDocumentationModule.prepareForGeneration(dokkaConfiguration)
val timeBuild = measureTimeMillis {
logger.info("Generating pages... ")
- val outputInjector = Guice.createInjector(DokkaOutputModule(options, logger))
+ val outputInjector = Guice.createInjector(DokkaOutputModule(dokkaConfiguration, logger))
outputInjector.getInstance(Generator::class.java).buildAll(totalDocumentationModule)
}
logger.info("done in ${timeBuild / 1000} secs")
}
private fun appendSourceModule(
- defaultPlatform: String?,
- analysisPlatform: Platform,
- sourceRoots: List<SourceRoot>,
+ passConfiguration: DokkaConfiguration.PassConfiguration,
documentationModule: DocumentationModule
- ) {
+ ) = with(passConfiguration) {
- val sourcePaths = sourceRoots.map { it.path }
- val environment = createAnalysisEnvironment(sourcePaths, analysisPlatform)
+ val sourcePaths = passConfiguration.sourceRoots.map { it.path }
+ val environment = createAnalysisEnvironment(sourcePaths, passConfiguration)
logger.info("Module: $moduleName")
- logger.info("Output: ${File(options.outputDir)}")
+ logger.info("Output: ${File(dokkaConfiguration.outputDir)}")
logger.info("Sources: ${sourcePaths.joinToString()}")
logger.info("Classpath: ${environment.classpath.joinToString()}")
logger.info("Analysing sources and libraries... ")
val startAnalyse = System.currentTimeMillis()
- val defaultPlatformAsList = defaultPlatform?.let { listOf(it) }.orEmpty()
+ val defaultPlatformAsList = listOf(passConfiguration.analysisPlatform.key)
val defaultPlatformsProvider = object : DefaultPlatformsProvider {
override fun getDefaultPlatforms(descriptor: DeclarationDescriptor): List<String> {
val containingFilePath = descriptor.sourcePsi()?.containingFile?.virtualFile?.canonicalPath
@@ -86,9 +76,9 @@ class DokkaGenerator(val logger: DokkaLogger,
}
val injector = Guice.createInjector(
- DokkaAnalysisModule(environment, options, defaultPlatformsProvider, documentationModule.nodeRefGraph, logger))
+ DokkaAnalysisModule(environment, dokkaConfiguration, defaultPlatformsProvider, documentationModule.nodeRefGraph, passConfiguration, logger))
- buildDocumentationModule(injector, documentationModule, { isNotSample(it) }, includes)
+ buildDocumentationModule(injector, documentationModule, { isNotSample(it, passConfiguration.samples) }, includes)
documentationModule.nodeRefGraph.nodeMapView.forEach { (_, node) ->
node.addReferenceTo(
DocumentationNode(analysisPlatform.key, Content.Empty, NodeKind.Platform),
@@ -102,28 +92,28 @@ class DokkaGenerator(val logger: DokkaLogger,
Disposer.dispose(environment)
}
- fun createAnalysisEnvironment(sourcePaths: List<String>, analysisPlatform: Platform): AnalysisEnvironment {
- val environment = AnalysisEnvironment(DokkaMessageCollector(logger), analysisPlatform)
+ fun createAnalysisEnvironment(sourcePaths: List<String>, passConfiguration: DokkaConfiguration.PassConfiguration): AnalysisEnvironment {
+ val environment = AnalysisEnvironment(DokkaMessageCollector(logger), passConfiguration.analysisPlatform)
environment.apply {
if (analysisPlatform == Platform.jvm) {
addClasspath(PathUtil.getJdkClassesRootsFromCurrentJre())
}
// addClasspath(PathUtil.getKotlinPathsForCompiler().getRuntimePath())
- for (element in this@DokkaGenerator.classpath) {
+ for (element in passConfiguration.classpath) {
addClasspath(File(element))
}
addSources(sourcePaths)
- addSources(this@DokkaGenerator.samples)
+ addSources(passConfiguration.samples)
- loadLanguageVersionSettings(options.languageVersion, options.apiVersion)
+ loadLanguageVersionSettings(passConfiguration.languageVersion, passConfiguration.apiVersion)
}
return environment
}
- fun isNotSample(file: PsiFile): Boolean {
+ fun isNotSample(file: PsiFile, samples: List<String>): Boolean {
val sourceFile = File(file.virtualFile!!.path)
return samples.none { sample ->
val canonicalSample = File(sample).canonicalPath
diff --git a/core/src/main/kotlin/Generation/FileGenerator.kt b/core/src/main/kotlin/Generation/FileGenerator.kt
index b7c6cf63..eb6800b3 100644
--- a/core/src/main/kotlin/Generation/FileGenerator.kt
+++ b/core/src/main/kotlin/Generation/FileGenerator.kt
@@ -2,7 +2,6 @@ package org.jetbrains.dokka
import com.google.inject.Inject
import com.google.inject.name.Named
-import org.jetbrains.kotlin.utils.fileUtils.withReplacedExtensionOrNull
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
@@ -12,7 +11,7 @@ class FileGenerator @Inject constructor(@Named("outputDir") override val root: F
@set:Inject(optional = true) var outlineService: OutlineFormatService? = null
@set:Inject(optional = true) lateinit var formatService: FormatService
- @set:Inject(optional = true) lateinit var options: DocumentationOptions
+ @set:Inject(optional = true) lateinit var dokkaConfiguration: DokkaConfiguration
@set:Inject(optional = true) var packageListService: PackageListService? = null
override fun location(node: DocumentationNode): FileLocation {
@@ -74,7 +73,7 @@ class FileGenerator @Inject constructor(@Named("outputDir") override val root: F
val moduleRoot = location(module).file.parentFile
val packageListFile = File(moduleRoot, "package-list")
- packageListFile.writeText("\$dokka.format:${options.outputFormat}\n" +
+ packageListFile.writeText("\$dokka.format:${dokkaConfiguration.format}\n" +
packageListService!!.formatPackageList(module as DocumentationModule))
}
diff --git a/core/src/main/kotlin/Generation/configurationImpl.kt b/core/src/main/kotlin/Generation/configurationImpl.kt
index 8829682a..3e39b4ed 100644
--- a/core/src/main/kotlin/Generation/configurationImpl.kt
+++ b/core/src/main/kotlin/Generation/configurationImpl.kt
@@ -45,29 +45,47 @@ data class PackageOptionsImpl(override val prefix: String,
override val suppress: Boolean = false) : DokkaConfiguration.PackageOptions
data class DokkaConfigurationImpl(
- override val moduleName: String,
- override val classpath: List<String>,
- override val sourceRoots: List<SourceRootImpl>,
- override val samples: List<String>,
- override val includes: List<String>,
- override val outputDir: String,
- override val format: String,
- override val includeNonPublic: Boolean,
- override val includeRootPackage: Boolean,
- override val reportUndocumented: Boolean,
- override val skipEmptyPackages: Boolean,
- override val skipDeprecated: Boolean,
- override val jdkVersion: Int,
- override val generateIndexPages: Boolean,
- override val sourceLinks: List<SourceLinkDefinitionImpl>,
- override val impliedPlatforms: List<String>,
- override val perPackageOptions: List<PackageOptionsImpl>,
- override val externalDocumentationLinks: List<ExternalDocumentationLinkImpl>,
- override val noStdlibLink: Boolean,
- override val noJdkLink: Boolean,
- override val cacheRoot: String?,
- override val suppressedFiles: List<String>,
- override val languageVersion: String?,
- override val apiVersion: String?,
- override val collectInheritedExtensionsFromLibraries: Boolean
-) : DokkaConfiguration \ No newline at end of file
+ override val outputDir: String = "",
+ override val format: String = "html",
+ override val generateIndexPages: Boolean = false,
+ override val cacheRoot: String? = null,
+ override val impliedPlatforms: List<String> = listOf(),
+ override val passesConfigurations: List<DokkaConfiguration.PassConfiguration> = listOf()
+) : DokkaConfiguration
+
+class PassConfigurationImpl (
+ override val classpath: List<String> = listOf(),
+ override val moduleName: String = "",
+ override val sourceRoots: List<SourceRoot> = listOf(),
+ override val samples: List<String> = listOf(),
+ override val includes: List<String> = listOf(),
+ override val includeNonPublic: Boolean = false,
+ override val includeRootPackage: Boolean = false,
+ override val reportUndocumented: Boolean = false,
+ override val skipEmptyPackages: Boolean = false,
+ override val skipDeprecated: Boolean = false,
+ override val jdkVersion: Int = 6,
+ override val sourceLinks: List<SourceLinkDefinition> = listOf(),
+ override val perPackageOptions: List<DokkaConfiguration.PackageOptions> = listOf(),
+ externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink> = listOf(),
+ override val languageVersion: String? = null,
+ override val apiVersion: String? = null,
+ override val noStdlibLink: Boolean = false,
+ override val noJdkLink: Boolean = false,
+ override val suppressedFiles: List<String> = listOf(),
+ override val collectInheritedExtensionsFromLibraries: Boolean = false,
+ override val analysisPlatform: Platform = Platform.DEFAULT,
+ override val targets: List<String> = listOf()
+): DokkaConfiguration.PassConfiguration {
+ private val defaultLinks = run {
+ val links = mutableListOf<DokkaConfiguration.ExternalDocumentationLink>()
+ if (!noJdkLink)
+ links += DokkaConfiguration.ExternalDocumentationLink.Builder("http://docs.oracle.com/javase/$jdkVersion/docs/api/").build()
+
+ if (!noStdlibLink)
+ links += DokkaConfiguration.ExternalDocumentationLink.Builder("https://kotlinlang.org/api/latest/jvm/stdlib/").build()
+ links
+ }
+ override val externalDocumentationLinks = defaultLinks + externalDocumentationLinks
+}
+
diff --git a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
index 332afffb..1fe4d180 100644
--- a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
+++ b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.kdoc.psi.impl.KDocTag
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtModifierListOwner
-import java.io.File
fun getSignature(element: PsiElement?) = when(element) {
is PsiPackage -> element.qualifiedName
@@ -44,24 +43,24 @@ interface JavaDocumentationBuilder {
}
class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
- private val options: DocumentationOptions
+ private val passConfiguration: DokkaConfiguration.PassConfiguration
private val refGraph: NodeReferenceGraph
private val docParser: JavaDocumentationParser
@Inject constructor(
- options: DocumentationOptions,
- refGraph: NodeReferenceGraph,
- logger: DokkaLogger,
- signatureProvider: ElementSignatureProvider,
- externalDocumentationLinkResolver: ExternalDocumentationLinkResolver
+ passConfiguration: DokkaConfiguration.PassConfiguration,
+ refGraph: NodeReferenceGraph,
+ logger: DokkaLogger,
+ signatureProvider: ElementSignatureProvider,
+ externalDocumentationLinkResolver: ExternalDocumentationLinkResolver
) {
- this.options = options
+ this.passConfiguration = passConfiguration
this.refGraph = refGraph
this.docParser = JavadocParser(refGraph, logger, signatureProvider, externalDocumentationLinkResolver)
}
- constructor(options: DocumentationOptions, refGraph: NodeReferenceGraph, docParser: JavaDocumentationParser) {
- this.options = options
+ constructor(passConfiguration: DokkaConfiguration.PassConfiguration, refGraph: NodeReferenceGraph, docParser: JavaDocumentationParser) {
+ this.passConfiguration = passConfiguration
this.refGraph = refGraph
this.docParser = docParser
}
@@ -141,7 +140,7 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
}
}
- private fun skipFile(javaFile: PsiJavaFile): Boolean = options.effectivePackageOptions(javaFile.packageName).suppress
+ private fun skipFile(javaFile: PsiJavaFile): Boolean = passConfiguration.effectivePackageOptions(javaFile.packageName).suppress
private fun skipElement(element: Any) =
skipElementByVisibility(element) ||
@@ -151,13 +150,13 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
private fun skipElementByVisibility(element: Any): Boolean =
element is PsiModifierListOwner &&
element !is PsiParameter &&
- !(options.effectivePackageOptions((element.containingFile as? PsiJavaFile)?.packageName ?: "").includeNonPublic) &&
+ !(passConfiguration.effectivePackageOptions((element.containingFile as? PsiJavaFile)?.packageName ?: "").includeNonPublic) &&
(element.hasModifierProperty(PsiModifier.PRIVATE) ||
element.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) ||
element.isInternal())
private fun skipElementBySuppressedFiles(element: Any): Boolean =
- element is PsiElement && File(element.containingFile.virtualFile.path).absoluteFile in options.suppressedFiles
+ element is PsiElement && element.containingFile.virtualFile.path in passConfiguration.suppressedFiles
private fun PsiElement.isInternal(): Boolean {
val ktElement = (this as? KtLightElement<*, *>)?.kotlinOrigin ?: return false
diff --git a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
index d73bef4a..c3a84e57 100644
--- a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
+++ b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
@@ -10,7 +10,7 @@ class DeclarationLinkResolver
@Inject constructor(val resolutionFacade: DokkaResolutionFacade,
val refGraph: NodeReferenceGraph,
val logger: DokkaLogger,
- val options: DocumentationOptions,
+ val passConfiguration: DokkaConfiguration.PassConfiguration,
val externalDocumentationLinkResolver: ExternalDocumentationLinkResolver,
val elementSignatureProvider: ElementSignatureProvider) {
@@ -63,7 +63,7 @@ class DeclarationLinkResolver
if (symbol is CallableMemberDescriptor && symbol.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
return symbol.overriddenDescriptors.firstOrNull()
}
- if (symbol is TypeAliasDescriptor && !symbol.isDocumented(options)) {
+ if (symbol is TypeAliasDescriptor && !symbol.isDocumented(passConfiguration)) {
return symbol.classDescriptor
}
return symbol
diff --git a/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt b/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
index 7817da18..d0650d45 100644
--- a/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
+++ b/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered
import org.jetbrains.kotlin.resolve.source.PsiSourceElement
class DescriptorDocumentationParser
- @Inject constructor(val options: DocumentationOptions,
+ @Inject constructor(val options: DokkaConfiguration.PassConfiguration,
val logger: DokkaLogger,
val linkResolver: DeclarationLinkResolver,
val resolutionFacade: DokkaResolutionFacade,
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index e3675f9d..fb0b898a 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -4,7 +4,7 @@ import com.google.inject.Inject
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiField
import com.intellij.psi.PsiJavaFile
-import org.jetbrains.dokka.DokkaConfiguration.*
+import org.jetbrains.dokka.DokkaConfiguration.PassConfiguration
import org.jetbrains.dokka.Kotlin.DescriptorDocumentationParser
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.*
@@ -35,62 +35,8 @@ import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.typeUtil.supertypes
import org.jetbrains.kotlin.util.supertypesWithAny
-import java.io.File
-import java.nio.file.Path
-import java.nio.file.Paths
import com.google.inject.name.Named as GuiceNamed
-class DocumentationOptions(val outputDir: String,
- val outputFormat: String,
- includeNonPublic: Boolean = false,
- val includeRootPackage: Boolean = false,
- reportUndocumented: Boolean = true,
- val skipEmptyPackages: Boolean = true,
- skipDeprecated: Boolean = false,
- jdkVersion: Int = 6,
- val generateIndexPages: Boolean = true,
- val sourceLinks: List<SourceLinkDefinition> = emptyList(),
- val impliedPlatforms: List<String> = emptyList(),
- // Sorted by pattern length
- perPackageOptions: List<PackageOptions> = emptyList(),
- externalDocumentationLinks: List<ExternalDocumentationLink> = emptyList(),
- noStdlibLink: Boolean,
- noJdkLink: Boolean = false,
- val languageVersion: String?,
- val apiVersion: String?,
- cacheRoot: String? = null,
- val suppressedFiles: Set<File> = emptySet(),
- val collectInheritedExtensionsFromLibraries: Boolean = false) {
- init {
- if (perPackageOptions.any { it.prefix == "" })
- throw IllegalArgumentException("Please do not register packageOptions with all match pattern, use global settings instead")
- }
-
- val perPackageOptions = perPackageOptions.sortedByDescending { it.prefix.length }
- val rootPackageOptions = PackageOptionsImpl("", includeNonPublic, reportUndocumented, skipDeprecated)
-
- fun effectivePackageOptions(pack: String): PackageOptions = perPackageOptions.firstOrNull { pack == it.prefix || pack.startsWith(it.prefix + ".") } ?: rootPackageOptions
- fun effectivePackageOptions(pack: FqName): PackageOptions = effectivePackageOptions(pack.asString())
-
- val defaultLinks = run {
- val links = mutableListOf<ExternalDocumentationLink>()
- if (!noJdkLink)
- links += ExternalDocumentationLink.Builder("http://docs.oracle.com/javase/$jdkVersion/docs/api/").build()
-
- if (!noStdlibLink)
- links += ExternalDocumentationLink.Builder("https://kotlinlang.org/api/latest/jvm/stdlib/").build()
- links
- }
-
- 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,
extensionReceiverDescriptor: DeclarationDescriptor,
allFqNames: Collection<FqName>): Boolean {
@@ -120,7 +66,7 @@ val ignoredSupertypes = setOf(
class DocumentationBuilder
@Inject constructor(val resolutionFacade: DokkaResolutionFacade,
val descriptorDocumentationParser: DescriptorDocumentationParser,
- val options: DocumentationOptions,
+ val passConfiguration: DokkaConfiguration.PassConfiguration,
val refGraph: NodeReferenceGraph,
val platformNodeRegistry: PlatformNodeRegistry,
val logger: DokkaLogger,
@@ -352,7 +298,7 @@ class DocumentationBuilder
fun DocumentationNode.isSinceKotlin() = name == "SinceKotlin" && kind == NodeKind.Annotation
fun DocumentationNode.appendSourceLink(sourceElement: SourceElement) {
- appendSourceLink(sourceElement.getPsi(), options.sourceLinks)
+ appendSourceLink(sourceElement.getPsi(), passConfiguration.sourceLinks)
}
fun DocumentationNode.appendSignature(descriptor: DeclarationDescriptor) {
@@ -360,7 +306,7 @@ class DocumentationBuilder
}
fun DocumentationNode.appendChild(descriptor: DeclarationDescriptor, kind: RefKind): DocumentationNode? {
- if (!descriptor.isGenerated() && descriptor.isDocumented(options)) {
+ if (!descriptor.isGenerated() && descriptor.isDocumented(passConfiguration)) {
val node = descriptor.build()
append(node, kind)
return node
@@ -387,7 +333,7 @@ class DocumentationBuilder
fun DocumentationNode.appendOrUpdateMember(descriptor: DeclarationDescriptor) {
- if (descriptor.isGenerated() || !descriptor.isDocumented(options)) return
+ if (descriptor.isGenerated() || !descriptor.isDocumented(passConfiguration)) return
val existingNode = refGraph.lookup(descriptor.signature())
if (existingNode != null) {
@@ -459,10 +405,10 @@ class DocumentationBuilder
val allFqNames = fragments.map { it.fqName }.distinct()
for (packageName in allFqNames) {
- if (packageName.isRoot && !options.includeRootPackage) continue
+ if (packageName.isRoot && !passConfiguration.includeRootPackage) continue
val declarations = fragments.filter { it.fqName == packageName }.flatMap { it.getMemberScope().getContributedDescriptors() }
- if (options.skipEmptyPackages && declarations.none { it.isDocumented(options) }) continue
+ if (passConfiguration.skipEmptyPackages && declarations.none { it.isDocumented(passConfiguration) }) continue
logger.info(" package $packageName: ${declarations.count()} declarations")
val packageNode = findOrCreatePackageNode(this, packageName.asString(), packageContent, this@DocumentationBuilder.refGraph)
packageDocumentationBuilder.buildPackageDocumentation(this@DocumentationBuilder, packageName, packageNode,
@@ -489,7 +435,7 @@ class DocumentationBuilder
}.flatten()
val allDescriptors =
- if (options.collectInheritedExtensionsFromLibraries) {
+ if (passConfiguration.collectInheritedExtensionsFromLibraries) {
allPackageViewDescriptors.map { it.memberScope }
} else {
fragments.asSequence().map { it.getMemberScope() }
@@ -694,7 +640,7 @@ class DocumentationBuilder
.mapTo(result) { ClassMember(it, extraModifier = "static") }
val companionObjectDescriptor = companionObjectDescriptor
- if (companionObjectDescriptor != null && companionObjectDescriptor.isDocumented(options)) {
+ if (companionObjectDescriptor != null && companionObjectDescriptor.isDocumented(passConfiguration)) {
val descriptors = companionObjectDescriptor.defaultType.memberScope.getContributedDescriptors()
val descriptorsToDocument = descriptors.filter { it !is CallableDescriptor || !it.isInheritedFromAny() }
descriptorsToDocument.mapTo(result) {
@@ -967,12 +913,12 @@ class DocumentationBuilder
}
-fun DeclarationDescriptor.isDocumented(options: DocumentationOptions): Boolean {
- return (options.effectivePackageOptions(fqNameSafe).includeNonPublic
+fun DeclarationDescriptor.isDocumented(passConfiguration: DokkaConfiguration.PassConfiguration): Boolean {
+ return (passConfiguration.effectivePackageOptions(fqNameSafe).includeNonPublic
|| this !is MemberDescriptor
|| this.visibility.isPublicAPI)
- && !isDocumentationSuppressed(options)
- && (!options.effectivePackageOptions(fqNameSafe).skipDeprecated || !isDeprecated())
+ && !isDocumentationSuppressed(passConfiguration)
+ && (!passConfiguration.effectivePackageOptions(fqNameSafe).skipDeprecated || !isDeprecated())
}
private fun DeclarationDescriptor.isGenerated() = this is CallableMemberDescriptor && kind != CallableMemberDescriptor.Kind.DECLARATION
@@ -986,7 +932,7 @@ class KotlinPackageDocumentationBuilder : PackageDocumentationBuilder {
val externalClassNodes = hashMapOf<FqName, DocumentationNode>()
declarations.forEach { descriptor ->
with(documentationBuilder) {
- if (descriptor.isDocumented(options)) {
+ if (descriptor.isDocumented(passConfiguration)) {
val parent = packageNode.getParentForPackageMember(descriptor, externalClassNodes, allFqNames)
parent.appendOrUpdateMember(descriptor)
}
@@ -998,14 +944,14 @@ class KotlinPackageDocumentationBuilder : PackageDocumentationBuilder {
class KotlinJavaDocumentationBuilder
@Inject constructor(val resolutionFacade: DokkaResolutionFacade,
val documentationBuilder: DocumentationBuilder,
- val options: DocumentationOptions,
+ val passConfiguration: DokkaConfiguration.PassConfiguration,
val logger: DokkaLogger) : JavaDocumentationBuilder {
override fun appendFile(file: PsiJavaFile, module: DocumentationModule, packageContent: Map<String, Content>) {
val classDescriptors = file.classes.map {
it.getJavaClassDescriptor(resolutionFacade)
}
- if (classDescriptors.any { it != null && it.isDocumented(options) }) {
+ if (classDescriptors.any { it != null && it.isDocumented(passConfiguration) }) {
val packageNode = findOrCreatePackageNode(module, file.packageName, packageContent, documentationBuilder.refGraph)
for (descriptor in classDescriptors.filterNotNull()) {
@@ -1035,13 +981,13 @@ fun AnnotationDescriptor.mustBeDocumented(): Boolean {
return annotationClass.isDocumentedAnnotation()
}
-fun DeclarationDescriptor.isDocumentationSuppressed(options: DocumentationOptions): Boolean {
+fun DeclarationDescriptor.isDocumentationSuppressed(passConfiguration: DokkaConfiguration.PassConfiguration): Boolean {
- if (options.effectivePackageOptions(fqNameSafe).suppress) return true
+ if (passConfiguration.effectivePackageOptions(fqNameSafe).suppress) return true
val path = this.findPsi()?.containingFile?.virtualFile?.path
if (path != null) {
- if (File(path).absoluteFile in options.suppressedFiles) return true
+ if (path in passConfiguration.suppressedFiles) return true
}
val doc = findKDoc()
@@ -1079,7 +1025,7 @@ fun DeclarationDescriptor.signature(): String {
is TypeAliasDescriptor -> DescriptorUtils.getFqName(this).asString()
is PropertyDescriptor -> containingDeclaration.signature() + "$" + name + receiverSignature()
- is FunctionDescriptor -> containingDeclaration.signature() + "$" + name + parameterSignature() + ":" + returnType?.signature()
+ is FunctionDescriptor -> containingDeclaration.signature() + "$" + name + parameterSignature() + ":" + returnType?.signature()
is ValueParameterDescriptor -> containingDeclaration.signature() + "/" + name
is TypeParameterDescriptor -> containingDeclaration.signature() + "*" + name
is ReceiverParameterDescriptor -> containingDeclaration.signature() + "/" + name
@@ -1140,8 +1086,8 @@ fun DeclarationDescriptor.sourceLocation(): String? {
return null
}
-fun DocumentationModule.prepareForGeneration(options: DocumentationOptions) {
- if (options.generateIndexPages) {
+fun DocumentationModule.prepareForGeneration(configuration: DokkaConfiguration) {
+ if (configuration.generateIndexPages) {
generateAllTypesNode()
}
nodeRefGraph.resolveReferences()
@@ -1167,4 +1113,12 @@ fun ClassDescriptor.supertypesWithAnyPrecise(): Collection<KotlinType> {
return emptyList()
}
return typeConstructor.supertypesWithAny()
-} \ No newline at end of file
+}
+
+fun PassConfiguration.effectivePackageOptions(pack: String): DokkaConfiguration.PackageOptions {
+ val rootPackageOptions = PackageOptionsImpl("", includeNonPublic, reportUndocumented, skipDeprecated)
+ return perPackageOptions.firstOrNull { pack == it.prefix || pack.startsWith(it.prefix + ".") } ?: rootPackageOptions
+}
+
+fun PassConfiguration.effectivePackageOptions(pack: FqName): DokkaConfiguration.PackageOptions = effectivePackageOptions(pack.asString())
+
diff --git a/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt b/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt
index a8129793..2fc207b9 100644
--- a/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt
+++ b/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt
@@ -22,6 +22,7 @@ import java.net.HttpURLConnection
import java.net.URL
import java.net.URLConnection
import java.nio.file.Path
+import java.nio.file.Paths
import java.security.MessageDigest
import javax.inject.Named
import kotlin.reflect.full.findAnnotation
@@ -30,7 +31,8 @@ fun ByteArray.toHexString() = this.joinToString(separator = "") { "%02x".format(
@Singleton
class ExternalDocumentationLinkResolver @Inject constructor(
- val options: DocumentationOptions,
+ val configuration: DokkaConfiguration,
+ val passConfiguration: DokkaConfiguration.PassConfiguration,
@Named("libraryResolutionFacade") val libraryResolutionFacade: DokkaResolutionFacade,
val logger: DokkaLogger
) {
@@ -42,7 +44,12 @@ class ExternalDocumentationLinkResolver @Inject constructor(
override fun toString(): String = rootUrl.toString()
}
- val cacheDir: Path? = options.cacheRoot?.resolve("packageListCache")?.apply { createDirectories() }
+
+ val cacheDir: Path? = when {
+ configuration.cacheRoot == "default" -> Paths.get(System.getProperty("user.home"), ".cache", "dokka")
+ configuration.cacheRoot != null -> Paths.get(configuration.cacheRoot)
+ else -> null
+ }?.resolve("packageListCache")?.apply { createDirectories() }
val cachedProtocols = setOf("http", "https", "ftp")
@@ -157,7 +164,7 @@ class ExternalDocumentationLinkResolver @Inject constructor(
}
init {
- options.externalDocumentationLinks.forEach {
+ passConfiguration.externalDocumentationLinks.forEach {
try {
loadPackageList(it)
} catch (e: Exception) {
diff --git a/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt
index c7ed8292..be6dd2e1 100644
--- a/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt
@@ -28,7 +28,7 @@ class KotlinAsJavaDocumentationBuilder
return
}
- val javaDocumentationBuilder = JavaPsiDocumentationBuilder(documentationBuilder.options,
+ val javaDocumentationBuilder = JavaPsiDocumentationBuilder(documentationBuilder.passConfiguration,
documentationBuilder.refGraph,
kotlinAsJavaDocumentationParser)
diff --git a/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt b/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt
index 116a5c02..f3f45c3f 100644
--- a/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt
+++ b/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.resolve.scopes.ResolutionScope
open class DefaultSampleProcessingService
-@Inject constructor(val options: DocumentationOptions,
+@Inject constructor(val configuration: DokkaConfiguration,
val logger: DokkaLogger,
val resolutionFacade: DokkaResolutionFacade)
: SampleProcessingService {
diff --git a/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt b/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt
index b0988c35..b5801457 100644
--- a/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt
+++ b/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt
@@ -12,10 +12,10 @@ import org.jetbrains.kotlin.psi.psiUtil.prevLeaf
import org.jetbrains.kotlin.resolve.ImportPath
open class KotlinWebsiteSampleProcessingService
-@Inject constructor(options: DocumentationOptions,
+@Inject constructor(dokkaConfiguration: DokkaConfiguration,
logger: DokkaLogger,
resolutionFacade: DokkaResolutionFacade)
- : DefaultSampleProcessingService(options, logger, resolutionFacade) {
+ : DefaultSampleProcessingService(dokkaConfiguration, logger, resolutionFacade) {
private class SampleBuilder : KtTreeVisitorVoid() {
val builder = StringBuilder()
diff --git a/core/src/main/kotlin/Utilities/DokkaModules.kt b/core/src/main/kotlin/Utilities/DokkaModules.kt
index 732cbc48..251d5c23 100644
--- a/core/src/main/kotlin/Utilities/DokkaModules.kt
+++ b/core/src/main/kotlin/Utilities/DokkaModules.kt
@@ -14,9 +14,10 @@ import kotlin.reflect.KClass
const val impliedPlatformsName = "impliedPlatforms"
class DokkaAnalysisModule(val environment: AnalysisEnvironment,
- val options: DocumentationOptions,
+ val configuration: DokkaConfiguration,
val defaultPlatformsProvider: DefaultPlatformsProvider,
val nodeReferenceGraph: NodeReferenceGraph,
+ val passConfiguration: DokkaConfiguration.PassConfiguration,
val logger: DokkaLogger) : Module {
override fun configure(binder: Binder) {
binder.bind<DokkaLogger>().toInstance(logger)
@@ -28,29 +29,30 @@ class DokkaAnalysisModule(val environment: AnalysisEnvironment,
binder.bind<DokkaResolutionFacade>().toInstance(dokkaResolutionFacade)
binder.bind<DokkaResolutionFacade>().annotatedWith(Names.named("libraryResolutionFacade")).toInstance(libraryResolutionFacade)
- binder.bind<DocumentationOptions>().toInstance(options)
+ binder.bind<DokkaConfiguration>().toInstance(configuration)
+ binder.bind<DokkaConfiguration.PassConfiguration>().toInstance(passConfiguration)
binder.bind<DefaultPlatformsProvider>().toInstance(defaultPlatformsProvider)
binder.bind<NodeReferenceGraph>().toInstance(nodeReferenceGraph)
- val descriptor = ServiceLocator.lookup<FormatDescriptor>("format", options.outputFormat)
+ val descriptor = ServiceLocator.lookup<FormatDescriptor>("format", configuration.format)
descriptor.configureAnalysis(binder)
}
}
object StringListType : TypeLiteral<@JvmSuppressWildcards List<String>>()
-class DokkaOutputModule(val options: DocumentationOptions,
+class DokkaOutputModule(val configuration: DokkaConfiguration,
val logger: DokkaLogger) : Module {
override fun configure(binder: Binder) {
- binder.bind(File::class.java).annotatedWith(Names.named("outputDir")).toInstance(File(options.outputDir))
+ binder.bind(File::class.java).annotatedWith(Names.named("outputDir")).toInstance(File(configuration.outputDir))
- binder.bind<DocumentationOptions>().toInstance(options)
+ binder.bind<DokkaConfiguration>().toInstance(configuration)
binder.bind<DokkaLogger>().toInstance(logger)
- binder.bind(StringListType).annotatedWith(Names.named(impliedPlatformsName)).toInstance(options.impliedPlatforms)
+ binder.bind(StringListType).annotatedWith(Names.named(impliedPlatformsName)).toInstance(configuration.impliedPlatforms)
- val descriptor = ServiceLocator.lookup<FormatDescriptor>("format", options.outputFormat)
+ val descriptor = ServiceLocator.lookup<FormatDescriptor>("format", configuration.format)
descriptor.configureOutput(binder)
}
diff --git a/core/src/main/kotlin/javadoc/dokka-adapters.kt b/core/src/main/kotlin/javadoc/dokka-adapters.kt
index 483fb3cd..1329876a 100644
--- a/core/src/main/kotlin/javadoc/dokka-adapters.kt
+++ b/core/src/main/kotlin/javadoc/dokka-adapters.kt
@@ -4,16 +4,19 @@ import com.google.inject.Binder
import com.google.inject.Inject
import com.sun.tools.doclets.formats.html.HtmlDoclet
import org.jetbrains.dokka.*
-import org.jetbrains.dokka.Formats.*
+import org.jetbrains.dokka.Formats.DefaultAnalysisComponent
+import org.jetbrains.dokka.Formats.DefaultAnalysisComponentServices
+import org.jetbrains.dokka.Formats.FormatDescriptor
+import org.jetbrains.dokka.Formats.KotlinAsJava
import org.jetbrains.dokka.Utilities.bind
import org.jetbrains.dokka.Utilities.toType
-class JavadocGenerator @Inject constructor(val options: DocumentationOptions, val logger: DokkaLogger) : Generator {
+class JavadocGenerator @Inject constructor(val configuration: DokkaConfiguration, val logger: DokkaLogger) : Generator {
override fun buildPages(nodes: Iterable<DocumentationNode>) {
val module = nodes.single() as DocumentationModule
- HtmlDoclet.start(ModuleNodeAdapter(module, StandardReporter(logger), options.outputDir))
+ HtmlDoclet.start(ModuleNodeAdapter(module, StandardReporter(logger), configuration.outputDir))
}
override fun buildOutlines(nodes: Iterable<DocumentationNode>) {
diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt
index 4a755130..b65efbe9 100644
--- a/core/src/test/kotlin/TestAPI.kt
+++ b/core/src/test/kotlin/TestAPI.kt
@@ -35,31 +35,35 @@ fun verifyModel(modelConfig: ModelConfig,
verifier: (DocumentationModule) -> Unit) {
val documentation = DocumentationModule("test")
- val options = DocumentationOptions(
- "",
- modelConfig.format,
- includeNonPublic = modelConfig.includeNonPublic,
- skipEmptyPackages = false,
- includeRootPackage = true,
- sourceLinks = listOf(),
- perPackageOptions = modelConfig.perPackageOptions,
- generateIndexPages = false,
- noStdlibLink = modelConfig.noStdlibLink,
- noJdkLink = false,
- cacheRoot = "default",
- languageVersion = null,
- apiVersion = null,
- collectInheritedExtensionsFromLibraries = modelConfig.collectInheritedExtensionsFromLibraries
+ val passConfiguration = PassConfigurationImpl (
+ includeNonPublic = modelConfig.includeNonPublic,
+ skipEmptyPackages = false,
+ includeRootPackage = true,
+ sourceLinks = listOf(),
+ perPackageOptions = modelConfig.perPackageOptions,
+ noStdlibLink = modelConfig.noStdlibLink,
+ noJdkLink = false,
+ languageVersion = null,
+ apiVersion = null,
+ collectInheritedExtensionsFromLibraries = modelConfig.collectInheritedExtensionsFromLibraries
+ )
+ val configuration = DokkaConfigurationImpl(
+ outputDir = "",
+ format = modelConfig.format,
+ generateIndexPages = false,
+ cacheRoot = "default",
+ passesConfigurations = listOf(passConfiguration)
)
- appendDocumentation(documentation, options, modelConfig)
- documentation.prepareForGeneration(options)
+ appendDocumentation(documentation, configuration, passConfiguration, modelConfig)
+ documentation.prepareForGeneration(configuration)
verifier(documentation)
}
fun appendDocumentation(documentation: DocumentationModule,
- options: DocumentationOptions,
+ dokkaConfiguration: DokkaConfiguration,
+ passConfiguration: DokkaConfiguration.PassConfiguration,
modelConfig: ModelConfig
) {
val messageCollector = object : MessageCollector {
@@ -108,13 +112,13 @@ fun appendDocumentation(documentation: DocumentationModule,
}
addRoots(modelConfig.roots.toList())
- loadLanguageVersionSettings(options.languageVersion, options.apiVersion)
+ loadLanguageVersionSettings(passConfiguration.languageVersion, passConfiguration.apiVersion)
}
val defaultPlatformsProvider = object : DefaultPlatformsProvider {
override fun getDefaultPlatforms(descriptor: DeclarationDescriptor) = modelConfig.defaultPlatforms
}
val injector = Guice.createInjector(
- DokkaAnalysisModule(environment, options, defaultPlatformsProvider, documentation.nodeRefGraph, DokkaConsoleLogger))
+ DokkaAnalysisModule(environment, dokkaConfiguration, defaultPlatformsProvider, documentation.nodeRefGraph, passConfiguration, DokkaConsoleLogger))
buildDocumentationModule(injector, documentation)
Disposer.dispose(environment)
}
diff --git a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
index 643b5b2d..4f292e37 100644
--- a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
+++ b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
@@ -48,17 +48,20 @@ class KotlinWebSiteFormatTest: FileGeneratorTestCase() {
private fun buildMultiplePlatforms(path: String): DocumentationModule {
val module = DocumentationModule("test")
- val options = DocumentationOptions(
- outputDir = "",
- outputFormat = "html",
- generateIndexPages = false,
- noStdlibLink = true,
+ val passConfiguration = PassConfigurationImpl(noStdlibLink = true,
noJdkLink = true,
languageVersion = null,
apiVersion = null
)
+ val configuration = DokkaConfigurationImpl(
+ outputDir = "",
+ format = "html",
+ generateIndexPages = false,
+ passesConfigurations = listOf(passConfiguration)
+ )
+
appendDocumentation(
- module, options, ModelConfig(
+ module, configuration, passConfiguration, ModelConfig(
roots = arrayOf(contentRootFromPath("testdata/format/website/$path/jvm.kt")),
defaultPlatforms = listOf("JVM")
)
@@ -67,13 +70,13 @@ class KotlinWebSiteFormatTest: FileGeneratorTestCase() {
appendDocumentation(
- module, options, ModelConfig(
+ module, configuration, passConfiguration, ModelConfig(
roots = arrayOf(contentRootFromPath("testdata/format/website/$path/jre7.kt")),
defaultPlatforms = listOf("JVM", "JRE7")
)
)
appendDocumentation(
- module, options, ModelConfig(
+ module, configuration, passConfiguration, ModelConfig(
roots = arrayOf(contentRootFromPath("testdata/format/website/$path/js.kt")),
defaultPlatforms = listOf("JS")
)
diff --git a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
index 3ae0930e..1901154f 100644
--- a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
+++ b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
@@ -64,29 +64,37 @@ abstract class BaseKotlinWebSiteHtmlFormatTest(val analysisPlatform: Platform):
private fun buildMultiplePlatforms(path: String): DocumentationModule {
val module = DocumentationModule("test")
- val options = DocumentationOptions(
- outputDir = "",
- outputFormat = "kotlin-website-html",
- generateIndexPages = false,
+ val passConfiguration = PassConfigurationImpl(
noStdlibLink = true,
noJdkLink = true,
languageVersion = null,
apiVersion = null
)
+
+ val dokkaConfiguration = DokkaConfigurationImpl(
+ outputDir = "",
+ format = "kotlin-website-html",
+ generateIndexPages = false,
+ passesConfigurations = listOf(
+ passConfiguration
+ )
+
+ )
+
appendDocumentation(
- module, options, ModelConfig(
+ module, dokkaConfiguration, passConfiguration, ModelConfig(
roots = arrayOf(contentRootFromPath("testdata/format/website-html/$path/jvm.kt")),
defaultPlatforms = listOf("JVM")
)
)
appendDocumentation(
- module, options, ModelConfig(
+ module, dokkaConfiguration, passConfiguration, ModelConfig(
roots = arrayOf(contentRootFromPath("testdata/format/website-html/$path/jre7.kt")),
defaultPlatforms = listOf("JVM", "JRE7")
)
)
appendDocumentation(
- module, options, ModelConfig(
+ module, dokkaConfiguration, passConfiguration, ModelConfig(
roots = arrayOf(contentRootFromPath("testdata/format/website-html/$path/js.kt")),
defaultPlatforms = listOf("JS")
)
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index 4de70751..29d2d20f 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -1,7 +1,6 @@
package org.jetbrains.dokka.tests
import org.jetbrains.dokka.*
-import org.junit.Before
import org.junit.Test
abstract class BaseMarkdownFormatTest(val analysisPlatform: Platform): FileGeneratorTestCase() {
@@ -249,16 +248,23 @@ abstract class BaseMarkdownFormatTest(val analysisPlatform: Platform): FileGener
@Test fun packagePlatformsWithExtExtensions() {
val path = "multiplatform/packagePlatformsWithExtExtensions"
val module = DocumentationModule("test")
- val options = DocumentationOptions(
- outputDir = "",
- outputFormat = "html",
- generateIndexPages = false,
+ val passConfiguration = PassConfigurationImpl(
noStdlibLink = true,
noJdkLink = true,
languageVersion = null,
apiVersion = null
)
- appendDocumentation(module, options, ModelConfig(
+
+ val dokkaConfiguration = DokkaConfigurationImpl(
+ outputDir = "",
+ format = "html",
+ generateIndexPages = false,
+ passesConfigurations = listOf(
+ passConfiguration
+ )
+ )
+
+ appendDocumentation(module, dokkaConfiguration, passConfiguration, ModelConfig(
roots = arrayOf(contentRootFromPath("testdata/format/$path/jvm.kt")),
defaultPlatforms = listOf("JVM"),
withKotlinRuntime = true,
@@ -373,24 +379,30 @@ abstract class BaseMarkdownFormatTest(val analysisPlatform: Platform): FileGener
private fun buildMultiplePlatforms(path: String): DocumentationModule {
val module = DocumentationModule("test")
- val options = DocumentationOptions(
- outputDir = "",
- outputFormat = "html",
- generateIndexPages = false,
+ val passConfiguration = PassConfigurationImpl(
noStdlibLink = true,
noJdkLink = true,
languageVersion = null,
apiVersion = null
)
+ val dokkaConfiguration = DokkaConfigurationImpl(
+ outputDir = "",
+ format = "html",
+ generateIndexPages = false,
+ passesConfigurations = listOf(
+ passConfiguration
+ )
+
+ )
appendDocumentation(
- module, options, ModelConfig(
+ module, dokkaConfiguration, passConfiguration, ModelConfig(
roots = arrayOf(contentRootFromPath("testdata/format/$path/jvm.kt")),
defaultPlatforms = listOf("JVM"),
analysisPlatform = Platform.jvm
)
)
appendDocumentation(
- module, options, ModelConfig(
+ module, dokkaConfiguration, passConfiguration, ModelConfig(
roots = arrayOf(contentRootFromPath("testdata/format/$path/js.kt")),
defaultPlatforms = listOf("JS"),
analysisPlatform = Platform.js
diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt
index 287b628a..e0fa27d1 100644
--- a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt
+++ b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt
@@ -39,31 +39,37 @@ enum class Platform(val key: String) {
}
interface DokkaConfiguration {
- val moduleName: String
- val classpath: List<String>
- val sourceRoots: List<SourceRoot>
- val samples: List<String>
- val includes: List<String>
val outputDir: String
val format: String
- val includeNonPublic: Boolean
- val includeRootPackage: Boolean
- val reportUndocumented: Boolean
- val skipEmptyPackages: Boolean
- val skipDeprecated: Boolean
- val jdkVersion: Int
val generateIndexPages: Boolean
- val sourceLinks: List<SourceLinkDefinition>
- val impliedPlatforms: List<String>
- val perPackageOptions: List<PackageOptions>
- val externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink>
- val languageVersion: String?
- val apiVersion: String?
- val noStdlibLink: Boolean
- val noJdkLink: Boolean
val cacheRoot: String?
- val suppressedFiles: List<String>
- val collectInheritedExtensionsFromLibraries: Boolean
+ val passesConfigurations: List<PassConfiguration>
+ val impliedPlatforms: List<String>
+
+ interface PassConfiguration {
+ val moduleName: String
+ val classpath: List<String>
+ val sourceRoots: List<SourceRoot>
+ val samples: List<String>
+ val includes: List<String>
+ val includeNonPublic: Boolean
+ val includeRootPackage: Boolean
+ val reportUndocumented: Boolean
+ val skipEmptyPackages: Boolean
+ val skipDeprecated: Boolean
+ val jdkVersion: Int
+ val sourceLinks: List<SourceLinkDefinition>
+ val perPackageOptions: List<PackageOptions>
+ val externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink>
+ val languageVersion: String?
+ val apiVersion: String?
+ val noStdlibLink: Boolean
+ val noJdkLink: Boolean
+ val suppressedFiles: List<String>
+ val collectInheritedExtensionsFromLibraries: Boolean
+ val analysisPlatform: Platform
+ val targets: List<String>
+ }
interface SourceRoot {
val path: String
@@ -106,31 +112,12 @@ interface DokkaConfiguration {
}
data class SerializeOnlyDokkaConfiguration(
- override val moduleName: String,
- override val classpath: List<String>,
- override val sourceRoots: List<DokkaConfiguration.SourceRoot>,
- override val samples: List<String>,
- override val includes: List<String>,
override val outputDir: String,
override val format: String,
- override val includeNonPublic: Boolean,
- override val includeRootPackage: Boolean,
- override val reportUndocumented: Boolean,
- override val skipEmptyPackages: Boolean,
- override val skipDeprecated: Boolean,
- override val jdkVersion: Int,
override val generateIndexPages: Boolean,
- override val sourceLinks: List<DokkaConfiguration.SourceLinkDefinition>,
- override val impliedPlatforms: List<String>,
- override val perPackageOptions: List<DokkaConfiguration.PackageOptions>,
- override val externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink>,
- override val noStdlibLink: Boolean,
- override val noJdkLink: Boolean,
override val cacheRoot: String?,
- override val suppressedFiles: List<String>,
- override val languageVersion: String?,
- override val apiVersion: String?,
- override val collectInheritedExtensionsFromLibraries: Boolean
+ override val impliedPlatforms: List<String>,
+ override val passesConfigurations: List<DokkaConfiguration.PassConfiguration>
) : DokkaConfiguration
diff --git a/runners/ant/src/main/kotlin/ant/dokka.kt b/runners/ant/src/main/kotlin/ant/dokka.kt
index 0b1ccc13..4f629198 100644
--- a/runners/ant/src/main/kotlin/ant/dokka.kt
+++ b/runners/ant/src/main/kotlin/ant/dokka.kt
@@ -116,29 +116,34 @@ class DokkaAntTask: Task() {
SourceLinkDefinitionImpl(File(path).canonicalFile.absolutePath, url, it.lineSuffix)
}
- val generator = DokkaGenerator(
- AntLogger(this),
- compileClasspath.list().toList(),
- sourcePath.list().map { SourceRootImpl(it) } + antSourceRoots.mapNotNull { it.toSourceRoot() },
- samplesPath.list().toList(),
- includesPath.list().toList(),
- moduleName!!,
- DocumentationOptions(
- outputDir!!,
- outputFormat,
- skipDeprecated = skipDeprecated,
- sourceLinks = sourceLinks,
- jdkVersion = jdkVersion,
- impliedPlatforms = impliedPlatforms.split(','),
- perPackageOptions = antPackageOptions,
- externalDocumentationLinks = antExternalDocumentationLinks.map { it.build() },
- noStdlibLink = noStdlibLink,
- noJdkLink = noJdkLink,
- cacheRoot = cacheRoot,
- languageVersion = languageVersion,
- apiVersion = apiVersion
- )
+ val passConfiguration = PassConfigurationImpl(
+ classpath = compileClasspath.list().toList(),
+ sourceRoots = sourcePath.list().map { SourceRootImpl(it) } + antSourceRoots.mapNotNull { it.toSourceRoot() },
+ samples = samplesPath.list().toList(),
+ includes = includesPath.list().toList(),
+ moduleName = moduleName!!,
+ skipDeprecated = skipDeprecated,
+ sourceLinks = sourceLinks,
+ jdkVersion = jdkVersion,
+ perPackageOptions = antPackageOptions,
+ externalDocumentationLinks = antExternalDocumentationLinks.map { it.build() },
+ noStdlibLink = noStdlibLink,
+ noJdkLink = noJdkLink,
+ languageVersion = languageVersion,
+ apiVersion = apiVersion
)
+
+ val configuration = DokkaConfigurationImpl(
+ outputDir = outputDir!!,
+ format = outputFormat,
+ impliedPlatforms = impliedPlatforms.split(','),
+ cacheRoot = cacheRoot,
+ passesConfigurations = listOf(
+ passConfiguration
+ )
+ )
+
+ val generator = DokkaGenerator(configuration, AntLogger(this))
generator.generate()
}
} \ No newline at end of file
diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt
index f871f406..330de5e1 100644
--- a/runners/cli/src/main/kotlin/cli/main.kt
+++ b/runners/cli/src/main/kotlin/cli/main.kt
@@ -44,7 +44,7 @@ class DokkaArguments {
@set:Argument(value = "impliedPlatforms", description = "List of implied platforms (comma-separated)")
var impliedPlatforms: String = ""
- @set:Argument(value = "packageOptions", description = "List of package options in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" ")
+ @set:Argument(value = "packageOptions", description = "List of package passConfiguration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" ")
var packageOptions: String = ""
@set:Argument(value = "links", description = "External documentation links in format url^packageListUrl^^url2...")
@@ -111,31 +111,37 @@ object MainKt {
val classPath = arguments.classpath.split(File.pathSeparatorChar).toList()
- val documentationOptions = DocumentationOptions(
- arguments.outputDir.let { if (it.endsWith('/')) it else it + '/' },
- arguments.outputFormat,
+ val passConfig = PassConfigurationImpl(
skipDeprecated = arguments.nodeprecated,
sourceLinks = sourceLinks,
- impliedPlatforms = arguments.impliedPlatforms.split(','),
perPackageOptions = parsePerPackageOptions(arguments.packageOptions),
jdkVersion = arguments.jdkVersion,
externalDocumentationLinks = parseLinks(arguments.links),
noStdlibLink = arguments.noStdlibLink,
- cacheRoot = arguments.cacheRoot,
languageVersion = arguments.languageVersion,
apiVersion = arguments.apiVersion,
collectInheritedExtensionsFromLibraries = arguments.collectInheritedExtensionsFromLibraries,
- noJdkLink = arguments.noJdkLink
+ noJdkLink = arguments.noJdkLink,
+ sourceRoots = sources.map(SourceRootImpl.Companion::parseSourceRoot),
+ analysisPlatform = sources.map (SourceRootImpl.Companion::parseSourceRoot).single().analysisPlatform,
+ samples = samples,
+ includes = includes,
+ moduleName = arguments.moduleName,
+ classpath = classPath
+ )
+
+ val config = DokkaConfigurationImpl(
+ outputDir = arguments.outputDir.let { if (it.endsWith('/')) it else it + '/' },
+ format = arguments.outputFormat,
+ impliedPlatforms = arguments.impliedPlatforms.split(','),
+ cacheRoot = arguments.cacheRoot,
+
+ passesConfigurations = listOf(
+ passConfig
+ )
)
- val generator = DokkaGenerator(
- DokkaConsoleLogger,
- classPath,
- sources.map(SourceRootImpl.Companion::parseSourceRoot),
- samples,
- includes,
- arguments.moduleName,
- documentationOptions)
+ val generator = DokkaGenerator(config, DokkaConsoleLogger)
generator.generate()
DokkaConsoleLogger.report()
diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
index ea55c8fe..78fd2d86 100644
--- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
+++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
@@ -129,30 +129,33 @@ abstract class AbstractDokkaMojo : AbstractMojo() {
return
}
- val gen = DokkaGenerator(
- MavenDokkaLogger(log),
- classpath,
- sourceDirectories.map { SourceRootImpl(it) } + sourceRoots,
- samplesDirs,
- includeDirs + includes,
- moduleName,
- DocumentationOptions(getOutDir(), getOutFormat(),
- sourceLinks = sourceLinks.map { SourceLinkDefinitionImpl(it.dir, it.url, it.urlSuffix) },
- jdkVersion = jdkVersion,
- skipDeprecated = skipDeprecated,
- skipEmptyPackages = skipEmptyPackages,
- reportUndocumented = reportNotDocumented,
- impliedPlatforms = impliedPlatforms,
- perPackageOptions = perPackageOptions,
- externalDocumentationLinks = externalDocumentationLinks.map { it.build() },
- noStdlibLink = noStdlibLink,
- noJdkLink = noJdkLink,
- cacheRoot = cacheRoot,
- languageVersion = languageVersion,
- apiVersion = apiVersion
- )
+ val passConfiguration = PassConfigurationImpl(
+ sourceLinks = sourceLinks.map { SourceLinkDefinitionImpl(it.dir, it.url, it.urlSuffix) },
+ jdkVersion = jdkVersion,
+ skipDeprecated = skipDeprecated,
+ skipEmptyPackages = skipEmptyPackages,
+ reportUndocumented = reportNotDocumented,
+ perPackageOptions = perPackageOptions,
+ externalDocumentationLinks = externalDocumentationLinks.map { it.build() },
+ noStdlibLink = noStdlibLink,
+ noJdkLink = noJdkLink,
+ languageVersion = languageVersion,
+ apiVersion = apiVersion
+
+ )
+
+ val configuration = DokkaConfigurationImpl(
+ outputDir = getOutDir(),
+ format = getOutFormat(),
+ impliedPlatforms = impliedPlatforms,
+ cacheRoot = cacheRoot,
+ passesConfigurations = listOf(
+ passConfiguration
+ )
)
+ val gen = DokkaGenerator(configuration, MavenDokkaLogger(log))
+
gen.generate()
}
}