diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-08-31 13:27:43 +0200 |
---|---|---|
committer | Andrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com> | 2020-09-08 12:52:59 +0200 |
commit | 883408f0d12abfba88434b41cd8d752afc7ebf35 (patch) | |
tree | ec693ce8e071fe7defa3cd760c5e7234697e59a2 /plugins/base/src/main/kotlin/transformers | |
parent | 956e5ff3b21290d536b45f2a185f419416eb5554 (diff) | |
download | dokka-883408f0d12abfba88434b41cd8d752afc7ebf35.tar.gz dokka-883408f0d12abfba88434b41cd8d752afc7ebf35.tar.bz2 dokka-883408f0d12abfba88434b41cd8d752afc7ebf35.zip |
Apply requested changes
Diffstat (limited to 'plugins/base/src/main/kotlin/transformers')
7 files changed, 120 insertions, 224 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt b/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt index 1b65fc22..1fb7b960 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt @@ -62,7 +62,7 @@ class ActualTypealiasAdder : DocumentableTransformer { private fun <T> addActualTypeAlias( elements: Iterable<T>, typealiases: Map<DRI, DTypeAlias> - ): List<T> where T : DClasslike, T : WithExtraProperties<T>, T : WithExpectActual = + ): List<T> where T : DClasslike, T : WithExtraProperties<T>, T : WithSources = elements.map { element -> if (element.expectPresentInSet != null) { typealiases[element.dri]?.let { ta -> @@ -81,4 +81,4 @@ class ActualTypealiasAdder : DocumentableTransformer { element } } -}
\ No newline at end of file +} diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt index 6e288c01..a7cd171e 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt @@ -79,10 +79,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab private fun <T> mergeExpectActual( elements: List<T>, reducer: (T, T) -> T - ): List<T> where T : Documentable, T : WithExpectActual { - - fun T.isExpectActual(): Boolean = - this.safeAs<WithExtraProperties<T>>().let { it != null && it.extra[IsExpectActual] != null } + ): List<T> where T : Documentable, T : WithSources { fun mergeClashingElements(elements: List<Pair<T, Set<DokkaConfiguration.DokkaSourceSet>>>): List<T> = elements.groupBy { it.first.name }.values.flatMap { listOfDocumentableToSSIds -> @@ -147,7 +144,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab return elements.partition { - it.isExpectActual() + (it as? WithIsExpectActual)?.isExpectActual ?: false }.let { (expectActuals, notExpectActuals) -> notExpectActuals.map { it to it.sourceSets } .groupBy { it.first.dri }.values.flatMap(::mergeClashingElements) + diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt index 6a6231c5..aab7c6ba 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt @@ -35,12 +35,8 @@ class DeprecatedDocumentableFilterTransformer(val context: DokkaContext) : PreMe filterPackages(original.packages).let { (modified, packages) -> if (!modified) original else - DModule( - original.name, - packages = packages, - documentation = original.documentation, - sourceSets = original.sourceSets, - extra = original.extra + original.copy( + packages = packages ) } @@ -65,16 +61,10 @@ class DeprecatedDocumentableFilterTransformer(val context: DokkaContext) : PreMe !modified -> pckg else -> { packagesListChanged = true - DPackage( - pckg.dri, - functions, - properties, - classlikes, - pckg.typealiases, - pckg.documentation, - pckg.expectPresentInSet, - pckg.sourceSets, - pckg.extra + pckg.copy( + functions = functions, + properties = properties, + classlikes = classlikes ) } } @@ -98,16 +88,10 @@ class DeprecatedDocumentableFilterTransformer(val context: DokkaContext) : PreMe private fun filterEnumEntries(entries: List<DEnumEntry>) = entries.filter { it.isAllowedInPackage() }.map { entry -> - DEnumEntry( - entry.dri, - entry.name, - entry.documentation, - entry.expectPresentInSet, - filterFunctions(entry.functions).second, - filterProperties(entry.properties).second, - filterClasslikes(entry.classlikes).second, - entry.sourceSets, - entry.extra + entry.copy( + functions = filterFunctions(entry.functions).second, + properties = filterProperties(entry.properties).second, + classlikes = filterClasslikes(entry.classlikes).second, ) } @@ -125,122 +109,70 @@ class DeprecatedDocumentableFilterTransformer(val context: DokkaContext) : PreMe } }.map { classlike -> fun helper(): DClasslike = when (classlike) { - is DClass -> DClass( - classlike.dri, - classlike.name, - filterFunctions(classlike.constructors).let { + is DClass -> classlike.copy( + constructors = filterFunctions(classlike.constructors).let { modified = modified || it.first; it.second }, - filterFunctions(classlike.functions).let { + functions = filterFunctions(classlike.functions).let { modified = modified || it.first; it.second }, - filterProperties(classlike.properties).let { + properties = filterProperties(classlike.properties).let { modified = modified || it.first; it.second }, - filterClasslikes(classlike.classlikes).let { + classlikes = filterClasslikes(classlike.classlikes).let { modified = modified || it.first; it.second - }, - classlike.sources, - classlike.visibility, - classlike.companion, - classlike.generics, - classlike.supertypes, - classlike.documentation, - classlike.expectPresentInSet, - classlike.modifier, - classlike.sourceSets, - classlike.extra + } ) - is DAnnotation -> DAnnotation( - classlike.name, - classlike.dri, - classlike.documentation, - classlike.expectPresentInSet, - classlike.sources, - filterFunctions(classlike.functions).let { + is DAnnotation -> classlike.copy( + functions = filterFunctions(classlike.functions).let { modified = modified || it.first; it.second }, - filterProperties(classlike.properties).let { + properties = filterProperties(classlike.properties).let { modified = modified || it.first; it.second }, - filterClasslikes(classlike.classlikes).let { + classlikes = filterClasslikes(classlike.classlikes).let { modified = modified || it.first; it.second }, - classlike.visibility, - classlike.companion, - filterFunctions(classlike.constructors).let { + constructors = filterFunctions(classlike.constructors).let { modified = modified || it.first; it.second - }, - classlike.generics, - classlike.sourceSets, - classlike.extra + } ) - is DEnum -> DEnum( - classlike.dri, - classlike.name, - filterEnumEntries(classlike.entries), - classlike.documentation, - classlike.expectPresentInSet, - classlike.sources, - filterFunctions(classlike.functions).let { + is DEnum -> classlike.copy( + entries = filterEnumEntries(classlike.entries), + functions = filterFunctions(classlike.functions).let { modified = modified || it.first; it.second }, - filterProperties(classlike.properties).let { + properties = filterProperties(classlike.properties).let { modified = modified || it.first; it.second }, - filterClasslikes(classlike.classlikes).let { + classlikes = filterClasslikes(classlike.classlikes).let { modified = modified || it.first; it.second }, - classlike.visibility, - classlike.companion, - filterFunctions(classlike.constructors).let { + constructors = filterFunctions(classlike.constructors).let { modified = modified || it.first; it.second }, - classlike.supertypes, - classlike.sourceSets, - classlike.extra ) - is DInterface -> DInterface( - classlike.dri, - classlike.name, - classlike.documentation, - classlike.expectPresentInSet, - classlike.sources, - filterFunctions(classlike.functions).let { + is DInterface -> classlike.copy( + functions = filterFunctions(classlike.functions).let { modified = modified || it.first; it.second }, - filterProperties(classlike.properties).let { + properties = filterProperties(classlike.properties).let { modified = modified || it.first; it.second }, - filterClasslikes(classlike.classlikes).let { + classlikes = filterClasslikes(classlike.classlikes).let { modified = modified || it.first; it.second - }, - classlike.visibility, - classlike.companion, - classlike.generics, - classlike.supertypes, - classlike.sourceSets, - classlike.extra + } ) - is DObject -> DObject( - classlike.name, - classlike.dri, - classlike.documentation, - classlike.expectPresentInSet, - classlike.sources, - filterFunctions(classlike.functions).let { + is DObject -> classlike.copy( + functions = filterFunctions(classlike.functions).let { modified = modified || it.first; it.second }, - filterProperties(classlike.properties).let { + properties = filterProperties(classlike.properties).let { modified = modified || it.first; it.second }, - filterClasslikes(classlike.classlikes).let { + classlikes = filterClasslikes(classlike.classlikes).let { modified = modified || it.first; it.second - }, - classlike.visibility, - classlike.supertypes, - classlike.sourceSets, - classlike.extra + } ) } helper() diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt index ff05beed..9b024a0b 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt @@ -122,21 +122,13 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe ) = functions.transform(additionalCondition) { original, filteredPlatforms -> with(original) { - DFunction( - dri, - name, - isConstructor, - parameters, - documentation.filtered(filteredPlatforms), - expectPresentInSet.filtered(filteredPlatforms), - sources.filtered(filteredPlatforms), - visibility.filtered(filteredPlatforms), - type, - generics.mapNotNull { it.filter(filteredPlatforms) }, - receiver, - modifier, - filteredPlatforms, - extra + copy( + documentation = documentation.filtered(filteredPlatforms), + expectPresentInSet = expectPresentInSet.filtered(filteredPlatforms), + sources = sources.filtered(filteredPlatforms), + visibility = visibility.filtered(filteredPlatforms), + generics = generics.mapNotNull { it.filter(filteredPlatforms) }, + sourceSets = filteredPlatforms, ) } } @@ -151,21 +143,13 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe ): Pair<Boolean, List<DProperty>> = properties.transform(additionalCondition, ::hasVisibleAccessorsForPlatform) { original, filteredPlatforms -> with(original) { - DProperty( - dri, - name, - documentation.filtered(filteredPlatforms), - expectPresentInSet.filtered(filteredPlatforms), - sources.filtered(filteredPlatforms), - visibility.filtered(filteredPlatforms), - type, - receiver, - setter, - getter, - modifier, - filteredPlatforms, - generics.mapNotNull { it.filter(filteredPlatforms) }, - extra + copy( + documentation = documentation.filtered(filteredPlatforms), + expectPresentInSet = expectPresentInSet.filtered(filteredPlatforms), + sources = sources.filtered(filteredPlatforms), + visibility = visibility.filtered(filteredPlatforms), + sourceSets = filteredPlatforms, + generics = generics.mapNotNull { it.filter(filteredPlatforms) }, ) } } @@ -235,86 +219,69 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe classlikesListChanged = classlikesListChanged || modified when { !modified -> this - this is DClass -> DClass( - dri, - name, - constructors, - functions, - properties, - classlikes, - sources.filtered(filteredPlatforms), - visibility.filtered(filteredPlatforms), - companion, - generics, - supertypes.filtered(filteredPlatforms), - documentation.filtered(filteredPlatforms), - expectPresentInSet.filtered(filteredPlatforms), - modifier, - filteredPlatforms, - extra + this is DClass -> copy( + constructors = constructors, + functions = functions, + properties = properties, + classlikes = classlikes, + sources = sources.filtered(filteredPlatforms), + visibility = visibility.filtered(filteredPlatforms), + companion = companion, + generics = generics, + supertypes = supertypes.filtered(filteredPlatforms), + documentation = documentation.filtered(filteredPlatforms), + expectPresentInSet = expectPresentInSet.filtered(filteredPlatforms), + sourceSets = filteredPlatforms ) - this is DAnnotation -> DAnnotation( - name, - dri, - documentation.filtered(filteredPlatforms), - expectPresentInSet.filtered(filteredPlatforms), - sources.filtered(filteredPlatforms), - functions, - properties, - classlikes, - visibility.filtered(filteredPlatforms), - companion, - constructors, - generics, - filteredPlatforms, - extra + this is DAnnotation -> copy( + documentation = documentation.filtered(filteredPlatforms), + expectPresentInSet = expectPresentInSet.filtered(filteredPlatforms), + sources = sources.filtered(filteredPlatforms), + functions = functions, + properties = properties, + classlikes = classlikes, + visibility = visibility.filtered(filteredPlatforms), + companion = companion, + constructors = constructors, + generics = generics, + sourceSets = filteredPlatforms ) - this is DEnum -> DEnum( - dri, - name, - enumEntries, - documentation.filtered(filteredPlatforms), - expectPresentInSet.filtered(filteredPlatforms), - sources.filtered(filteredPlatforms), - functions, - properties, - classlikes, - visibility.filtered(filteredPlatforms), - companion, - constructors, - supertypes.filtered(filteredPlatforms), - filteredPlatforms, - extra + this is DEnum -> copy( + entries = enumEntries, + documentation = documentation.filtered(filteredPlatforms), + expectPresentInSet = expectPresentInSet.filtered(filteredPlatforms), + sources = sources.filtered(filteredPlatforms), + functions = functions, + properties = properties, + classlikes = classlikes, + visibility = visibility.filtered(filteredPlatforms), + companion = companion, + constructors = constructors, + supertypes = supertypes.filtered(filteredPlatforms), + sourceSets = filteredPlatforms ) - this is DInterface -> DInterface( - dri, - name, - documentation.filtered(filteredPlatforms), - expectPresentInSet.filtered(filteredPlatforms), - sources.filtered(filteredPlatforms), - functions, - properties, - classlikes, - visibility.filtered(filteredPlatforms), - companion, - generics, - supertypes.filtered(filteredPlatforms), - filteredPlatforms, - extra + this is DInterface -> copy( + documentation = documentation.filtered(filteredPlatforms), + expectPresentInSet = expectPresentInSet.filtered(filteredPlatforms), + sources = sources.filtered(filteredPlatforms), + functions = functions, + properties = properties, + classlikes = classlikes, + visibility = visibility.filtered(filteredPlatforms), + companion = companion, + generics = generics, + supertypes = supertypes.filtered(filteredPlatforms), + sourceSets = filteredPlatforms ) - this is DObject -> DObject( - name, - dri, - documentation.filtered(filteredPlatforms), - expectPresentInSet.filtered(filteredPlatforms), - sources.filtered(filteredPlatforms), - functions, - properties, - classlikes, - visibility, - supertypes.filtered(filteredPlatforms), - filteredPlatforms, - extra + this is DObject -> copy( + documentation = documentation.filtered(filteredPlatforms), + expectPresentInSet = expectPresentInSet.filtered(filteredPlatforms), + sources = sources.filtered(filteredPlatforms), + functions = functions, + properties = properties, + classlikes = classlikes, + supertypes = supertypes.filtered(filteredPlatforms), + sourceSets = filteredPlatforms ) else -> null } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt index ddc0cd37..2608d9ba 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt @@ -129,7 +129,7 @@ internal class ReportUndocumentedTransformer : DocumentableTransformer { private fun callableMemberDescriptorOrNull( documentable: Documentable, sourceSet: DokkaSourceSet ): CallableMemberDescriptor? { - if (documentable is WithExpectActual) { + if (documentable is WithSources) { return documentable.sources[sourceSet] .safeAs<DescriptorDocumentableSource>()?.descriptor .safeAs() diff --git a/plugins/base/src/main/kotlin/transformers/documentables/SuppressedDocumentableFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/SuppressedDocumentableFilterTransformer.kt index 7febabbb..b066e69b 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/SuppressedDocumentableFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/SuppressedDocumentableFilterTransformer.kt @@ -42,7 +42,7 @@ class SuppressedDocumentableFilterTransformer(val context: DokkaContext) : PreMe } private fun isSuppressed(documentable: Documentable): Boolean { - if (documentable !is WithExpectActual) return false + if (documentable !is WithSources) return false val sourceFile = File(source(documentable).path).absoluteFile return sourceSet(documentable).suppressedFiles.any { suppressedFile -> sourceFile.startsWith(suppressedFile.absoluteFile) diff --git a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt index 8f6f09fb..76bf0067 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt @@ -8,7 +8,7 @@ import org.jetbrains.dokka.model.DocumentableSource import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.analysis.DescriptorDocumentableSource import org.jetbrains.dokka.analysis.PsiDocumentableSource -import org.jetbrains.dokka.model.WithExpectActual +import org.jetbrains.dokka.model.WithSources import org.jetbrains.dokka.model.toDisplaySourceSets import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext @@ -23,7 +23,7 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent override fun invoke(input: RootPageNode) = input.transformContentPagesTree { node -> when (val documentable = node.documentable) { - is WithExpectActual -> resolveSources(documentable) + is WithSources -> resolveSources(documentable) .takeIf { it.isNotEmpty() } ?.let { node.addSourcesContent(it) } ?: node @@ -34,7 +34,7 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent private fun getSourceLinks() = context.configuration.sourceSets .flatMap { it.sourceLinks.map { sl -> SourceLink(sl, it) } } - private fun resolveSources(documentable: WithExpectActual) = documentable.sources + private fun resolveSources(documentable: WithSources) = documentable.sources .mapNotNull { entry -> getSourceLinks().find { File(entry.value.path).startsWith(it.path) && it.sourceSetData == entry.key }?.let { Pair( |