diff options
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r-- | core/src/main/kotlin/DokkaBootstrapImpl.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/DokkaGenerator.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/configuration.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/defaultConfiguration.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/links/DRI.kt | 35 | ||||
-rw-r--r-- | core/src/main/kotlin/model/Documentable.kt | 11 |
6 files changed, 36 insertions, 18 deletions
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index 56e837fc..d39ee1d5 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -17,7 +17,7 @@ fun parsePerPackageOptions(arg: String): List<PackageOptions> { throw IllegalArgumentException("Please do not register packageOptions with all match pattern, use global settings instead") val args = it.subList(1, it.size) val deprecated = args.find { it.endsWith("deprecated") }?.startsWith("+") ?: true - val reportUndocumented = args.find { it.endsWith("warnUndocumented") }?.startsWith("+") ?: true + val reportUndocumented = args.find { it.endsWith("reportUndocumented") }?.startsWith("+") ?: true val privateApi = args.find { it.endsWith("privateApi") }?.startsWith("+") ?: false val suppress = args.find { it.endsWith("suppress") }?.startsWith("+") ?: false PackageOptionsImpl( diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index 7f90fe9a..61fb7324 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -146,7 +146,7 @@ class DokkaGenerator( } pass.classpath.forEach { addClasspath(File(it)) } - addSources((pass.sourceRoots + pass.dependentSourceRoots).map { it.path }) + addSources((pass.sourceRoots + pass.dependentSourceRoots).map { it.path }) loadLanguageVersionSettings(pass.languageVersion, pass.apiVersion) diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt index c38d0234..0b59f301 100644 --- a/core/src/main/kotlin/configuration.kt +++ b/core/src/main/kotlin/configuration.kt @@ -83,7 +83,7 @@ interface DokkaConfiguration { interface PackageOptions { val prefix: String val includeNonPublic: Boolean - val reportUndocumented: Boolean + val reportUndocumented: Boolean? val skipDeprecated: Boolean val suppress: Boolean } diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt index acfa55d4..7aaa1c89 100644 --- a/core/src/main/kotlin/defaultConfiguration.kt +++ b/core/src/main/kotlin/defaultConfiguration.kt @@ -73,7 +73,7 @@ data class SourceLinkDefinitionImpl( data class PackageOptionsImpl( override val prefix: String, override val includeNonPublic: Boolean, - override val reportUndocumented: Boolean, + override val reportUndocumented: Boolean?, override val skipDeprecated: Boolean, override val suppress: Boolean ): DokkaConfiguration.PackageOptions diff --git a/core/src/main/kotlin/links/DRI.kt b/core/src/main/kotlin/links/DRI.kt index 1c823d92..9cc51fb7 100644 --- a/core/src/main/kotlin/links/DRI.kt +++ b/core/src/main/kotlin/links/DRI.kt @@ -38,12 +38,13 @@ data class DRI( } fun from(psi: PsiElement) = psi.parentsWithSelf.run { - val callable = firstIsInstanceOrNull<PsiMethod>() + val psiMethod = firstIsInstanceOrNull<PsiMethod>() + val psiField = firstIsInstanceOrNull<PsiField>() val classes = filterIsInstance<PsiClass>().toList() DRI( classes.lastOrNull()?.qualifiedName?.substringBeforeLast('.', ""), classes.toList().takeIf { it.isNotEmpty() }?.asReversed()?.mapNotNull { it.name }?.joinToString("."), - callable?.let { Callable.from(it) }, + psiMethod?.let { Callable.from(it) } ?: psiField?.let { Callable.from(it) } , DriTarget.from(psi) ) } @@ -85,12 +86,21 @@ data class Callable( valueParameters.mapNotNull { TypeReference.from(it) } ) } + fun from(psi: PsiMethod) = with(psi) { Callable( name, null, parameterList.parameters.map { param -> JavaClassReference(param.type.canonicalText) }) } + + fun from(psi: PsiField): Callable { + return Callable( + name = psi.name, + receiver = null, + params = emptyList() + ) + } } } @@ -169,11 +179,12 @@ sealed class DriTarget { companion object { fun from(descriptor: DeclarationDescriptor): DriTarget = descriptor.parentsWithSelf.run { - return when(descriptor){ + return when (descriptor) { is TypeParameterDescriptor -> PointingToGenericParameters(descriptor.index) else -> { val callable = firstIsInstanceOrNull<CallableDescriptor>() - val params = callable?.let { listOfNotNull(it.extensionReceiverParameter) + it.valueParameters }.orEmpty() + val params = + callable?.let { listOfNotNull(it.extensionReceiverParameter) + it.valueParameters }.orEmpty() val parameterDescriptor = firstIsInstanceOrNull<ParameterDescriptor>() parameterDescriptor?.let { PointingToCallableParameters(params.indexOf(it)) } @@ -183,7 +194,7 @@ sealed class DriTarget { } fun from(psi: PsiElement): DriTarget = psi.parentsWithSelf.run { - return when(psi) { + return when (psi) { is PsiTypeParameter -> PointingToGenericParameters(psi.index) else -> firstIsInstanceOrNull<PsiParameter>()?.let { val callable = firstIsInstanceOrNull<PsiMethod>() @@ -199,15 +210,15 @@ data class PointingToGenericParameters(val parameterIndex: Int) : DriTarget() { override fun toString(): String = "PointingToGenericParameters($parameterIndex)" } -object PointingToDeclaration: DriTarget() +object PointingToDeclaration : DriTarget() -data class PointingToCallableParameters(val parameterIndex: Int): DriTarget(){ +data class PointingToCallableParameters(val parameterIndex: Int) : DriTarget() { override fun toString(): String = "PointingToCallableParameters($parameterIndex)" } -fun DriTarget.nextTarget(): DriTarget = when(this){ - is PointingToGenericParameters -> PointingToGenericParameters(this.parameterIndex+1) - is PointingToCallableParameters -> PointingToCallableParameters(this.parameterIndex+1) - else -> this - } +fun DriTarget.nextTarget(): DriTarget = when (this) { + is PointingToGenericParameters -> PointingToGenericParameters(this.parameterIndex + 1) + is PointingToCallableParameters -> PointingToCallableParameters(this.parameterIndex + 1) + else -> this +} diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index a7dd0919..c4dabb3b 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -1,8 +1,6 @@ package org.jetbrains.dokka.model import com.intellij.psi.PsiNamedElement -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.Platform import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.model.properties.PropertyContainer @@ -378,6 +376,15 @@ fun Documentable.dfs(predicate: (Documentable) -> Boolean): Documentable? = this.children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull() } +fun Documentable.withDescendants(): Sequence<Documentable> { + return sequence { + yield(this@withDescendants) + children.forEach { child -> + yieldAll(child.withDescendants()) + } + } +} + sealed class Visibility(val name: String) sealed class KotlinVisibility(name: String) : Visibility(name) { object Public : KotlinVisibility("public") |