aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r--plugins/base/src/main/kotlin/DokkaBaseConfiguration.kt4
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt6
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt5
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt75
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt2
5 files changed, 61 insertions, 31 deletions
diff --git a/plugins/base/src/main/kotlin/DokkaBaseConfiguration.kt b/plugins/base/src/main/kotlin/DokkaBaseConfiguration.kt
index c18b3446..5b93c209 100644
--- a/plugins/base/src/main/kotlin/DokkaBaseConfiguration.kt
+++ b/plugins/base/src/main/kotlin/DokkaBaseConfiguration.kt
@@ -5,10 +5,12 @@ import java.io.File
data class DokkaBaseConfiguration(
var customStyleSheets: List<File> = defaultCustomStyleSheets,
- var customAssets: List<File> = defaultCustomAssets
+ var customAssets: List<File> = defaultCustomAssets,
+ var separateInheritedMembers: Boolean = separateInheritedMembersDefault
): ConfigurableBlock {
companion object {
val defaultCustomStyleSheets: List<File> = emptyList()
val defaultCustomAssets: List<File> = emptyList()
+ const val separateInheritedMembersDefault: Boolean = false
}
} \ No newline at end of file
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index f388ee44..4695dac5 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -405,6 +405,7 @@ private class DokkaDescriptorVisitor(
): DProperty {
val dri = parent.dri.copy(callable = Callable.from(originalDescriptor))
val descriptor = originalDescriptor.getConcreteDescriptor()
+ val inheritedFrom = descriptor.createDRI().let { (originalDri, _) -> originalDri.takeIf { it != dri } }
val isExpect = descriptor.isExpect
val isActual = descriptor.isActual
@@ -438,7 +439,8 @@ private class DokkaDescriptorVisitor(
(descriptor.additionalExtras() + descriptor.getAnnotationsWithBackingField()
.toAdditionalExtras()).toSet().toSourceSetDependent().toAdditionalModifiers(),
descriptor.getAnnotationsWithBackingField().toSourceSetDependent().toAnnotations(),
- descriptor.getDefaultValue()?.let { DefaultValue(it) }
+ descriptor.getDefaultValue()?.let { DefaultValue(it) },
+ InheritedMember(inheritedFrom.toSourceSetDependent()),
))
)
}
@@ -484,7 +486,7 @@ private class DokkaDescriptorVisitor(
sourceSets = setOf(sourceSet),
isExpectActual = (isExpect || isActual),
extra = PropertyContainer.withAll(
- InheritedFunction(inheritedFrom.toSourceSetDependent()),
+ InheritedMember(inheritedFrom.toSourceSetDependent()),
descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(),
descriptor.getAnnotations().toSourceSetDependent().toAnnotations()
)
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt
index 2aa3e2dc..18647207 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt
@@ -1,8 +1,10 @@
package org.jetbrains.dokka.base.translators.documentables
import org.jetbrains.dokka.base.DokkaBase
+import org.jetbrains.dokka.base.DokkaBaseConfiguration
import org.jetbrains.dokka.model.DModule
import org.jetbrains.dokka.pages.ModulePageNode
+import org.jetbrains.dokka.plugability.configuration
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.querySingle
@@ -11,10 +13,11 @@ import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslat
class DefaultDocumentableToPageTranslator(
context: DokkaContext
) : DocumentableToPageTranslator {
+ private val configuration = configuration<DokkaBase, DokkaBaseConfiguration>(context)
private val commentsToContentConverter = context.plugin<DokkaBase>().querySingle { commentsToContentConverter }
private val signatureProvider = context.plugin<DokkaBase>().querySingle { signatureProvider }
private val logger = context.logger
override fun invoke(module: DModule): ModulePageNode =
- DefaultPageCreator(commentsToContentConverter, signatureProvider, logger).pageForModule(module)
+ DefaultPageCreator(configuration, commentsToContentConverter, signatureProvider, logger).pageForModule(module)
} \ No newline at end of file
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index e0ced0aa..355eff16 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
import kotlin.reflect.KClass
import kotlin.reflect.full.isSubclassOf
import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
+import org.jetbrains.dokka.base.DokkaBaseConfiguration
import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint
import org.jetbrains.dokka.base.transformers.documentables.ClashingDriIdentifier
@@ -25,12 +26,15 @@ private val specialTags: Set<KClass<out TagWrapper>> =
setOf(Property::class, Description::class, Constructor::class, Receiver::class, Param::class, See::class)
open class DefaultPageCreator(
+ configuration: DokkaBaseConfiguration?,
commentsToContentConverter: CommentsToContentConverter,
signatureProvider: SignatureProvider,
val logger: DokkaLogger
) {
protected open val contentBuilder = PageContentBuilder(commentsToContentConverter, signatureProvider, logger)
+ protected val separateInheritedMembers = configuration?.separateInheritedMembers ?: DokkaBaseConfiguration.separateInheritedMembersDefault
+
open fun pageForModule(m: DModule) =
ModulePageNode(m.name.ifEmpty { "<root>" }, contentForModule(m), m, m.packages.map(::pageForPackage))
@@ -56,7 +60,7 @@ open class DefaultPageCreator(
constructors.map(::pageForFunction) +
c.classlikes.renameClashingDocumentable().map(::pageForClasslike) +
c.filteredFunctions.renameClashingDocumentable().map(::pageForFunction) +
- c.properties.renameClashingDocumentable().mapNotNull(::pageForProperty) +
+ c.filteredProperties.renameClashingDocumentable().mapNotNull(::pageForProperty) +
if (c is DEnum) c.entries.map(::pageForEnumEntry) else emptyList()
)
@@ -86,12 +90,17 @@ open class DefaultPageCreator(
open fun pageForProperty(p: DProperty): MemberPageNode? = MemberPageNode(p.nameAfterClash(), contentForProperty(p), setOf(p.dri), p)
+ private fun <T> T.isInherited(): Boolean where T: Documentable, T: WithExtraProperties<T> =
+ sourceSets.all { sourceSet -> extra[InheritedMember]?.isInherited(sourceSet) == true }
+
private val WithScope.filteredFunctions: List<DFunction>
- get() = functions.mapNotNull { function ->
- function.takeIf {
- it.sourceSets.any { sourceSet -> it.extra[InheritedFunction]?.isInherited(sourceSet) != true }
- }
- }
+ get() = functions.filterNot { it.isInherited() }
+
+ private val WithScope.filteredProperties: List<DProperty>
+ get() = properties.filterNot { it.isInherited() }
+
+ private fun <T> Collection<T>.splitInherited(): Pair<List<T>, List<T>> where T: Documentable, T: WithExtraProperties<T> =
+ partition { it.isInherited() }
protected open fun contentForModule(m: DModule) = contentBuilder.contentFor(m) {
group(kind = ContentKind.Cover) {
@@ -153,26 +162,16 @@ open class DefaultPageCreator(
(s as? DPackage)?.typealiases ?: emptyList()
).flatten()
divergentBlock("Types", types, ContentKind.Classlikes, extra = mainExtra + SimpleAttr.header("Types"))
- divergentBlock(
- "Functions",
- s.functions.sorted(),
- ContentKind.Functions,
- extra = mainExtra + SimpleAttr.header("Functions")
- )
- block(
- "Properties",
- 2,
- ContentKind.Properties,
- s.properties,
- sourceSets.toSet(),
- needsAnchors = true,
- extra = mainExtra + SimpleAttr.header("Properties")
- ) {
- link(it.name, it.dri, kind = ContentKind.Main)
- sourceSetDependentHint(it.dri, it.sourceSets.toSet(), kind = ContentKind.SourceSetDependentHint, extra = PropertyContainer.empty()) {
- +buildSignature(it)
- contentForBrief(it)
- }
+ if (separateInheritedMembers) {
+ val (inheritedFunctions, memberFunctions) = s.functions.splitInherited()
+ val (inheritedProperties, memberProperties) = s.properties.splitInherited()
+ propertiesBlock("Properties", memberProperties, sourceSets)
+ propertiesBlock("Inherited properties", inheritedProperties, sourceSets)
+ functionsBlock("Functions", memberFunctions)
+ functionsBlock("Inherited functions", inheritedFunctions)
+ } else {
+ functionsBlock("Functions", s.functions)
+ propertiesBlock("Properties", s.properties, sourceSets)
}
s.safeAs<WithExtraProperties<Documentable>>()?.let { it.extra[InheritorsInfo] }?.let { inheritors ->
val map = inheritors.value.filter { it.value.isNotEmpty() }
@@ -537,6 +536,30 @@ open class DefaultPageCreator(
}
}
+ private fun DocumentableContentBuilder.functionsBlock(name: String, list: Collection<DFunction>) = divergentBlock(
+ name,
+ list.sorted(),
+ ContentKind.Functions,
+ extra = mainExtra + SimpleAttr.header(name)
+ )
+ private fun DocumentableContentBuilder.propertiesBlock(name: String, list: Collection<DProperty>, sourceSets: Set<DokkaSourceSet>) {
+ block(
+ name,
+ 2,
+ ContentKind.Properties,
+ list,
+ sourceSets,
+ needsAnchors = true,
+ extra = mainExtra + SimpleAttr.header(name)
+ ) {
+ link(it.name, it.dri, kind = ContentKind.Main)
+ sourceSetDependentHint(it.dri, it.sourceSets.toSet(), kind = ContentKind.SourceSetDependentHint) {
+ +buildSignature(it)
+ contentForBrief(it)
+ }
+ }
+ }
+
protected open fun DocumentableContentBuilder.divergentBlock(
name: String,
collection: Collection<Documentable>,
diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
index 00fab531..1f52f373 100644
--- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
@@ -367,7 +367,7 @@ class DefaultPsiToDocumentableTranslator(
false,
psi.additionalExtras().let {
PropertyContainer.withAll(
- InheritedFunction(inheritedFrom.toSourceSetDependent()),
+ InheritedMember(inheritedFrom.toSourceSetDependent()),
it.toSourceSetDependent().toAdditionalModifiers(),
(psi.annotations.toList()
.toListOfAnnotations() + it.toListOfAnnotations()).toSourceSetDependent()