diff options
58 files changed, 656 insertions, 564 deletions
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index 94792303..bd632546 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -84,7 +84,7 @@ class DokkaBootstrapImpl : DokkaBootstrap { fun configure(logger: DokkaLogger, configuration: DokkaConfigurationImpl) = with(configuration) { - fun defaultLinks(config: PassConfigurationImpl): List<ExternalDocumentationLinkImpl> { + fun defaultLinks(config: DokkaSourceSetImpl): List<ExternalDocumentationLinkImpl> { val links = mutableListOf<ExternalDocumentationLinkImpl>() if (!config.noJdkLink) links += DokkaConfiguration.ExternalDocumentationLink @@ -100,8 +100,8 @@ class DokkaBootstrapImpl : DokkaBootstrap { val configurationWithLinks = configuration.copy( - passesConfigurations = - passesConfigurations.map { + sourceSets = + sourceSets.map { val links: List<ExternalDocumentationLinkImpl> = it.externalDocumentationLinks + defaultLinks(it) it.copy(externalDocumentationLinks = links) diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index b88c6223..ce8d229a 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -1,8 +1,7 @@ package org.jetbrains.dokka import org.jetbrains.dokka.model.DModule -import org.jetbrains.dokka.model.SourceSetCache -import org.jetbrains.dokka.model.SourceSetData +import org.jetbrains.dokka.DokkaConfiguration.* import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.DokkaPlugin @@ -18,13 +17,11 @@ class DokkaGenerator( private val logger: DokkaLogger ) { fun generate() = timed { - val sourceSetsCache = SourceSetCache() - report("Initializing plugins") - val context = initializePlugins(configuration, logger, sourceSetsCache) + val context = initializePlugins(configuration, logger) report("Creating documentation models") - val modulesFromPlatforms = createDocumentationModels(context, sourceSetsCache) + val modulesFromPlatforms = createDocumentationModels(context) report("Transforming documentation model before merging") val transformedDocumentationBeforeMerge = transformDocumentationModelBeforeMerge(modulesFromPlatforms, context) @@ -48,9 +45,8 @@ class DokkaGenerator( }.dump("\n\n === TIME MEASUREMENT ===\n") fun generateAllModulesPage() = timed { - val sourceSetsCache = SourceSetCache() report("Initializing plugins") - val context = initializePlugins(configuration, logger, sourceSetsCache) + val context = initializePlugins(configuration, logger) report("Creating all modules page") val pages = createAllModulePage(context) @@ -66,15 +62,12 @@ class DokkaGenerator( fun initializePlugins( configuration: DokkaConfiguration, logger: DokkaLogger, - sourceSetsCache: SourceSetCache, pluginOverrides: List<DokkaPlugin> = emptyList() - ) = DokkaContext.create(configuration, logger, sourceSetsCache, pluginOverrides) + ) = DokkaContext.create(configuration, logger, pluginOverrides) fun createDocumentationModels( - context: DokkaContext, - sourceSetsCache: SourceSetCache - ) = context.configuration.passesConfigurations - .map { passConfiguration -> sourceSetsCache.getSourceSet(passConfiguration) } + context: DokkaContext + ) = context.configuration.sourceSets .flatMap { passConfiguration -> translateSources(passConfiguration, context) } fun transformDocumentationModelBeforeMerge( @@ -133,9 +126,9 @@ class DokkaGenerator( } } - private fun translateSources(platformData: SourceSetData, context: DokkaContext) = + private fun translateSources(sourceSet: DokkaSourceSet, context: DokkaContext) = context[CoreExtensions.sourceToDocumentableTranslator].map { - it.invoke(platformData, context) + it.invoke(sourceSet, context) } } diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt index b016f83d..463d2342 100644 --- a/core/src/main/kotlin/configuration.kt +++ b/core/src/main/kotlin/configuration.kt @@ -49,12 +49,12 @@ interface DokkaConfiguration { val cacheRoot: String? val offlineMode: Boolean val failOnWarning: Boolean - val passesConfigurations: List<PassConfiguration> + val sourceSets: List<DokkaSourceSet> val modules: List<DokkaModuleDescription> val pluginsClasspath: List<File> val pluginsConfiguration: Map<String, String> - interface PassConfiguration { + interface DokkaSourceSet { val moduleName: String val displayName: String val sourceSetID: String diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt index 4e83d3c3..d3ac9df2 100644 --- a/core/src/main/kotlin/defaultConfiguration.kt +++ b/core/src/main/kotlin/defaultConfiguration.kt @@ -8,14 +8,14 @@ data class DokkaConfigurationImpl( override val format: String, override val cacheRoot: String?, override val offlineMode: Boolean, - override val passesConfigurations: List<PassConfigurationImpl>, + override val sourceSets: List<DokkaSourceSetImpl>, override val pluginsClasspath: List<File>, override val pluginsConfiguration: Map<String, String>, override val modules: List<DokkaModuleDescriptionImpl>, override val failOnWarning: Boolean ) : DokkaConfiguration -data class PassConfigurationImpl( +data class DokkaSourceSetImpl( override val moduleName: String, override val displayName: String, override val sourceSetID: String, @@ -39,7 +39,7 @@ data class PassConfigurationImpl( override val noJdkLink: Boolean, override val suppressedFiles: List<String>, override val analysisPlatform: Platform -) : DokkaConfiguration.PassConfiguration +) : DokkaConfiguration.DokkaSourceSet data class DokkaModuleDescriptionImpl( override val name: String, diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index 768bddc5..35278302 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.model +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.model.properties.PropertyContainer @@ -11,8 +12,8 @@ abstract class Documentable { abstract val dri: DRI abstract val children: List<Documentable> abstract val documentation: SourceSetDependent<DocumentationNode> - abstract val sourceSets: Set<SourceSetData> - abstract val expectPresentInSet: SourceSetData? + abstract val sourceSets: Set<DokkaSourceSet> + abstract val expectPresentInSet: DokkaSourceSet? override fun toString(): String = "${javaClass.simpleName}($dri)" @@ -23,7 +24,7 @@ abstract class Documentable { override fun hashCode() = dri.hashCode() } -typealias SourceSetDependent<T> = Map<SourceSetData, T> +typealias SourceSetDependent<T> = Map<DokkaSourceSet, T> interface WithExpectActual { val sources: SourceSetDependent<DocumentableSource> @@ -88,8 +89,8 @@ data class DModule( override val name: String, val packages: List<DPackage>, override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: SourceSetData? = null, - override val sourceSets: Set<SourceSetData>, + override val expectPresentInSet: DokkaSourceSet? = null, + override val sourceSets: Set<DokkaSourceSet>, override val extra: PropertyContainer<DModule> = PropertyContainer.empty() ) : Documentable(), WithExtraProperties<DModule> { override val dri: DRI = DRI.topLevel @@ -106,8 +107,8 @@ data class DPackage( override val classlikes: List<DClasslike>, val typealiases: List<DTypeAlias>, override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: SourceSetData? = null, - override val sourceSets: Set<SourceSetData>, + override val expectPresentInSet: DokkaSourceSet? = null, + override val sourceSets: Set<DokkaSourceSet>, override val extra: PropertyContainer<DPackage> = PropertyContainer.empty() ) : Documentable(), WithScope, WithExtraProperties<DPackage> { override val name = dri.packageName.orEmpty() @@ -130,9 +131,9 @@ data class DClass( override val generics: List<DTypeParameter>, override val supertypes: SourceSetDependent<List<DRI>>, override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, override val modifier: SourceSetDependent<Modifier>, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val extra: PropertyContainer<DClass> = PropertyContainer.empty() ) : DClasslike(), WithAbstraction, WithCompanion, WithConstructors, WithGenerics, WithSupertypes, WithExtraProperties<DClass> { @@ -148,7 +149,7 @@ data class DEnum( override val name: String, val entries: List<DEnumEntry>, override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, override val sources: SourceSetDependent<DocumentableSource>, override val functions: List<DFunction>, override val properties: List<DProperty>, @@ -157,7 +158,7 @@ data class DEnum( override val companion: DObject?, override val constructors: List<DFunction>, override val supertypes: SourceSetDependent<List<DRI>>, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val extra: PropertyContainer<DEnum> = PropertyContainer.empty() ) : DClasslike(), WithCompanion, WithConstructors, WithSupertypes, WithExtraProperties<DEnum> { override val children: List<Documentable> @@ -170,11 +171,11 @@ data class DEnumEntry( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, override val functions: List<DFunction>, override val properties: List<DProperty>, override val classlikes: List<DClasslike>, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val extra: PropertyContainer<DEnumEntry> = PropertyContainer.empty() ) : Documentable(), WithScope, WithExtraProperties<DEnumEntry> { override val children: List<Documentable> @@ -189,14 +190,14 @@ data class DFunction( val isConstructor: Boolean, val parameters: List<DParameter>, override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, override val sources: SourceSetDependent<DocumentableSource>, override val visibility: SourceSetDependent<Visibility>, override val type: Bound, override val generics: List<DTypeParameter>, override val receiver: DParameter?, override val modifier: SourceSetDependent<Modifier>, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val extra: PropertyContainer<DFunction> = PropertyContainer.empty() ) : Documentable(), Callable, WithGenerics, WithExtraProperties<DFunction> { override val children: List<Documentable> @@ -209,7 +210,7 @@ data class DInterface( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, override val sources: SourceSetDependent<DocumentableSource>, override val functions: List<DFunction>, override val properties: List<DProperty>, @@ -218,7 +219,7 @@ data class DInterface( override val companion: DObject?, override val generics: List<DTypeParameter>, override val supertypes: SourceSetDependent<List<DRI>>, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val extra: PropertyContainer<DInterface> = PropertyContainer.empty() ) : DClasslike(), WithCompanion, WithGenerics, WithSupertypes, WithExtraProperties<DInterface> { override val children: List<Documentable> @@ -231,14 +232,14 @@ data class DObject( override val name: String?, override val dri: DRI, override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, override val sources: SourceSetDependent<DocumentableSource>, override val functions: List<DFunction>, override val properties: List<DProperty>, override val classlikes: List<DClasslike>, override val visibility: SourceSetDependent<Visibility>, override val supertypes: SourceSetDependent<List<DRI>>, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val extra: PropertyContainer<DObject> = PropertyContainer.empty() ) : DClasslike(), WithSupertypes, WithExtraProperties<DObject> { override val children: List<Documentable> @@ -251,7 +252,7 @@ data class DAnnotation( override val name: String, override val dri: DRI, override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, override val sources: SourceSetDependent<DocumentableSource>, override val functions: List<DFunction>, override val properties: List<DProperty>, @@ -260,7 +261,7 @@ data class DAnnotation( override val companion: DObject?, override val constructors: List<DFunction>, override val generics: List<DTypeParameter>, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val extra: PropertyContainer<DAnnotation> = PropertyContainer.empty() ) : DClasslike(), WithCompanion, WithConstructors, WithExtraProperties<DAnnotation>, WithGenerics { override val children: List<Documentable> @@ -273,7 +274,7 @@ data class DProperty( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, override val sources: SourceSetDependent<DocumentableSource>, override val visibility: SourceSetDependent<Visibility>, override val type: Bound, @@ -281,7 +282,7 @@ data class DProperty( val setter: DFunction?, val getter: DFunction?, override val modifier: SourceSetDependent<Modifier>, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val generics: List<DTypeParameter>, override val extra: PropertyContainer<DProperty> = PropertyContainer.empty() ) : Documentable(), Callable, WithExtraProperties<DProperty>, WithGenerics { @@ -296,9 +297,9 @@ data class DParameter( override val dri: DRI, override val name: String?, override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, val type: Bound, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val extra: PropertyContainer<DParameter> = PropertyContainer.empty() ) : Documentable(), WithExtraProperties<DParameter> { override val children: List<Nothing> @@ -311,9 +312,9 @@ data class DTypeParameter( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, val bounds: List<Bound>, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val extra: PropertyContainer<DTypeParameter> = PropertyContainer.empty() ) : Documentable(), WithExtraProperties<DTypeParameter> { override val children: List<Nothing> @@ -329,8 +330,8 @@ data class DTypeAlias( val underlyingType: SourceSetDependent<Bound>, override val visibility: SourceSetDependent<Visibility>, override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: SourceSetData?, - override val sourceSets: Set<SourceSetData>, + override val expectPresentInSet: DokkaSourceSet?, + override val sourceSets: Set<DokkaSourceSet>, override val extra: PropertyContainer<DTypeAlias> = PropertyContainer.empty() ) : Documentable(), WithType, WithVisibility, WithExtraProperties<DTypeAlias> { override val children: List<Nothing> diff --git a/core/src/main/kotlin/model/SourceSetData.kt b/core/src/main/kotlin/model/SourceSetData.kt deleted file mode 100644 index 3e38cc7b..00000000 --- a/core/src/main/kotlin/model/SourceSetData.kt +++ /dev/null @@ -1,38 +0,0 @@ -package org.jetbrains.dokka.model - -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.plugability.DokkaContext - -data class SourceSetData( - val moduleName: String, - val sourceSetID: String, - val displayName: String, - val platform: Platform, - val sourceRoots: List<DokkaConfiguration.SourceRoot> = emptyList(), - val dependentSourceSets: List<String> = emptyList() -) - -class SourceSetCache { - private val sourceSets = HashMap<String, SourceSetData>() - - val allSourceSets: List<SourceSetData> - get() = sourceSets.values.toList() - - fun getSourceSet(pass: DokkaConfiguration.PassConfiguration) = - sourceSets.getOrPut(pass.sourceSetID, - { - SourceSetData( - pass.moduleName, - pass.sourceSetID, - pass.displayName, - pass.analysisPlatform, - pass.sourceRoots, - pass.dependentSourceSets - ) - } - ) -} - -fun DokkaContext.sourceSet(pass: DokkaConfiguration.PassConfiguration): SourceSetData = - sourceSetCache.getSourceSet(pass)
\ No newline at end of file diff --git a/core/src/main/kotlin/model/documentableProperties.kt b/core/src/main/kotlin/model/documentableProperties.kt index 2aec199c..cd6a9335 100644 --- a/core/src/main/kotlin/model/documentableProperties.kt +++ b/core/src/main/kotlin/model/documentableProperties.kt @@ -1,26 +1,26 @@ package org.jetbrains.dokka.model +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy -data class InheritedFunction(val inheritedFrom: SourceSetDependent<DRI?>): ExtraProperty<DFunction> { +data class InheritedFunction(val inheritedFrom: SourceSetDependent<DRI?>) : ExtraProperty<DFunction> { companion object : ExtraProperty.Key<DFunction, InheritedFunction> { override fun mergeStrategyFor(left: InheritedFunction, right: InheritedFunction) = MergeStrategy.Replace( InheritedFunction(left.inheritedFrom + right.inheritedFrom) ) } - fun isInherited(sourceSetDependent: SourceSetData): Boolean = inheritedFrom[sourceSetDependent] != null + fun isInherited(sourceSetDependent: DokkaSourceSet): Boolean = inheritedFrom[sourceSetDependent] != null override val key: ExtraProperty.Key<DFunction, *> = InheritedFunction } -data class ImplementedInterfaces(val interfaces: SourceSetDependent<List<DRI>>): ExtraProperty<Documentable> { +data class ImplementedInterfaces(val interfaces: SourceSetDependent<List<DRI>>) : ExtraProperty<Documentable> { companion object : ExtraProperty.Key<Documentable, ImplementedInterfaces> { - override fun mergeStrategyFor(left: ImplementedInterfaces, right: ImplementedInterfaces) = MergeStrategy.Replace( - ImplementedInterfaces(left.interfaces + right.interfaces) - ) + override fun mergeStrategyFor(left: ImplementedInterfaces, right: ImplementedInterfaces) = + MergeStrategy.Replace(ImplementedInterfaces(left.interfaces + right.interfaces)) } override val key: ExtraProperty.Key<Documentable, *> = ImplementedInterfaces diff --git a/core/src/main/kotlin/model/documentableUtils.kt b/core/src/main/kotlin/model/documentableUtils.kt index 2d4ade15..7057a62c 100644 --- a/core/src/main/kotlin/model/documentableUtils.kt +++ b/core/src/main/kotlin/model/documentableUtils.kt @@ -1,12 +1,14 @@ package org.jetbrains.dokka.model -fun <T> SourceSetDependent<T>.filtered(platformDataList: Set<SourceSetData>) = filter { it.key in platformDataList } -fun SourceSetData?.filtered(platformDataList: Set<SourceSetData>) = takeIf { this in platformDataList } +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet -fun DTypeParameter.filter(filteredData: Set<SourceSetData>) = - if (filteredData.containsAll(sourceSets)) this +fun <T> SourceSetDependent<T>.filtered(sourceSets: Set<DokkaSourceSet>) = filter { it.key in sourceSets } +fun DokkaSourceSet?.filtered(sourceSets: Set<DokkaSourceSet>) = takeIf { this in sourceSets } + +fun DTypeParameter.filter(filteredSet: Set<DokkaSourceSet>) = + if (filteredSet.containsAll(sourceSets)) this else { - val intersection = filteredData.intersect(sourceSets) + val intersection = filteredSet.intersect(sourceSets) if (intersection.isEmpty()) null else DTypeParameter( dri, diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt index 1b9c937d..dc23a082 100644 --- a/core/src/main/kotlin/pages/ContentNodes.kt +++ b/core/src/main/kotlin/pages/ContentNodes.kt @@ -1,7 +1,7 @@ package org.jetbrains.dokka.pages +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.model.properties.WithExtraProperties @@ -11,7 +11,7 @@ data class DCI(val dri: Set<DRI>, val kind: Kind) { interface ContentNode : WithExtraProperties<ContentNode> { val dci: DCI - val sourceSets: Set<SourceSetData> + val sourceSets: Set<DokkaSourceSet> val style: Set<Style> fun hasAnyContent(): Boolean @@ -21,7 +21,7 @@ interface ContentNode : WithExtraProperties<ContentNode> { data class ContentText( val text: String, override val dci: DCI, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val style: Set<Style> = emptySet(), override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty() ) : ContentNode { @@ -32,7 +32,7 @@ data class ContentText( // TODO: Remove data class ContentBreakLine( - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val dci: DCI = DCI(emptySet(), ContentKind.Empty), override val style: Set<Style> = emptySet(), override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty() @@ -47,11 +47,12 @@ data class ContentHeader( override val children: List<ContentNode>, val level: Int, override val dci: DCI, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val style: Set<Style>, override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty() ) : ContentComposite { constructor(level: Int, c: ContentComposite) : this(c.children, level, c.dci, c.sourceSets, c.style, c.extra) + override fun withNewExtras(newExtras: PropertyContainer<ContentNode>): ContentHeader = copy(extra = newExtras) } @@ -60,7 +61,7 @@ data class ContentCode( override val children: List<ContentNode>, val language: String, override val dci: DCI, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val style: Set<Style>, override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty() ) : ContentComposite { @@ -75,7 +76,7 @@ data class ContentDRILink( override val children: List<ContentNode>, val address: DRI, override val dci: DCI, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val style: Set<Style> = emptySet(), override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty() ) : ContentLink { @@ -87,7 +88,7 @@ data class ContentResolvedLink( override val children: List<ContentNode>, val address: String, override val dci: DCI, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val style: Set<Style> = emptySet(), override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty() ) : ContentLink { @@ -101,7 +102,7 @@ data class ContentEmbeddedResource( val address: String, val altText: String?, override val dci: DCI, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val style: Set<Style> = emptySet(), override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty() ) : ContentLink { @@ -121,7 +122,7 @@ data class ContentTable( val header: List<ContentGroup>, override val children: List<ContentGroup>, override val dci: DCI, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val style: Set<Style>, override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty() ) : ContentComposite { @@ -133,7 +134,7 @@ data class ContentList( override val children: List<ContentNode>, val ordered: Boolean, override val dci: DCI, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val style: Set<Style>, override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty() ) : ContentComposite { @@ -144,7 +145,7 @@ data class ContentList( data class ContentGroup( override val children: List<ContentNode>, override val dci: DCI, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val style: Set<Style>, override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty() ) : ContentComposite { @@ -164,7 +165,7 @@ data class ContentDivergentGroup( ) : ContentComposite { data class GroupID(val name: String) - override val sourceSets: Set<SourceSetData> + override val sourceSets: Set<DokkaSourceSet> get() = children.flatMap { it.sourceSets }.distinct().toSet() override fun withNewExtras(newExtras: PropertyContainer<ContentNode>): ContentDivergentGroup = @@ -177,7 +178,7 @@ data class ContentDivergentInstance( val divergent: ContentNode, val after: ContentNode?, override val dci: DCI, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val style: Set<Style>, override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty() ) : ContentComposite { @@ -190,7 +191,7 @@ data class ContentDivergentInstance( data class PlatformHintedContent( val inner: ContentNode, - override val sourceSets: Set<SourceSetData> + override val sourceSets: Set<DokkaSourceSet> ) : ContentComposite { override val children = listOf(inner) @@ -231,9 +232,9 @@ enum class ContentStyle : Style { RowTitle, TabbedContent, WithExtraAttributes } -object CommentTable: Style +object CommentTable : Style -object MultimoduleTable: Style +object MultimoduleTable : Style fun ContentNode.dfs(predicate: (ContentNode) -> Boolean): ContentNode? = if (predicate(this)) { this diff --git a/core/src/main/kotlin/plugability/DokkaContext.kt b/core/src/main/kotlin/plugability/DokkaContext.kt index a2ff26c7..15349ff0 100644 --- a/core/src/main/kotlin/plugability/DokkaContext.kt +++ b/core/src/main/kotlin/plugability/DokkaContext.kt @@ -1,7 +1,6 @@ package org.jetbrains.dokka.plugability import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.model.SourceSetCache import org.jetbrains.dokka.utilities.DokkaLogger import java.io.File import java.net.URLClassLoader @@ -18,7 +17,6 @@ interface DokkaContext { fun <T, E> single(point: E): T where T : Any, E : ExtensionPoint<T> - val sourceSetCache: SourceSetCache val logger: DokkaLogger val configuration: DokkaConfiguration val unusedPoints: Collection<ExtensionPoint<*>> @@ -28,10 +26,9 @@ interface DokkaContext { fun create( configuration: DokkaConfiguration, logger: DokkaLogger, - sourceSetsCache: SourceSetCache, pluginOverrides: List<DokkaPlugin> ): DokkaContext = - DokkaContextConfigurationImpl(logger, configuration, sourceSetsCache).apply { + DokkaContextConfigurationImpl(logger, configuration).apply { // File(it.path) is a workaround for an incorrect filesystem in a File instance returned by Gradle. configuration.pluginsClasspath.map { File(it.path).toURI().toURL() } .toTypedArray() @@ -54,8 +51,7 @@ interface DokkaContextConfiguration { private class DokkaContextConfigurationImpl( override val logger: DokkaLogger, - override val configuration: DokkaConfiguration, - override val sourceSetCache: SourceSetCache + override val configuration: DokkaConfiguration ) : DokkaContext, DokkaContextConfiguration { private val plugins = mutableMapOf<KClass<*>, DokkaPlugin>() private val pluginStubs = mutableMapOf<KClass<*>, DokkaPlugin>() diff --git a/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt b/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt index f9c0a3d0..6bc8fb14 100644 --- a/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt +++ b/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt @@ -1,9 +1,9 @@ package org.jetbrains.dokka.transformers.sources +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.model.DModule -import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.plugability.DokkaContext interface SourceToDocumentableTranslator { - fun invoke(sourceSet: SourceSetData, context: DokkaContext): DModule + fun invoke(sourceSet: DokkaSourceSet, context: DokkaContext): DModule }
\ No newline at end of file diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/EnvironmentAndFacade.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/EnvironmentAndFacade.kt index 9d15123a..a12becee 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/EnvironmentAndFacade.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/EnvironmentAndFacade.kt @@ -14,21 +14,21 @@ import java.io.File internal fun createEnvironmentAndFacade( logger: DokkaLogger, configuration: DokkaConfiguration, - pass: DokkaConfiguration.PassConfiguration + sourceSet: DokkaConfiguration.DokkaSourceSet ): EnvironmentAndFacade = - AnalysisEnvironment(DokkaMessageCollector(logger), pass.analysisPlatform).run { + AnalysisEnvironment(DokkaMessageCollector(logger), sourceSet.analysisPlatform).run { if (analysisPlatform == Platform.jvm) { addClasspath(PathUtil.getJdkClassesRootsFromCurrentJre()) } - pass.classpath.forEach { addClasspath(File(it)) } + sourceSet.classpath.forEach { addClasspath(File(it)) } addSources( - (pass.sourceRoots + configuration.passesConfigurations.filter { it.sourceSetID in pass.dependentSourceSets } + (sourceSet.sourceRoots + configuration.sourceSets.filter { it.sourceSetID in sourceSet.dependentSourceSets } .flatMap { it.sourceRoots }) .map { it.path } ) - loadLanguageVersionSettings(pass.languageVersion, pass.apiVersion) + loadLanguageVersionSettings(sourceSet.languageVersion, sourceSet.apiVersion) val environment = createCoreEnvironment() val (facade, _) = createResolutionFacade(environment) diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinAnalysis.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinAnalysis.kt index cd07b2a3..426ffdde 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinAnalysis.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinAnalysis.kt @@ -2,45 +2,37 @@ package org.jetbrains.dokka.analysis -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.model.SourceSetCache -import org.jetbrains.dokka.model.SourceSetData +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.model.SourceSetDependent import org.jetbrains.dokka.plugability.DokkaContext fun KotlinAnalysis(context: DokkaContext): KotlinAnalysis { - val environments = context.configuration.passesConfigurations - .associate { passConfiguration -> - context.sourceSetCache.getSourceSet(passConfiguration) to createEnvironmentAndFacade( + val environments = context.configuration.sourceSets + .associate { sourceSet -> + sourceSet to createEnvironmentAndFacade( logger = context.logger, configuration = context.configuration, - pass = passConfiguration + sourceSet = sourceSet ) } - return KotlinAnalysisImpl(context.sourceSetCache, environments) + return KotlinAnalysisImpl(environments) } interface KotlinAnalysis : SourceSetDependent<EnvironmentAndFacade> { - override fun get(key: SourceSetData): EnvironmentAndFacade + override fun get(key: DokkaSourceSet): EnvironmentAndFacade operator fun get(sourceSetID: String): EnvironmentAndFacade - operator fun get(passConfiguration: DokkaConfiguration.PassConfiguration): EnvironmentAndFacade } internal class KotlinAnalysisImpl( - private val sourceSetCache: SourceSetCache, private val environments: SourceSetDependent<EnvironmentAndFacade> ) : KotlinAnalysis, SourceSetDependent<EnvironmentAndFacade> by environments { - override fun get(key: SourceSetData): EnvironmentAndFacade { + override fun get(key: DokkaSourceSet): EnvironmentAndFacade { return environments[key] ?: throw IllegalStateException("Missing EnvironmentAndFacade for sourceSet $key") } override fun get(sourceSetID: String): EnvironmentAndFacade { return environments.entries.first { (sourceSet, _) -> sourceSet.sourceSetID == sourceSetID }.value } - - override fun get(passConfiguration: DokkaConfiguration.PassConfiguration): EnvironmentAndFacade { - return get(sourceSetCache.getSourceSet(passConfiguration)) - } } diff --git a/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt b/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt index cdaa0274..e3da9ecc 100644 --- a/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt +++ b/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt @@ -1,11 +1,11 @@ package org.jetbrains.dokka.base.allModulePage +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.resolvers.local.MultimoduleLocationProvider.Companion.MULTIMODULE_PACKAGE_PLACEHOLDER import org.jetbrains.dokka.base.transformers.pages.comments.DocTagToContentConverter import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.model.doc.P import org.jetbrains.dokka.pages.* @@ -30,9 +30,13 @@ class MultimodulePageCreator( if (commentsConverter == null || signatureProvider == null) throw IllegalStateException("Both comments converter and signature provider must not be null") - val sourceSetData = emptySet<SourceSetData>() + val sourceSetData = emptySet<DokkaSourceSet>() val builder = PageContentBuilder(commentsConverter, signatureProvider, context.logger) - val contentNode = builder.contentFor(dri = DRI(MULTIMODULE_PACKAGE_PLACEHOLDER), kind = ContentKind.Cover, sourceSets = sourceSetData) { + val contentNode = builder.contentFor( + dri = DRI(MULTIMODULE_PACKAGE_PLACEHOLDER), + kind = ContentKind.Cover, + sourceSets = sourceSetData + ) { header(2, "All modules:") table(styles = setOf(MultimoduleTable)) { modules.mapNotNull { module -> diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt index 141a18e6..f4d547e3 100644 --- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt @@ -1,10 +1,12 @@ package org.jetbrains.dokka.base.renderers -import kotlinx.coroutines.* -import kotlinx.html.FlowContent +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.resolvers.local.LocationProvider -import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin @@ -28,7 +30,7 @@ abstract class DefaultRenderer<T>( abstract fun T.buildList( node: ContentList, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? = null + sourceSetRestriction: Set<DokkaSourceSet>? = null ) abstract fun T.buildNewLine() @@ -36,7 +38,7 @@ abstract class DefaultRenderer<T>( abstract fun T.buildTable( node: ContentTable, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? = null + sourceSetRestriction: Set<DokkaSourceSet>? = null ) abstract fun T.buildText(textNode: ContentText) @@ -48,18 +50,18 @@ abstract class DefaultRenderer<T>( open fun T.buildPlatformDependent( content: PlatformHintedContent, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? + sourceSetRestriction: Set<DokkaSourceSet>? ) = buildContentNode(content.inner, pageContext) open fun T.buildGroup( node: ContentGroup, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? = null + sourceSetRestriction: Set<DokkaSourceSet>? = null ) = wrapGroup(node, pageContext) { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } } open fun T.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) = - node.children.forEach { it.build(this, pageContext) } + node.children.forEach { it.build(this, pageContext) } open fun T.wrapGroup(node: ContentGroup, pageContext: ContentPage, childrenCallback: T.() -> Unit) = childrenCallback() @@ -67,7 +69,7 @@ abstract class DefaultRenderer<T>( open fun T.buildLinkText( nodes: List<ContentNode>, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? = null + sourceSetRestriction: Set<DokkaSourceSet>? = null ) { nodes.forEach { it.build(this, pageContext, sourceSetRestriction) } } @@ -79,7 +81,7 @@ abstract class DefaultRenderer<T>( open fun T.buildHeader( node: ContentHeader, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? = null + sourceSetRestriction: Set<DokkaSourceSet>? = null ) { buildHeader(node.level, node) { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } } } @@ -87,16 +89,16 @@ abstract class DefaultRenderer<T>( open fun ContentNode.build( builder: T, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? = null + sourceSetRestriction: Set<DokkaSourceSet>? = null ) = builder.buildContentNode(this, pageContext, sourceSetRestriction) open fun T.buildContentNode( node: ContentNode, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? = null + sourceSetRestriction: Set<DokkaSourceSet>? = null ) { - if (sourceSetRestriction == null || node.sourceSets.any { it in sourceSetRestriction } ) { + if (sourceSetRestriction == null || node.sourceSets.any { it in sourceSetRestriction }) { when (node) { is ContentText -> buildText(node) is ContentHeader -> buildHeader(node, pageContext, sourceSetRestriction) diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 43722888..ee6f1e1f 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -1,13 +1,15 @@ package org.jetbrains.dokka.base.renderers.html -import kotlinx.coroutines.* +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking import kotlinx.html.* import kotlinx.html.stream.createHTML +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.Platform import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.DefaultRenderer import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext @@ -20,11 +22,10 @@ open class HtmlRenderer( context: DokkaContext ) : DefaultRenderer<FlowContent>(context) { - private val sourceSetDependencyMap = with(context.sourceSetCache) { - allSourceSets.map { sourceSet -> - sourceSet to allSourceSets.filter { sourceSet.dependentSourceSets.contains(it.sourceSetID) } - }.toMap() - } + private val sourceSetDependencyMap = context.configuration.sourceSets.map { sourceSet -> + sourceSet to context.configuration.sourceSets.filter { sourceSet.dependentSourceSets.contains(it.sourceSetID) } + }.toMap() + private val pageList = mutableMapOf<String, Pair<String, String>>() @@ -94,7 +95,7 @@ open class HtmlRenderer( button(classes = "platform-tag platform-selector") { attributes["data-active"] = "" attributes["data-filter"] = it.sourceSetID - when (it.platform.key) { + when (it.analysisPlatform.key) { "common" -> classes = classes + "common-like" "native" -> classes = classes + "native-like" "jvm" -> classes = classes + "jvm-like" @@ -138,7 +139,7 @@ open class HtmlRenderer( override fun FlowContent.buildPlatformDependent( content: PlatformHintedContent, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? + sourceSetRestriction: Set<DokkaSourceSet>? ) = buildPlatformDependent( content.sourceSets.filter { @@ -150,7 +151,7 @@ open class HtmlRenderer( ) private fun FlowContent.buildPlatformDependent( - nodes: Map<SourceSetData, Collection<ContentNode>>, + nodes: Map<DokkaSourceSet, Collection<ContentNode>>, pageContext: ContentPage, extra: PropertyContainer<ContentNode> = PropertyContainer.empty(), styles: Set<Style> = emptySet() @@ -172,7 +173,7 @@ open class HtmlRenderer( if (index == 0) attributes["data-active"] = "" attributes["data-toggle"] = pair.first.sourceSetID when ( - pair.first.platform.key + pair.first.analysisPlatform.key ) { "common" -> classes = classes + "common-like" "native" -> classes = classes + "native-like" @@ -192,9 +193,9 @@ open class HtmlRenderer( } private fun contentsForSourceSetDependent( - nodes: Map<SourceSetData, Collection<ContentNode>>, + nodes: Map<DokkaSourceSet, Collection<ContentNode>>, pageContext: ContentPage, - ): List<Pair<SourceSetData, String>> { + ): List<Pair<DokkaSourceSet, String>> { var counter = 0 return nodes.toList().map { (sourceSet, elements) -> sourceSet to createHTML(prettyPrint = false).div { @@ -203,8 +204,8 @@ open class HtmlRenderer( } }.stripDiv() }.groupBy( - Pair<SourceSetData, String>::second, - Pair<SourceSetData, String>::first + Pair<DokkaSourceSet, String>::second, + Pair<DokkaSourceSet, String>::first ).entries.flatMap { (html, sourceSets) -> sourceSets.filterNot { sourceSetDependencyMap[it].orEmpty().any { dependency -> sourceSets.contains(dependency) } @@ -238,8 +239,8 @@ open class HtmlRenderer( ) } }.groupBy( - Pair<Pair<ContentDivergentInstance, SourceSetData>, Pair<String, String>>::second, - Pair<Pair<ContentDivergentInstance, SourceSetData>, Pair<String, String>>::first + Pair<Pair<ContentDivergentInstance, DokkaSourceSet>, Pair<String, String>>::second, + Pair<Pair<ContentDivergentInstance, DokkaSourceSet>, Pair<String, String>>::first ) distinct.forEach { @@ -293,14 +294,14 @@ open class HtmlRenderer( override fun FlowContent.buildList( node: ContentList, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? + sourceSetRestriction: Set<DokkaSourceSet>? ) = if (node.ordered) ol { buildListItems(node.children, pageContext, sourceSetRestriction) } else ul { buildListItems(node.children, pageContext, sourceSetRestriction) } open fun OL.buildListItems( items: List<ContentNode>, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? = null + sourceSetRestriction: Set<DokkaSourceSet>? = null ) { items.forEach { if (it is ContentList) @@ -313,7 +314,7 @@ open class HtmlRenderer( open fun UL.buildListItems( items: List<ContentNode>, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? = null + sourceSetRestriction: Set<DokkaSourceSet>? = null ) { items.forEach { if (it is ContentList) @@ -340,7 +341,7 @@ open class HtmlRenderer( private fun FlowContent.buildRow( node: ContentGroup, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>?, + sourceSetRestriction: Set<DokkaSourceSet>?, style: Set<Style> ) { node.children @@ -393,11 +394,11 @@ open class HtmlRenderer( } } - private fun FlowContent.createPlatformTagBubbles(sourceSets: List<SourceSetData>) { + private fun FlowContent.createPlatformTagBubbles(sourceSets: List<DokkaSourceSet>) { div("platform-tags") { sourceSets.forEach { div("platform-tag") { - when (it.platform.key) { + when (it.analysisPlatform.key) { "common" -> classes = classes + "common-like" "native" -> classes = classes + "native-like" "jvm" -> classes = classes + "jvm-like" @@ -409,7 +410,7 @@ open class HtmlRenderer( } } - private fun FlowContent.createPlatformTags(node: ContentNode, sourceSetRestriction: Set<SourceSetData>? = null) { + private fun FlowContent.createPlatformTags(node: ContentNode, sourceSetRestriction: Set<DokkaSourceSet>? = null) { node.takeIf { sourceSetRestriction == null || it.sourceSets.any { s -> s in sourceSetRestriction } }?.let { createPlatformTagBubbles(node.sourceSets.filter { sourceSetRestriction == null || it in sourceSetRestriction @@ -420,7 +421,7 @@ open class HtmlRenderer( override fun FlowContent.buildTable( node: ContentTable, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? + sourceSetRestriction: Set<DokkaSourceSet>? ) { when (node.dci.kind) { ContentKind.Comment -> buildDefaultTable(node, pageContext, sourceSetRestriction) @@ -437,7 +438,7 @@ open class HtmlRenderer( fun FlowContent.buildDefaultTable( node: ContentTable, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? + sourceSetRestriction: Set<DokkaSourceSet>? ) { table { thead { @@ -522,7 +523,7 @@ open class HtmlRenderer( fun FlowContent.buildLink( to: DRI, - platforms: List<SourceSetData>, + platforms: List<DokkaSourceSet>, from: PageNode? = null, block: FlowContent.() -> Unit ) = buildLink(locationProvider.resolve(to, platforms, from), block) @@ -562,7 +563,7 @@ open class HtmlRenderer( private fun getSymbolSignature(page: ContentPage) = page.content.dfs { it.dci.kind == ContentKind.Symbol } private fun flattenToText(node: ContentNode): String { - fun getContentTextNodes(node: ContentNode, sourceSetRestriction: SourceSetData): List<ContentText> = + fun getContentTextNodes(node: ContentNode, sourceSetRestriction: DokkaSourceSet): List<ContentText> = when (node) { is ContentText -> listOf(node) is ContentComposite -> node.children @@ -573,7 +574,8 @@ open class HtmlRenderer( else -> emptyList() } - val sourceSetRestriction = node.sourceSets.find { it.platform == Platform.common } ?: node.sourceSets.first() + val sourceSetRestriction = + node.sourceSets.find { it.analysisPlatform == Platform.common } ?: node.sourceSets.first() return getContentTextNodes(node, sourceSetRestriction).joinToString("") { it.text } } diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt index 4048c11e..eb563dbd 100644 --- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt +++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt @@ -3,7 +3,7 @@ package org.jetbrains.dokka.base.renderers.html import kotlinx.html.* import kotlinx.html.stream.createHTML import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.SourceSetData +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.pages.PageNode import org.jetbrains.dokka.pages.RendererSpecificPage import org.jetbrains.dokka.pages.RenderingStrategy @@ -25,7 +25,7 @@ class NavigationPage(val root: NavigationNode) : RendererSpecificPage { id = navId attributes["pageId"] = node.dri.toString() div("overview") { - buildLink(node.dri, node.platforms) { +node.name } + buildLink(node.dri, node.sourceSets) { +node.name } if (node.children.isNotEmpty()) { span("navButton") { onClick = """document.getElementById("$navId").classList.toggle("hidden");""" @@ -41,11 +41,11 @@ class NavigationPage(val root: NavigationNode) : RendererSpecificPage { class NavigationNode( val name: String, val dri: DRI, - val platforms: List<SourceSetData>, + val sourceSets: List<DokkaSourceSet>, val children: List<NavigationNode> ) fun NavigationPage.transform(block: (NavigationNode) -> NavigationNode) = NavigationPage(root.transform(block)) fun NavigationNode.transform(block: (NavigationNode) -> NavigationNode) = - run(block).let { NavigationNode(it.name, it.dri, it.platforms, it.children.map(block)) } + run(block).let { NavigationNode(it.name, it.dri, it.sourceSets, it.children.map(block)) } diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index cdb30555..af0525d7 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -86,7 +86,7 @@ object StyleAndScriptsAppender : PageTransformer { class SourcesetDependencyAppender(val context: DokkaContext) : PageTransformer{ override fun invoke(input: RootPageNode): RootPageNode { - val dependenciesMap = context.configuration.passesConfigurations.map { + val dependenciesMap = context.configuration.sourceSets.map { it.sourceSetID to it.dependentSourceSets }.toMap() fun createDependenciesJson() : String = "sourceset_dependencies = '{${ diff --git a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt index a9e58f17..eada2e3b 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt @@ -1,16 +1,14 @@ package org.jetbrains.dokka.base.resolvers.local import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProvider import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.SourceSetData -import org.jetbrains.dokka.model.sourceSet import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.query -import java.lang.IllegalStateException import java.net.HttpURLConnection import java.net.URL import java.net.URLConnection @@ -48,14 +46,12 @@ open class DefaultLocationProvider( override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean): String = pathTo(node, context) + if (!skipExtension) extension else "" - override fun resolve(dri: DRI, sourceSets: List<SourceSetData>, context: PageNode?): String = + override fun resolve(dri: DRI, sourceSets: List<DokkaSourceSet>, context: PageNode?): String = pagesIndex[dri]?.let { resolve(it, context) } ?: // Not found in PageGraph, that means it's an external link - getLocation(dri, - this.dokkaContext.configuration.passesConfigurations - .filter { passConfig -> - sourceSets.toSet().contains(dokkaContext.sourceSet(passConfig)) - } + getLocation( + dri, + sourceSets .groupBy({ it.jdkVersion }, { it.externalDocumentationLinks }) .map { it.key to it.value.flatten().distinct() }.toMap() ) @@ -105,7 +101,7 @@ open class DefaultLocationProvider( // Not in cache, resolve packageLists for ((jdk, links) in toResolve) { for (link in links) { - if(dokkaContext.configuration.offlineMode && link.packageListUrl.protocol.toLowerCase() != "file") + if (dokkaContext.configuration.offlineMode && link.packageListUrl.protocol.toLowerCase() != "file") continue val locationInfo = loadPackageList(jdk, link.packageListUrl) diff --git a/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt index c6c48d63..d6d616f3 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt @@ -1,12 +1,12 @@ package org.jetbrains.dokka.base.resolvers.local import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.SourceSetData +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.pages.PageNode import org.jetbrains.dokka.pages.RootPageNode interface LocationProvider { - fun resolve(dri: DRI, sourceSets: List<SourceSetData>, context: PageNode? = null): String + fun resolve(dri: DRI, sourceSets: List<DokkaSourceSet>, context: PageNode? = null): String fun resolve(node: PageNode, context: PageNode? = null, skipExtension: Boolean = false): String fun resolveRoot(node: PageNode): String fun ancestors(node: PageNode): List<PageNode> diff --git a/plugins/base/src/main/kotlin/resolvers/local/MultimoduleLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/MultimoduleLocationProvider.kt index 21692bf9..39b005a1 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/MultimoduleLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/MultimoduleLocationProvider.kt @@ -1,7 +1,7 @@ package org.jetbrains.dokka.base.resolvers.local import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.SourceSetData +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.pages.PageNode import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext @@ -14,10 +14,10 @@ class MultimoduleLocationProvider(private val root: RootPageNode, context: Dokka it.name to it.path }.toMap() - override fun resolve(dri: DRI, platforms: List<SourceSetData>, context: PageNode?): String = + override fun resolve(dri: DRI, sourceSets: List<DokkaSourceSet>, context: PageNode?): String = dri.takeIf { it.packageName == MULTIMODULE_PACKAGE_PLACEHOLDER }?.classNames?.let { paths[it] }?.let { "$it/${dri.classNames}/index.html" - } ?: defaultLocationProvider.resolve(dri, platforms, context) + } ?: defaultLocationProvider.resolve(dri, sourceSets, context) override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean): String = defaultLocationProvider.resolve(node, context, skipExtension) diff --git a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt index 8dbe7b12..f042eae3 100644 --- a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt +++ b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt @@ -1,10 +1,12 @@ package org.jetbrains.dokka.base.signatures +import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.dokka.pages.* +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet interface JvmSignatureUtils { @@ -73,7 +75,7 @@ interface JvmSignatureUtils { is All -> All is Never, is OnlyOnce -> Never }.let { strategy -> - valueToSignature(it.value, strategy, listBrackets, classExtension) + valueToSignature(it.value, strategy, listBrackets, classExtension) } if (i != a.params.entries.size - 1) text(", ") } @@ -130,11 +132,11 @@ interface JvmSignatureUtils { } } - fun <T : Documentable> WithExtraProperties<T>.stylesIfDeprecated(sourceSetData: SourceSetData): Set<TextStyle> = + fun <T : Documentable> WithExtraProperties<T>.stylesIfDeprecated(sourceSetData: DokkaSourceSet): Set<TextStyle> = if (extra[Annotations]?.content?.get(sourceSetData)?.any { - it.dri == DRI("kotlin", "Deprecated") - || it.dri == DRI("java.lang", "Deprecated") - } == true) setOf(TextStyle.Strikethrough) else emptySet() + it.dri == DRI("kotlin", "Deprecated") + || it.dri == DRI("java.lang", "Deprecated") + } == true) setOf(TextStyle.Strikethrough) else emptySet() } sealed class AtStrategy diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index 3e92b902..28c26dea 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.base.signatures +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.Platform import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder @@ -24,7 +25,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog ExtraModifiers.KotlinOnlyModifiers.TailRec, ExtraModifiers.KotlinOnlyModifiers.External ) - private val platformSpecificModifiers : Map<ExtraModifiers, Set<Platform>> = mapOf( + private val platformSpecificModifiers: Map<ExtraModifiers, Set<Platform>> = mapOf( ExtraModifiers.KotlinOnlyModifiers.External to setOf(Platform.js) ) @@ -40,13 +41,14 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog ) } - private fun <T> PageContentBuilder.DocumentableContentBuilder.processExtraModifiers (t: T) - where T: Documentable, T: WithExtraProperties<T> { + private fun <T> PageContentBuilder.DocumentableContentBuilder.processExtraModifiers(t: T) + where T : Documentable, T : WithExtraProperties<T> { sourceSetDependentText( t.modifiers() .mapValues { entry -> entry.value.filter { - it !in ignoredExtraModifiers || entry.key.platform in (platformSpecificModifiers[it] ?: emptySet()) + it !in ignoredExtraModifiers || entry.key.analysisPlatform in (platformSpecificModifiers[it] + ?: emptySet()) } } ) { @@ -73,7 +75,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } } - private fun actualTypealiasedSignature(c: DClasslike, sourceSet: SourceSetData, aliasedType: Bound) = + private fun actualTypealiasedSignature(c: DClasslike, sourceSet: DokkaSourceSet, aliasedType: Bound) = contentBuilder.contentFor( c, ContentKind.Symbol, @@ -97,7 +99,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } - private fun regularSignature(c: DClasslike, sourceSet: SourceSetData) = + private fun regularSignature(c: DClasslike, sourceSet: DokkaSourceSet) = contentBuilder.contentFor( c, ContentKind.Symbol, @@ -315,7 +317,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog is UnresolvedBound -> text(p.name) } - private fun funType(dri: DRI, sourceSets: Set<SourceSetData>, type: TypeConstructor) = + private fun funType(dri: DRI, sourceSets: Set<DokkaSourceSet>, type: TypeConstructor) = contentBuilder.contentFor(dri, sourceSets, ContentKind.Main) { if (type.extension) { signatureForProjection(type.projections.first()) diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt index 27557107..109aa640 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt @@ -8,18 +8,16 @@ import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransf class DeprecatedDocumentableFilterTransformer(val context: DokkaContext) : PreMergeDocumentableTransformer { override fun invoke(modules: List<DModule>) = modules.map { original -> - val passOptions = context.configuration.passesConfigurations.first { - original.sourceSets.contains(context.sourceSet(it)) - } + val sourceSet = original.sourceSets.single() val packageOptions = - passOptions.perPackageOptions + sourceSet.perPackageOptions original.let { - DeprecatedDocumentableFilter(passOptions, packageOptions).processModule(it) + DeprecatedDocumentableFilter(sourceSet, packageOptions).processModule(it) } } private class DeprecatedDocumentableFilter( - val globalOptions: DokkaConfiguration.PassConfiguration, + val globalOptions: DokkaConfiguration.DokkaSourceSet, val packageOptions: List<DokkaConfiguration.PackageOptions> ) { diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt index 0a01680f..c3cc4d38 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt @@ -4,15 +4,13 @@ import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.model.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMergeDocumentableTransformer { override fun invoke(modules: List<DModule>) = modules.map { original -> - val passOptions = context.configuration.passesConfigurations.first { - original.sourceSets.contains(context.sourceSet(it)) - } - val packageOptions = - passOptions.perPackageOptions + val passOptions = original.sourceSets.single() + val packageOptions = passOptions.perPackageOptions original.let { DocumentableVisibilityFilter(packageOptions, passOptions).processModule(it) } @@ -20,7 +18,7 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe private class DocumentableVisibilityFilter( val packageOptions: List<DokkaConfiguration.PackageOptions>, - val globalOptions: DokkaConfiguration.PassConfiguration + val globalOptions: DokkaSourceSet ) { fun Visibility.isAllowedInPackage(packageName: String?) = when (this) { is JavaVisibility.Public, @@ -82,14 +80,14 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe return Pair(packagesListChanged, filteredPackages) } - private fun <T : WithVisibility> alwaysTrue(a: T, p: SourceSetData) = true - private fun <T : WithVisibility> alwaysFalse(a: T, p: SourceSetData) = false + private fun <T : WithVisibility> alwaysTrue(a: T, p: DokkaSourceSet) = true + private fun <T : WithVisibility> alwaysFalse(a: T, p: DokkaSourceSet) = false - private fun WithVisibility.visibilityForPlatform(data: SourceSetData): Visibility? = visibility[data] + private fun WithVisibility.visibilityForPlatform(data: DokkaSourceSet): Visibility? = visibility[data] private fun <T> T.filterPlatforms( - additionalCondition: (T, SourceSetData) -> Boolean = ::alwaysTrue, - alternativeCondition: (T, SourceSetData) -> Boolean = ::alwaysFalse + additionalCondition: (T, DokkaSourceSet) -> Boolean = ::alwaysTrue, + alternativeCondition: (T, DokkaSourceSet) -> Boolean = ::alwaysFalse ) where T : Documentable, T : WithVisibility = sourceSets.filter { d -> visibilityForPlatform(d)?.isAllowedInPackage(dri.packageName) == true && @@ -98,9 +96,9 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe }.toSet() private fun <T> List<T>.transform( - additionalCondition: (T, SourceSetData) -> Boolean = ::alwaysTrue, - alternativeCondition: (T, SourceSetData) -> Boolean = ::alwaysFalse, - recreate: (T, Set<SourceSetData>) -> T + additionalCondition: (T, DokkaSourceSet) -> Boolean = ::alwaysTrue, + alternativeCondition: (T, DokkaSourceSet) -> Boolean = ::alwaysFalse, + recreate: (T, Set<DokkaSourceSet>) -> T ): Pair<Boolean, List<T>> where T : Documentable, T : WithVisibility { var changed = false val values = mapNotNull { t -> @@ -122,7 +120,7 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe private fun filterFunctions( functions: List<DFunction>, - additionalCondition: (DFunction, SourceSetData) -> Boolean = ::alwaysTrue + additionalCondition: (DFunction, DokkaSourceSet) -> Boolean = ::alwaysTrue ) = functions.transform(additionalCondition) { original, filteredPlatforms -> with(original) { @@ -145,13 +143,13 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe } } - private fun hasVisibleAccessorsForPlatform(property: DProperty, data: SourceSetData) = + private fun hasVisibleAccessorsForPlatform(property: DProperty, data: DokkaSourceSet) = property.getter?.visibilityForPlatform(data)?.isAllowedInPackage(property.dri.packageName) == true || property.setter?.visibilityForPlatform(data)?.isAllowedInPackage(property.dri.packageName) == true private fun filterProperties( properties: List<DProperty>, - additionalCondition: (DProperty, SourceSetData) -> Boolean = ::alwaysTrue + additionalCondition: (DProperty, DokkaSourceSet) -> Boolean = ::alwaysTrue ): Pair<Boolean, List<DProperty>> = properties.transform(additionalCondition, ::hasVisibleAccessorsForPlatform) { original, filteredPlatforms -> with(original) { @@ -174,7 +172,7 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe } } - private fun filterEnumEntries(entries: List<DEnumEntry>, filteredPlatforms: Set<SourceSetData>) = + private fun filterEnumEntries(entries: List<DEnumEntry>, filteredPlatforms: Set<DokkaSourceSet>) = entries.mapNotNull { entry -> if (filteredPlatforms.containsAll(entry.sourceSets)) entry else { @@ -196,7 +194,7 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe private fun filterClasslikes( classlikeList: List<DClasslike>, - additionalCondition: (DClasslike, SourceSetData) -> Boolean = ::alwaysTrue + additionalCondition: (DClasslike, DokkaSourceSet) -> Boolean = ::alwaysTrue ): Pair<Boolean, List<DClasslike>> { var classlikesListChanged = false val filteredClasslikes: List<DClasslike> = classlikeList.mapNotNull { diff --git a/plugins/base/src/main/kotlin/transformers/documentables/EmptyPackagesFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/EmptyPackagesFilterTransformer.kt index 6b29531c..3fd0081a 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/EmptyPackagesFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/EmptyPackagesFilterTransformer.kt @@ -3,22 +3,18 @@ package org.jetbrains.dokka.base.transformers.documentables import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.model.DPackage -import org.jetbrains.dokka.model.sourceSet import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer class EmptyPackagesFilterTransformer(val context: DokkaContext) : PreMergeDocumentableTransformer { override fun invoke(modules: List<DModule>): List<DModule> = modules.map { original -> - val passOptions = context.configuration.passesConfigurations.first { - original.sourceSets.contains(context.sourceSet(it)) - } original.let { - EmptyPackagesFilter(passOptions).processModule(it) + EmptyPackagesFilter(original.sourceSets.single()).processModule(it) } } private class EmptyPackagesFilter( - val passOptions: DokkaConfiguration.PassConfiguration + val passOptions: DokkaConfiguration.DokkaSourceSet ) { fun DPackage.shouldBeSkipped() = passOptions.skipEmptyPackages && functions.isEmpty() && diff --git a/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt index 15ffc08a..f1bccd66 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt @@ -5,13 +5,14 @@ import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer class InheritorsExtractorTransformer : DocumentableTransformer { override fun invoke(original: DModule, context: DokkaContext): DModule = original.generateInheritanceMap().let { inheritanceMap -> original.appendInheritors(inheritanceMap) as DModule } - private fun <T : Documentable> T.appendInheritors(inheritanceMap: Map<SourceSetData, Map<DRI, List<DRI>>>): Documentable = + private fun <T : Documentable> T.appendInheritors(inheritanceMap: Map<DokkaSourceSet, Map<DRI, List<DRI>>>): Documentable = InheritorsInfo(inheritanceMap.getForDRI(dri)).let { info -> when (this) { is DModule -> copy(packages = packages.map { it.appendInheritors(inheritanceMap) as DPackage }) @@ -45,7 +46,7 @@ class InheritorsExtractorTransformer : DocumentableTransformer { private fun InheritorsInfo.isNotEmpty() = this.value.values.fold(0) { acc, list -> acc + list.size } > 0 - private fun Map<SourceSetData, Map<DRI, List<DRI>>>.getForDRI(dri: DRI) = + private fun Map<DokkaSourceSet, Map<DRI, List<DRI>>>.getForDRI(dri: DRI) = map { (v, k) -> v to k[dri] }.map { (k, v) -> k to v.orEmpty() }.toMap() @@ -57,7 +58,7 @@ class InheritorsExtractorTransformer : DocumentableTransformer { .groupBy({ it.first }) { it.second }.map { (k2, v2) -> k2 to v2.flatten() }.toMap() }.filter { it.second.values.isNotEmpty() }.toMap() - private fun <T : Documentable> T.getInheritanceEntriesRec(): List<Pair<SourceSetData, List<Pair<DRI, DRI>>>> = + private fun <T : Documentable> T.getInheritanceEntriesRec(): List<Pair<DokkaSourceSet, List<Pair<DRI, DRI>>>> = this.toInheritanceEntries() + children.flatMap { it.getInheritanceEntriesRec() } private fun <T : Documentable> T.toInheritanceEntries() = diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt index 63232793..1f718a7c 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt @@ -3,9 +3,8 @@ package org.jetbrains.dokka.base.transformers.documentables import org.jetbrains.dokka.analysis.EnvironmentAndFacade import org.jetbrains.dokka.analysis.KotlinAnalysis import org.jetbrains.dokka.model.DModule -import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.model.doc.DocumentationNode -import org.jetbrains.dokka.model.sourceSet +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.base.parsers.MarkdownParser import org.jetbrains.dokka.model.SourceSetDependent import org.jetbrains.dokka.plugability.DokkaContext @@ -23,9 +22,9 @@ internal class ModuleAndPackageDocumentationTransformer( override fun invoke(modules: List<DModule>): List<DModule> { val modulesAndPackagesDocumentation = - context.configuration.passesConfigurations + context.configuration.sourceSets .map { - Pair(it.moduleName, context.sourceSet(it)) to + Pair(it.moduleName, it) to it.includes.map { Paths.get(it) } .also { it.forEach { @@ -101,7 +100,7 @@ internal class ModuleAndPackageDocumentationTransformer( } } - private fun mergeDocumentation(origin: Map<SourceSetData, DocumentationNode>, new: Map<SourceSetData, DocumentationNode>) = + private fun mergeDocumentation(origin: Map<DokkaSourceSet, DocumentationNode>, new: Map<DokkaSourceSet, DocumentationNode>) = (origin.asSequence() + new.asSequence()) .distinct() .groupBy({ it.key }, { it.value }) diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt index 0b47345d..2ebd4c62 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt @@ -1,7 +1,7 @@ package org.jetbrains.dokka.base.transformers.documentables import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.DokkaConfiguration.PassConfiguration +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.analysis.DescriptorDocumentableSource import org.jetbrains.dokka.model.* import org.jetbrains.dokka.plugability.DokkaContext @@ -26,12 +26,11 @@ internal class ReportUndocumentedTransformer : DocumentableTransformer { } private fun shouldBeReportedIfNotDocumented( - documentable: Documentable, sourceSet: SourceSetData, context: DokkaContext + documentable: Documentable, sourceSet: DokkaSourceSet, context: DokkaContext ): Boolean { - val passConfiguration = passConfiguration(context, sourceSet) - val packageOptionsOrNull = packageOptionsOrNull(passConfiguration, documentable) + val packageOptionsOrNull = packageOptionsOrNull(sourceSet, documentable) - if (!(packageOptionsOrNull?.reportUndocumented ?: passConfiguration.reportUndocumented)) { + if (!(packageOptionsOrNull?.reportUndocumented ?: sourceSet.reportUndocumented)) { return false } @@ -61,7 +60,7 @@ internal class ReportUndocumentedTransformer : DocumentableTransformer { private fun reportIfUndocumented( context: DokkaContext, documentable: Documentable, - sourceSet: SourceSetData + sourceSet: DokkaSourceSet ) { if (isUndocumented(documentable, sourceSet)) { val documentableDescription = with(documentable) { @@ -94,14 +93,14 @@ internal class ReportUndocumentedTransformer : DocumentableTransformer { } } - private fun isUndocumented(documentable: Documentable, sourceSet: SourceSetData): Boolean { - fun resolveDependentSourceSets(sourceSet: SourceSetData): List<SourceSetData> { + private fun isUndocumented(documentable: Documentable, sourceSet: DokkaSourceSet): Boolean { + fun resolveDependentSourceSets(sourceSet: DokkaSourceSet): List<DokkaSourceSet> { return sourceSet.dependentSourceSets.mapNotNull { sourceSetID -> documentable.sourceSets.singleOrNull { it.sourceSetID == sourceSetID } } } - fun withAllDependentSourceSets(sourceSet: SourceSetData): Sequence<SourceSetData> { + fun withAllDependentSourceSets(sourceSet: DokkaSourceSet): Sequence<DokkaSourceSet> { return sequence { yield(sourceSet) for (dependentSourceSet in resolveDependentSourceSets(sourceSet)) { @@ -120,25 +119,16 @@ internal class ReportUndocumentedTransformer : DocumentableTransformer { return documentable.isConstructor } - private fun passConfiguration(context: DokkaContext, sourceSet: SourceSetData): PassConfiguration { - val passes = context.configuration.passesConfigurations.filter { configuration -> - configuration.sourceSetID == sourceSet.sourceSetID - } - if (passes.size > 1) - context.logger.error("Expected one passConfiguration with ID: ${sourceSet.sourceSetID} found: ${passes.size} in [${passes.joinToString { it.moduleName }}]") - return passes.first() - } - - private fun isFakeOverride(documentable: Documentable, sourceSet: SourceSetData): Boolean { + private fun isFakeOverride(documentable: Documentable, sourceSet: DokkaSourceSet): Boolean { return callableMemberDescriptorOrNull(documentable, sourceSet)?.kind == FAKE_OVERRIDE } - private fun isSynthesized(documentable: Documentable, sourceSet: SourceSetData): Boolean { + private fun isSynthesized(documentable: Documentable, sourceSet: DokkaSourceSet): Boolean { return callableMemberDescriptorOrNull(documentable, sourceSet)?.kind == SYNTHESIZED } private fun callableMemberDescriptorOrNull( - documentable: Documentable, sourceSet: SourceSetData + documentable: Documentable, sourceSet: DokkaSourceSet ): CallableMemberDescriptor? { if (documentable is WithExpectActual) { return documentable.sources[sourceSet] @@ -149,7 +139,7 @@ internal class ReportUndocumentedTransformer : DocumentableTransformer { return null } - private fun isPrivateOrInternalApi(documentable: Documentable, sourceSet: SourceSetData): Boolean { + private fun isPrivateOrInternalApi(documentable: Documentable, sourceSet: DokkaSourceSet): Boolean { return when (documentable.safeAs<WithVisibility>()?.visibility?.get(sourceSet)) { KotlinVisibility.Public -> false KotlinVisibility.Private -> true @@ -164,11 +154,11 @@ internal class ReportUndocumentedTransformer : DocumentableTransformer { } private fun packageOptionsOrNull( - passConfiguration: PassConfiguration, + dokkaSourceSet: DokkaSourceSet, documentable: Documentable ): DokkaConfiguration.PackageOptions? { val packageName = documentable.dri.packageName ?: return null - return passConfiguration.perPackageOptions + return dokkaSourceSet.perPackageOptions .filter { packageOptions -> packageName.startsWith(packageOptions.prefix) } .maxBy { packageOptions -> packageOptions.prefix.length } } diff --git a/plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt b/plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt index cb74441e..fa9ce37e 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt @@ -1,6 +1,6 @@ package org.jetbrains.dokka.base.transformers.pages.comments -import org.jetbrains.dokka.model.SourceSetData +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.model.doc.DocTag import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.pages.* @@ -9,7 +9,7 @@ interface CommentsToContentConverter { fun buildContent( docTag: DocTag, dci: DCI, - platforms: Set<SourceSetData>, + sourceSets: Set<DokkaSourceSet>, styles: Set<Style> = emptySet(), extras: PropertyContainer<ContentNode> = PropertyContainer.empty() ): List<ContentNode> diff --git a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt index be1217db..14f3a996 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt @@ -1,6 +1,6 @@ package org.jetbrains.dokka.base.transformers.pages.comments -import org.jetbrains.dokka.model.SourceSetData +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.model.doc.* import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.pages.* @@ -9,7 +9,7 @@ object DocTagToContentConverter : CommentsToContentConverter { override fun buildContent( docTag: DocTag, dci: DCI, - sourceSets: Set<SourceSetData>, + sourceSets: Set<DokkaSourceSet>, styles: Set<Style>, extra: PropertyContainer<ContentNode> ): List<ContentNode> { diff --git a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt index 0d133a65..a40f2f53 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt @@ -8,10 +8,9 @@ import org.jetbrains.dokka.analysis.DokkaResolutionFacade import org.jetbrains.dokka.analysis.EnvironmentAndFacade import org.jetbrains.dokka.base.renderers.platforms import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.SourceSetData +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.model.doc.Sample import org.jetbrains.dokka.model.properties.PropertyContainer -import org.jetbrains.dokka.model.sourceSet import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.pages.PageTransformer @@ -40,8 +39,8 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer { } } - private fun setUpAnalysis(context: DokkaContext) = context.configuration.passesConfigurations.map { - context.sourceSet(it) to AnalysisEnvironment(DokkaMessageCollector(context.logger), it.analysisPlatform).run { + private fun setUpAnalysis(context: DokkaContext) = context.configuration.sourceSets.map { + it to AnalysisEnvironment(DokkaMessageCollector(context.logger), it.analysisPlatform).run { if (analysisPlatform == Platform.jvm) { addClasspath(PathUtil.getJdkClassesRootsFromCurrentJre()) } @@ -59,9 +58,9 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer { private fun ContentNode.addSample( contentPage: ContentPage, - platform: SourceSetData, + platform: DokkaSourceSet, fqName: String, - analysis: Map<SourceSetData, EnvironmentAndFacade> + analysis: Map<DokkaSourceSet, EnvironmentAndFacade> ): ContentNode { val facade = analysis[platform]?.facade ?: return this.also { context.logger.warn("Cannot resolve facade for platform ${platform.moduleName}") } @@ -110,7 +109,7 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer { return DescriptorToSourceUtils.descriptorToDeclaration(symbol) } - private fun contentCode(sourceSets: List<SourceSetData>, dri: Set<DRI>, content: String, language: String) = + private fun contentCode(sourceSets: List<DokkaSourceSet>, dri: Set<DRI>, content: String, language: String) = ContentCode( children = listOf( ContentText( 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 7603c80b..42422934 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt @@ -3,11 +3,11 @@ package org.jetbrains.dokka.base.transformers.pages.sourcelinks import com.intellij.psi.PsiElement import com.intellij.psi.PsiDocumentManager import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.analysis.DescriptorDocumentableSource -import org.jetbrains.dokka.analysis.PsiDocumentableSource import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder -import org.jetbrains.dokka.model.SourceSetData 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.pages.* import org.jetbrains.dokka.plugability.DokkaContext @@ -29,8 +29,8 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent } } - private fun getSourceLinks() = context.configuration.passesConfigurations - .flatMap { it.sourceLinks.map { sl -> SourceLink(sl, context.sourceSetCache.getSourceSet(it)) } } + private fun getSourceLinks() = context.configuration.sourceSets + .flatMap { it.sourceLinks.map { sl -> SourceLink(sl, it) } } private fun resolveSources(documentable: WithExpectActual) = documentable.sources .mapNotNull { entry -> @@ -42,7 +42,7 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent } } - private fun ContentPage.addSourcesContent(sources: List<Pair<SourceSetData, String>>) = builder + private fun ContentPage.addSourcesContent(sources: List<Pair<DokkaSourceSet, String>>) = builder .buildSourcesContent(this, sources) .let { this.modified( @@ -52,7 +52,7 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent private fun PageContentBuilder.buildSourcesContent( node: ContentPage, - sources: List<Pair<SourceSetData, String>> + sources: List<Pair<DokkaSourceSet, String>> ) = contentFor( node.dri.first(), node.documentable!!.sourceSets.toSet() @@ -121,8 +121,8 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent } } -data class SourceLink(val path: String, val url: String, val lineSuffix: String?, val sourceSetData: SourceSetData) { - constructor(sourceLinkDefinition: DokkaConfiguration.SourceLinkDefinition, sourceSetData: SourceSetData) : this( +data class SourceLink(val path: String, val url: String, val lineSuffix: String?, val sourceSetData: DokkaSourceSet) { + constructor(sourceLinkDefinition: DokkaConfiguration.SourceLinkDefinition, sourceSetData: DokkaSourceSet) : this( sourceLinkDefinition.path, sourceLinkDefinition.url, sourceLinkDefinition.lineSuffix, sourceSetData ) } diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index cefea4ec..9cdd251c 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.base.translators.descriptors +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.analysis.* import org.jetbrains.dokka.links.* import org.jetbrains.dokka.links.Callable @@ -50,13 +51,12 @@ import org.jetbrains.kotlin.resolve.constants.AnnotationValue as ConstantsAnnota import org.jetbrains.kotlin.resolve.constants.ArrayValue as ConstantsArrayValue import org.jetbrains.kotlin.resolve.constants.EnumValue as ConstantsEnumValue import org.jetbrains.kotlin.resolve.constants.KClassValue as ConstantsKtClassValue -import kotlin.IllegalArgumentException class DefaultDescriptorToDocumentableTranslator( private val kotlinAnalysis: KotlinAnalysis ) : SourceToDocumentableTranslator { - override fun invoke(sourceSet: SourceSetData, context: DokkaContext): DModule { + override fun invoke(sourceSet: DokkaSourceSet, context: DokkaContext): DModule { val (environment, facade) = kotlinAnalysis[sourceSet] val packageFragments = environment.getSourceFiles().asSequence() .map { it.packageFqName } @@ -83,7 +83,7 @@ data class DRIWithPlatformInfo( fun DRI.withEmptyInfo() = DRIWithPlatformInfo(this, emptyMap()) private class DokkaDescriptorVisitor( - private val sourceSet: SourceSetData, + private val sourceSet: DokkaSourceSet, private val resolutionFacade: DokkaResolutionFacade, private val logger: DokkaLogger ) : DeclarationDescriptorVisitorEmptyBodies<Documentable, DRIWithPlatformInfo>() { @@ -729,11 +729,11 @@ private class DokkaDescriptorVisitor( private fun KtInitializerList.initializersAsText() = initializers.firstIsInstanceOrNull<KtCallElement>() - ?.getValueArgumentsInParentheses() - ?.flatMap { it.childrenAsText() } - .orEmpty() + ?.getValueArgumentsInParentheses() + ?.flatMap { it.childrenAsText() } + .orEmpty() - private fun ValueArgument.childrenAsText() = this.safeAs<KtValueArgument>()?.children?.map {it.text }.orEmpty() + private fun ValueArgument.childrenAsText() = this.safeAs<KtValueArgument>()?.children?.map { it.text }.orEmpty() private data class ClassInfo(val superclasses: List<DRI>, val interfaces: List<DRI>, val docs: SourceSetDependent<DocumentationNode>){ val supertypes: List<DRI> @@ -751,11 +751,12 @@ private class DokkaDescriptorVisitor( private fun ConstantsEnumValue.fullEnumEntryName() = "${this.enumClassId.relativeClassName.asString()}.${this.enumEntryName.identifier}" - private fun fallbackPackageName(): String = "[${sourceSet.displayName} root]"// TODO: error-prone, find a better way to do it + private fun fallbackPackageName(): String = + "[${sourceSet.displayName} root]"// TODO: error-prone, find a better way to do it } private fun DRI.withPackageFallbackTo(fallbackPackage: String): DRI { - return if(packageName.isNullOrBlank()){ + return if (packageName.isNullOrBlank()) { copy(packageName = fallbackPackage) } else { this diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 3fa950ed..c94b1814 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.base.translators.documentables +import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.documentables.InheritorsInfo import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter @@ -14,8 +15,9 @@ import org.jetbrains.dokka.utilities.DokkaLogger import org.jetbrains.kotlin.utils.addToStdlib.safeAs import kotlin.reflect.KClass import kotlin.reflect.full.isSubclassOf +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet -private typealias GroupedTags = Map<KClass<out TagWrapper>, List<Pair<SourceSetData?, TagWrapper>>> +private typealias GroupedTags = Map<KClass<out TagWrapper>, List<Pair<DokkaSourceSet?, TagWrapper>>> private val specialTags: Set<KClass<out TagWrapper>> = setOf(Property::class, Description::class, Constructor::class, Receiver::class, Param::class, See::class) @@ -71,8 +73,13 @@ open class DefaultPageCreator( protected open fun contentForModule(m: DModule) = contentBuilder.contentFor(m) { group(kind = ContentKind.Cover) { cover(m.name) - if(contentForDescription(m).isNotEmpty()){ - sourceSetDependentHint(m.dri, m.sourceSets.toSet(), kind = ContentKind.SourceSetDependantHint, styles = setOf(TextStyle.UnderCoverText)){ + if (contentForDescription(m).isNotEmpty()) { + sourceSetDependentHint( + m.dri, + m.sourceSets.toSet(), + kind = ContentKind.SourceSetDependantHint, + styles = setOf(TextStyle.UnderCoverText) + ) { +contentForDescription(m) } } @@ -88,13 +95,18 @@ open class DefaultPageCreator( protected open fun contentForPackage(p: DPackage) = contentBuilder.contentFor(p) { group(kind = ContentKind.Cover) { cover("Package ${p.name}") - if(contentForDescription(p).isNotEmpty()){ - sourceSetDependentHint(p.dri, p.sourceSets.toSet(), kind = ContentKind.SourceSetDependantHint, styles = setOf(TextStyle.UnderCoverText)){ + if (contentForDescription(p).isNotEmpty()) { + sourceSetDependentHint( + p.dri, + p.sourceSets.toSet(), + kind = ContentKind.SourceSetDependantHint, + styles = setOf(TextStyle.UnderCoverText) + ) { +contentForDescription(p) } } } - group(styles = setOf(ContentStyle.TabbedContent)){ + group(styles = setOf(ContentStyle.TabbedContent)) { +contentForComments(p) +contentForScope(p, p.dri, p.sourceSets) } @@ -103,15 +115,27 @@ open class DefaultPageCreator( protected open fun contentForScope( s: WithScope, dri: DRI, - sourceSets: Set<SourceSetData> + sourceSets: Set<DokkaSourceSet> ) = contentBuilder.contentFor(s as Documentable) { val types = listOf( s.classlikes, (s as? DPackage)?.typealiases ?: emptyList() ).flatten() divergentBlock("Types", types, ContentKind.Classlikes, extra = mainExtra + SimpleAttr.header("Types")) - divergentBlock("Functions", s.functions, ContentKind.Functions, extra = mainExtra + SimpleAttr.header( "Functions")) - block("Properties", 2, ContentKind.Properties, s.properties, sourceSets.toSet(), extra = mainExtra + SimpleAttr.header( "Properties")) { + divergentBlock( + "Functions", + s.functions, + ContentKind.Functions, + extra = mainExtra + SimpleAttr.header("Functions") + ) + block( + "Properties", + 2, + ContentKind.Properties, + s.properties, + sourceSets.toSet(), + extra = mainExtra + SimpleAttr.header("Properties") + ) { link(it.name, it.dri, kind = ContentKind.Main) sourceSetDependentHint(it.dri, it.sourceSets.toSet(), kind = ContentKind.SourceSetDependantHint) { contentForBrief(it) @@ -136,7 +160,7 @@ open class DefaultPageCreator( DCI(setOf(dri), ContentKind.Inheritors), sourceSets.toSet(), style = emptySet(), - extra = mainExtra + SimpleAttr.header( "Inheritors") + extra = mainExtra + SimpleAttr.header("Inheritors") ) } } @@ -150,7 +174,7 @@ open class DefaultPageCreator( +buildSignature(e) } } - group(styles = setOf(ContentStyle.TabbedContent)){ + group(styles = setOf(ContentStyle.TabbedContent)) { +contentForComments(e) +contentForScope(e, e.dri, e.sourceSets) } @@ -177,14 +201,28 @@ open class DefaultPageCreator( extra = PropertyContainer.empty<ContentNode>() + SimpleAttr.header("Constructors") ) { link(it.name, it.dri, kind = ContentKind.Main) - sourceSetDependentHint(it.dri, it.sourceSets.toSet(), kind = ContentKind.SourceSetDependantHint, styles = emptySet()) { + sourceSetDependentHint( + it.dri, + it.sourceSets.toSet(), + kind = ContentKind.SourceSetDependantHint, + styles = emptySet() + ) { contentForBrief(it) +buildSignature(it) } } } if (c is DEnum) { - block("Entries", 2, ContentKind.Classlikes, c.entries, c.sourceSets.toSet(), needsSorting = false, extra = mainExtra + SimpleAttr.header("Entries"), styles = emptySet()) { + block( + "Entries", + 2, + ContentKind.Classlikes, + c.entries, + c.sourceSets.toSet(), + needsSorting = false, + extra = mainExtra + SimpleAttr.header("Entries"), + styles = emptySet() + ) { link(it.name, it.dri) sourceSetDependentHint(it.dri, it.sourceSets.toSet(), kind = ContentKind.SourceSetDependantHint) { contentForBrief(it) @@ -198,11 +236,11 @@ open class DefaultPageCreator( @Suppress("UNCHECKED_CAST") private inline fun <reified T : TagWrapper> GroupedTags.withTypeUnnamed(): SourceSetDependent<T> = - (this[T::class] as List<Pair<SourceSetData, T>>?)?.toMap().orEmpty() + (this[T::class] as List<Pair<DokkaSourceSet, T>>?)?.toMap().orEmpty() @Suppress("UNCHECKED_CAST") private inline fun <reified T : NamedTagWrapper> GroupedTags.withTypeNamed(): Map<String, SourceSetDependent<T>> = - (this[T::class] as List<Pair<SourceSetData, T>>?) + (this[T::class] as List<Pair<DokkaSourceSet, T>>?) ?.groupBy { it.second.name } ?.mapValues { (_, v) -> v.toMap() } ?.toSortedMap(String.CASE_INSENSITIVE_ORDER) @@ -234,8 +272,8 @@ open class DefaultPageCreator( val unnamedTags: List<SourceSetDependent<TagWrapper>> = tags.filterNot { (k, _) -> k.isSubclassOf(NamedTagWrapper::class) || k in specialTags } - .map { (_, v) -> v.mapNotNull { (k,v) -> k?.let { it to v } }.toMap() } - if(unnamedTags.isNotEmpty()){ + .map { (_, v) -> v.mapNotNull { (k, v) -> k?.let { it to v } }.toMap() } + if (unnamedTags.isNotEmpty()) { platforms.forEach { platform -> unnamedTags.forEach { pdTag -> pdTag[platform]?.also { tag -> @@ -252,10 +290,10 @@ open class DefaultPageCreator( }.children } - private fun Documentable.getPossibleFallbackSourcesets(sourceSet: SourceSetData) = + private fun Documentable.getPossibleFallbackSourcesets(sourceSet: DokkaSourceSet) = this.sourceSets.filter { it.sourceSetID in sourceSet.dependentSourceSets } - private fun <V> Map<SourceSetData, V>.fallback(sourceSets: List<SourceSetData>) : V? = + private fun <V> Map<DokkaSourceSet, V>.fallback(sourceSets: List<DokkaSourceSet>): V? = sourceSets.firstOrNull { it in this.keys }.let { this[it] } protected open fun contentForComments( @@ -270,7 +308,10 @@ open class DefaultPageCreator( fun DocumentableContentBuilder.contentForParams() { if (tags.isNotEmptyForTag<Param>()) { header(2, "Parameters") - group(extra = mainExtra + SimpleAttr.header("Parameters"), styles = setOf(ContentStyle.WithExtraAttributes)){ + group( + extra = mainExtra + SimpleAttr.header("Parameters"), + styles = setOf(ContentStyle.WithExtraAttributes) + ) { sourceSetDependentHint(sourceSets = platforms.toSet(), kind = ContentKind.SourceSetDependantHint) { val receiver = tags.withTypeUnnamed<Receiver>() val params = tags.withTypeNamed<Param>() @@ -287,7 +328,11 @@ open class DefaultPageCreator( val paramRows = params.mapNotNull { (_, param) -> (param[platform] ?: param.fallback(possibleFallbacks))?.let { buildGroup(sourceSets = setOf(platform), kind = ContentKind.Parameters) { - text(it.name, kind = ContentKind.Parameters, styles = mainStyles + ContentStyle.RowTitle) + text( + it.name, + kind = ContentKind.Parameters, + styles = mainStyles + ContentStyle.RowTitle + ) comment(it.root) } } @@ -304,7 +349,10 @@ open class DefaultPageCreator( fun DocumentableContentBuilder.contentForSeeAlso() { if (tags.isNotEmptyForTag<See>()) { header(2, "See also") - group(extra = mainExtra + SimpleAttr.header("See also"), styles = setOf(ContentStyle.WithExtraAttributes)){ + group( + extra = mainExtra + SimpleAttr.header("See also"), + styles = setOf(ContentStyle.WithExtraAttributes) + ) { sourceSetDependentHint(sourceSets = platforms.toSet(), kind = ContentKind.SourceSetDependantHint) { val seeAlsoTags = tags.withTypeNamed<See>() table(kind = ContentKind.Sample) { @@ -312,8 +360,16 @@ open class DefaultPageCreator( val possibleFallbacks = d.getPossibleFallbackSourcesets(platform) seeAlsoTags.mapNotNull { (_, see) -> (see[platform] ?: see.fallback(possibleFallbacks))?.let { - buildGroup(sourceSets = setOf(platform), kind = ContentKind.Comment, styles = mainStyles + ContentStyle.RowTitle) { - if (it.address != null) link(it.name, it.address!!, kind = ContentKind.Comment) + buildGroup( + sourceSets = setOf(platform), + kind = ContentKind.Comment, + styles = mainStyles + ContentStyle.RowTitle + ) { + if (it.address != null) link( + it.name, + it.address!!, + kind = ContentKind.Comment + ) else text(it.name, kind = ContentKind.Comment) comment(it.root) } @@ -330,11 +386,18 @@ open class DefaultPageCreator( val samples = tags.withTypeNamed<Sample>() if (samples.isNotEmpty()) { header(2, "Samples") - group(extra = mainExtra + SimpleAttr.header("Samples"), styles = setOf(ContentStyle.WithExtraAttributes)){ + group( + extra = mainExtra + SimpleAttr.header("Samples"), + styles = setOf(ContentStyle.WithExtraAttributes) + ) { sourceSetDependentHint(sourceSets = platforms.toSet(), kind = ContentKind.SourceSetDependantHint) { platforms.map { platformData -> val content = samples.filter { it.value.isEmpty() || platformData in it.value } - group(sourceSets = setOf(platformData), kind = ContentKind.Sample, styles = setOf(TextStyle.Monospace)) { + group( + sourceSets = setOf(platformData), + kind = ContentKind.Sample, + styles = setOf(TextStyle.Monospace) + ) { content.forEach { text(it.key) } @@ -413,29 +476,33 @@ open class DefaultPageCreator( .mapValues { if (it.value.any { it is DClasslike }) it.value.filter { it !is DTypeAlias } else it.value } .toSortedMap(compareBy(nullsLast(String.CASE_INSENSITIVE_ORDER)){it}) .map { (elementName, elements) -> // This groupBy should probably use LocationProvider - buildGroup(elements.map { it.dri }.toSet(), elements.flatMap { it.sourceSets }.toSet(), kind = kind) { - link(elementName.orEmpty(), elements.first().dri, kind = kind) - divergentGroup( - ContentDivergentGroup.GroupID(name), + buildGroup( elements.map { it.dri }.toSet(), + elements.flatMap { it.sourceSets }.toSet(), kind = kind ) { - elements.map { - instance(setOf(it.dri), it.sourceSets.toSet()) { - before { - contentForBrief(it) - contentForSinceKotlin(it) - } - divergent { - group { - +buildSignature(it) + link(elementName.orEmpty(), elements.first().dri, kind = kind) + divergentGroup( + ContentDivergentGroup.GroupID(name), + elements.map { it.dri }.toSet(), + kind = kind + ) { + elements.map { + instance(setOf(it.dri), it.sourceSets.toSet()) { + before { + contentForBrief(it) + contentForSinceKotlin(it) + } + divergent { + group { + +buildSignature(it) + } } } } } } } - } } } } diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt index 9d10620e..a58ef114 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt @@ -1,9 +1,11 @@ package org.jetbrains.dokka.base.translators.documentables +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.* +import org.jetbrains.dokka.model.Documentable +import org.jetbrains.dokka.model.SourceSetDependent import org.jetbrains.dokka.model.doc.DocTag import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.pages.* @@ -19,7 +21,7 @@ open class PageContentBuilder( ) { fun contentFor( dri: DRI, - sourceSets: Set<SourceSetData>, + sourceSets: Set<DokkaSourceSet>, kind: Kind = ContentKind.Main, styles: Set<Style> = emptySet(), extra: PropertyContainer<ContentNode> = PropertyContainer.empty(), @@ -31,7 +33,7 @@ open class PageContentBuilder( fun contentFor( dri: Set<DRI>, - sourceSets: Set<SourceSetData>, + sourceSets: Set<DokkaSourceSet>, kind: Kind = ContentKind.Main, styles: Set<Style> = emptySet(), extra: PropertyContainer<ContentNode> = PropertyContainer.empty(), @@ -46,7 +48,7 @@ open class PageContentBuilder( kind: Kind = ContentKind.Main, styles: Set<Style> = emptySet(), extra: PropertyContainer<ContentNode> = PropertyContainer.empty(), - sourceSets: Set<SourceSetData> = d.sourceSets.toSet(), + sourceSets: Set<DokkaSourceSet> = d.sourceSets.toSet(), block: DocumentableContentBuilder.() -> Unit = {} ): ContentGroup = DocumentableContentBuilder(setOf(d.dri), sourceSets, styles, extra) @@ -56,14 +58,14 @@ open class PageContentBuilder( @ContentBuilderMarker open inner class DocumentableContentBuilder( val mainDRI: Set<DRI>, - val mainPlatformData: Set<SourceSetData>, + val mainPlatformData: Set<DokkaSourceSet>, val mainStyles: Set<Style>, val mainExtra: PropertyContainer<ContentNode> ) { protected val contents = mutableListOf<ContentNode>() fun build( - sourceSets: Set<SourceSetData>, + sourceSets: Set<DokkaSourceSet>, kind: Kind, styles: Set<Style>, extra: PropertyContainer<ContentNode> @@ -87,7 +89,7 @@ open class PageContentBuilder( level: Int, text: String, kind: Kind = ContentKind.Main, - platformData: Set<SourceSetData> = mainPlatformData, + platformData: Set<DokkaSourceSet> = mainPlatformData, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra, block: DocumentableContentBuilder.() -> Unit = {} @@ -109,18 +111,18 @@ open class PageContentBuilder( fun cover( text: String, - platformData: Set<SourceSetData> = mainPlatformData, + platformData: Set<DokkaSourceSet> = mainPlatformData, styles: Set<Style> = mainStyles + TextStyle.Cover, extra: PropertyContainer<ContentNode> = mainExtra, block: DocumentableContentBuilder.() -> Unit = {} - ) { + ) { header(1, text, platformData = platformData, styles = styles, extra = extra, block = block) } fun text( text: String, kind: Kind = ContentKind.Main, - sourceSets: Set<SourceSetData> = mainPlatformData, + sourceSets: Set<DokkaSourceSet> = mainPlatformData, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra ) { @@ -132,7 +134,7 @@ open class PageContentBuilder( fun linkTable( elements: List<DRI>, kind: Kind = ContentKind.Main, - sourceSets: Set<SourceSetData> = mainPlatformData, + sourceSets: Set<DokkaSourceSet> = mainPlatformData, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra ) { @@ -150,7 +152,7 @@ open class PageContentBuilder( fun table( kind: Kind = ContentKind.Main, - sourceSets: Set<SourceSetData> = mainPlatformData, + sourceSets: Set<DokkaSourceSet> = mainPlatformData, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra, operation: DocumentableContentBuilder.() -> List<ContentGroup> @@ -168,7 +170,7 @@ open class PageContentBuilder( level: Int, kind: Kind = ContentKind.Main, elements: Iterable<T>, - sourceSets: Set<SourceSetData> = mainPlatformData, + sourceSets: Set<DokkaSourceSet> = mainPlatformData, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra, renderWhenEmpty: Boolean = false, @@ -180,16 +182,16 @@ open class PageContentBuilder( contents += ContentTable( emptyList(), elements - .let{ + .let { if (needsSorting) - it.sortedWith(compareBy(nullsLast(String.CASE_INSENSITIVE_ORDER)){ it.name }) + it.sortedWith(compareBy(nullsLast(String.CASE_INSENSITIVE_ORDER)) { it.name }) else it } .map { - buildGroup(setOf(it.dri), it.sourceSets.toSet(), kind, styles, extra) { - operation(it) - } - }, + buildGroup(setOf(it.dri), it.sourceSets.toSet(), kind, styles, extra) { + operation(it) + } + }, DCI(mainDRI, kind), sourceSets, styles, extra ) @@ -201,7 +203,7 @@ open class PageContentBuilder( prefix: String = "", suffix: String = "", separator: String = ", ", - sourceSets: Set<SourceSetData> = mainPlatformData, // TODO: children should be aware of this platform data + sourceSets: Set<DokkaSourceSet> = mainPlatformData, // TODO: children should be aware of this platform data operation: DocumentableContentBuilder.(T) -> Unit ) { if (elements.isNotEmpty()) { @@ -219,7 +221,7 @@ open class PageContentBuilder( text: String, address: DRI, kind: Kind = ContentKind.Main, - sourceSets: Set<SourceSetData> = mainPlatformData, + sourceSets: Set<DokkaSourceSet> = mainPlatformData, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra ) { @@ -230,7 +232,7 @@ open class PageContentBuilder( text: String, address: DRI, kind: Kind = ContentKind.Main, - sourceSets: Set<SourceSetData> = mainPlatformData, + sourceSets: Set<DokkaSourceSet> = mainPlatformData, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra ) = ContentDRILink( @@ -244,7 +246,7 @@ open class PageContentBuilder( text: String, address: String, kind: Kind = ContentKind.Main, - sourceSets: Set<SourceSetData> = mainPlatformData, + sourceSets: Set<DokkaSourceSet> = mainPlatformData, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra ) = @@ -260,7 +262,7 @@ open class PageContentBuilder( fun link( address: DRI, kind: Kind = ContentKind.Main, - sourceSets: Set<SourceSetData> = mainPlatformData, + sourceSets: Set<DokkaSourceSet> = mainPlatformData, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra, block: DocumentableContentBuilder.() -> Unit @@ -276,7 +278,7 @@ open class PageContentBuilder( fun comment( docTag: DocTag, kind: Kind = ContentKind.Comment, - sourceSets: Set<SourceSetData> = mainPlatformData, + sourceSets: Set<DokkaSourceSet> = mainPlatformData, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra ) { @@ -290,7 +292,7 @@ open class PageContentBuilder( fun group( dri: Set<DRI> = mainDRI, - sourceSets: Set<SourceSetData> = mainPlatformData, + sourceSets: Set<DokkaSourceSet> = mainPlatformData, kind: Kind = ContentKind.Main, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra, @@ -316,7 +318,7 @@ open class PageContentBuilder( fun buildGroup( dri: Set<DRI> = mainDRI, - sourceSets: Set<SourceSetData> = mainPlatformData, + sourceSets: Set<DokkaSourceSet> = mainPlatformData, kind: Kind = ContentKind.Main, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra, @@ -325,7 +327,7 @@ open class PageContentBuilder( fun sourceSetDependentHint( dri: Set<DRI> = mainDRI, - sourceSets: Set<SourceSetData> = mainPlatformData, + sourceSets: Set<DokkaSourceSet> = mainPlatformData, kind: Kind = ContentKind.Main, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra, @@ -339,7 +341,7 @@ open class PageContentBuilder( fun sourceSetDependentHint( dri: DRI, - platformData: Set<SourceSetData> = mainPlatformData, + platformData: Set<DokkaSourceSet> = mainPlatformData, kind: Kind = ContentKind.Main, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra, @@ -354,7 +356,7 @@ open class PageContentBuilder( protected fun createText( text: String, kind: Kind, - sourceSets: Set<SourceSetData>, + sourceSets: Set<DokkaSourceSet>, styles: Set<Style>, extra: PropertyContainer<ContentNode> ) = @@ -362,7 +364,7 @@ open class PageContentBuilder( fun <T> sourceSetDependentText( value: SourceSetDependent<T>, - sourceSets: Set<SourceSetData> = value.keys, + sourceSets: Set<DokkaSourceSet> = value.keys, transform: (T) -> String ) = value.entries.filter { it.key in sourceSets }.mapNotNull { (p, v) -> transform(v).takeIf { it.isNotBlank() }?.let { it to p } @@ -381,7 +383,7 @@ open class PageContentBuilder( private val instances: MutableList<ContentDivergentInstance> = mutableListOf() fun instance( dri: Set<DRI>, - sourceSets: Set<SourceSetData>, // Having correct PlatformData is crucial here, that's why there's no default + sourceSets: Set<DokkaSourceSet>, // Having correct PlatformData is crucial here, that's why there's no default kind: Kind = mainKind, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra, @@ -411,7 +413,7 @@ open class PageContentBuilder( @ContentBuilderMarker open inner class DivergentInstanceBuilder( private val mainDRI: Set<DRI>, - private val mainSourceSets: Set<SourceSetData>, + private val mainSourceSets: Set<DokkaSourceSet>, private val mainStyles: Set<Style>, private val mainExtra: PropertyContainer<ContentNode> ) { @@ -421,7 +423,7 @@ open class PageContentBuilder( fun before( dri: Set<DRI> = mainDRI, - sourceSets: Set<SourceSetData> = mainSourceSets, + sourceSets: Set<DokkaSourceSet> = mainSourceSets, kind: Kind = ContentKind.Main, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra, @@ -434,7 +436,7 @@ open class PageContentBuilder( fun divergent( dri: Set<DRI> = mainDRI, - sourceSets: Set<SourceSetData> = mainSourceSets, + sourceSets: Set<DokkaSourceSet> = mainSourceSets, kind: Kind = ContentKind.Main, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra, @@ -445,7 +447,7 @@ open class PageContentBuilder( fun after( dri: Set<DRI> = mainDRI, - sourceSets: Set<SourceSetData> = mainSourceSets, + sourceSets: Set<DokkaSourceSet> = mainSourceSets, kind: Kind = ContentKind.Main, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra, @@ -459,7 +461,7 @@ open class PageContentBuilder( fun build( kind: Kind, - sourceSets: Set<SourceSetData> = mainSourceSets, + sourceSets: Set<DokkaSourceSet> = mainSourceSets, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra ) = diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index e71d936a..8588534b 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -7,10 +7,10 @@ import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.psi.* import com.intellij.psi.impl.source.PsiClassReferenceType import com.intellij.psi.impl.source.PsiImmediateClassType +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.analysis.KotlinAnalysis import org.jetbrains.dokka.analysis.PsiDocumentableSource import org.jetbrains.dokka.analysis.from -import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.nextTarget import org.jetbrains.dokka.links.withClass @@ -21,7 +21,6 @@ import org.jetbrains.dokka.model.doc.Param import org.jetbrains.dokka.model.doc.Text import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator import org.jetbrains.dokka.utilities.DokkaLogger import org.jetbrains.kotlin.asJava.elements.KtLightAbstractAnnotation @@ -42,7 +41,7 @@ class DefaultPsiToDocumentableTranslator( private val kotlinAnalysis: KotlinAnalysis ) : SourceToDocumentableTranslator { - override fun invoke(sourceSet: SourceSetData, context: DokkaContext): DModule { + override fun invoke(sourceSet: DokkaSourceSet, context: DokkaContext): DModule { fun isFileInSourceRoots(file: File): Boolean { return sourceSet.sourceRoots.any { root -> file.path.startsWith(File(root.path).absolutePath) } @@ -93,7 +92,7 @@ class DefaultPsiToDocumentableTranslator( } class DokkaPsiParser( - private val sourceSetData: SourceSetData, + private val sourceSetData: DokkaSourceSet, private val logger: DokkaLogger ) { @@ -187,7 +186,7 @@ class DefaultPsiToDocumentableTranslator( fields.filterIsInstance<PsiEnumConstant>().map { entry -> DEnumEntry( dri.withClass("$name.${entry.name}"), - entry.name.orEmpty(), + entry.name, javadocParser.parseDocumentation(entry).toSourceSetDependent(), null, emptyList(), diff --git a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt index f66f88db..2e05d241 100644 --- a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt +++ b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt @@ -3,8 +3,6 @@ package content.params import matchers.content.* import org.jetbrains.dokka.Platform import org.jetbrains.dokka.model.DFunction -import org.jetbrains.dokka.model.Documentable -import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.model.doc.Param import org.jetbrains.dokka.model.doc.Text @@ -570,7 +568,7 @@ class ContentForParamsTest : AbstractCoreTest() { } @Test - fun javaDocCommentWithDocumentedParameters(){ + fun javaDocCommentWithDocumentedParameters() { testInline( """ |/src/main/java/test/Main.java @@ -587,14 +585,14 @@ class ContentForParamsTest : AbstractCoreTest() { | } | } """.trimIndent(), testConfiguration - ){ - pagesTransformationStage = { - module -> + ) { + pagesTransformationStage = { module -> val sampleFunction = module.dfs { - it is MemberPageNode && it.dri.first().toString() == "test/Main/sample/#java.lang.String#java.lang.String/PointingToDeclaration/" + it is MemberPageNode && it.dri.first() + .toString() == "test/Main/sample/#java.lang.String#java.lang.String/PointingToDeclaration/" } as MemberPageNode val forJvm = (sampleFunction.documentable as DFunction).parameters.mapNotNull { - val jvm = it.documentation.keys.first { it.platform == Platform.jvm } + val jvm = it.documentation.keys.first { it.analysisPlatform == Platform.jvm } it.documentation[jvm] } diff --git a/plugins/base/src/test/kotlin/model/InheritorsTest.kt b/plugins/base/src/test/kotlin/model/InheritorsTest.kt index 5daebb73..f5517abb 100644 --- a/plugins/base/src/test/kotlin/model/InheritorsTest.kt +++ b/plugins/base/src/test/kotlin/model/InheritorsTest.kt @@ -31,7 +31,7 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", ) { with((this / "inheritors" / "A").cast<DInterface>()) { val map = extra[InheritorsInfo].assertNotNull("InheritorsInfo").value - with(map.keys.also { it counts 1 }.find { it.platform == Platform.jvm }.assertNotNull("jvm key").let { map[it]!! } + with(map.keys.also { it counts 1 }.find { it.analysisPlatform == Platform.jvm }.assertNotNull("jvm key").let { map[it]!! } ) { this counts 1 first().classNames equals "B" @@ -77,11 +77,11 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", with((m / "inheritors" / "A").cast<DInterface>()) { val map = extra[InheritorsInfo].assertNotNull("InheritorsInfo").value with(map.keys.also { it counts 2 }) { - with(find { it.platform == Platform.jvm }.assertNotNull("jvm key").let { map[it]!! }) { + with(find { it.analysisPlatform == Platform.jvm }.assertNotNull("jvm key").let { map[it]!! }) { this counts 1 first().classNames equals "B" } - with(find { it.platform == Platform.js }.assertNotNull("js key").let { map[it]!! }) { + with(find { it.analysisPlatform == Platform.js }.assertNotNull("js key").let { map[it]!! }) { this counts 2 val classes = listOf("B", "C") assertTrue(all { classes.contains(it.classNames) }, "One of subclasses missing in js" ) diff --git a/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt b/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt index 452439e9..21a70802 100644 --- a/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt +++ b/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt @@ -1,21 +1,17 @@ package renderers +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.DokkaConfigurationImpl import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.RootCreator import org.jetbrains.dokka.base.resolvers.external.DokkaExternalLocationProviderFactory import org.jetbrains.dokka.base.resolvers.external.JavadocExternalLocationProviderFactory import org.jetbrains.dokka.base.resolvers.local.DefaultLocationProviderFactory -import org.jetbrains.dokka.base.resolvers.local.LocationProvider -import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory import org.jetbrains.dokka.base.signatures.KotlinSignatureProvider import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter -import org.jetbrains.dokka.base.transformers.pages.samples.DefaultSamplesTransformer import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.Documentable -import org.jetbrains.dokka.model.SourceSetCache -import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.model.doc.DocTag import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.pages.* @@ -35,7 +31,6 @@ abstract class RenderingOnlyTestBase { DokkaBase().htmlPreprocessors to { _ -> RootCreator }, DokkaBase().externalLocationProviderFactory to { ::JavadocExternalLocationProviderFactory }, DokkaBase().externalLocationProviderFactory to { ::DokkaExternalLocationProviderFactory }, - sourceSetCache = SourceSetCache(), testConfiguration = DokkaConfigurationImpl( "", "", null, false, emptyList(), emptyList(), emptyMap(), emptyList(), false ) @@ -110,7 +105,7 @@ internal object EmptyCommentConverter : CommentsToContentConverter { override fun buildContent( docTag: DocTag, dci: DCI, - sourceSets: Set<SourceSetData>, + sourceSets: Set<DokkaSourceSet>, styles: Set<Style>, extras: PropertyContainer<ContentNode> ): List<ContentNode> = emptyList() diff --git a/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt b/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt index b10202bb..6ceb805b 100644 --- a/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt +++ b/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt @@ -4,15 +4,33 @@ import org.jetbrains.dokka.Platform import org.jetbrains.dokka.SourceRootImpl import org.jetbrains.dokka.base.renderers.html.HtmlRenderer import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.pages.ContentDivergentGroup import org.junit.jupiter.api.Test import renderers.* class DivergentTest : RenderingOnlyTestBase() { - private val js = SourceSetData("root", "js", "JS", Platform.js, listOf(SourceRootImpl("pl1"))) - private val jvm = SourceSetData("root", "jvm", "JVM", Platform.jvm, listOf(SourceRootImpl("pl1"))) - private val native = SourceSetData("root", "native", "NATIVE", Platform.native, listOf(SourceRootImpl("pl1"))) + private val js = defaultSourceSet.copy( + "root", + "JS", + "js", + analysisPlatform = Platform.js, + sourceRoots = listOf(SourceRootImpl("pl1")) + ) + private val jvm = defaultSourceSet.copy( + "root", + "JVM", + "jvm", + + analysisPlatform = Platform.jvm, + sourceRoots = listOf(SourceRootImpl("pl1")) + ) + private val native = defaultSourceSet.copy( + "root", + "NATIVE", + "native", + analysisPlatform = Platform.native, + sourceRoots = listOf(SourceRootImpl("pl1")) + ) @Test fun simpleWrappingCase() { @@ -178,10 +196,10 @@ class DivergentTest : RenderingOnlyTestBase() { HtmlRenderer(context).render(page) renderedContent.match( - Div(Div(Span(Div(Div("NATIVE")))), Div(Div(Div("a"))),"a+"), - Div(Div(Span(Div(Div("JS")))), Div(Div(Div("bd"))),"bd+"), + Div(Div(Span(Div(Div("NATIVE")))), Div(Div(Div("a"))), "a+"), + Div(Div(Span(Div(Div("JS")))), Div(Div(Div("bd"))), "bd+"), Div(Div(Span(Div(Div("JVM")))), Div(Div(Div("c")))), - Div(Div(Span(Div(Div("NATIVE")))), Div(Div(Div("e"))),"e+"), + Div(Div(Span(Div(Div("NATIVE")))), Div(Div(Div("e"))), "e+"), ) } diff --git a/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt b/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt index 878f442b..c868cfd5 100644 --- a/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt +++ b/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt @@ -3,7 +3,6 @@ package renderers.html import org.jetbrains.dokka.Platform import org.jetbrains.dokka.SourceRootImpl import org.jetbrains.dokka.base.renderers.html.HtmlRenderer -import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.pages.TextStyle import org.junit.jupiter.api.Test import renderers.Div @@ -12,9 +11,28 @@ import renderers.TestPage import renderers.match class SourceSetDependentHintTest : RenderingOnlyTestBase() { - private val pl1 = SourceSetData("root", "pl1", "pl3",Platform.js, listOf(SourceRootImpl("pl1"))) - private val pl2 = SourceSetData("root","pl2", "pl3", Platform.jvm, listOf(SourceRootImpl("pl1"))) - private val pl3 = SourceSetData("root","pl3", "pl3", Platform.native, listOf(SourceRootImpl("pl1"))) + + private val pl1 = defaultSourceSet.copy( + "root", + "pl1", + "pl1", + analysisPlatform = Platform.js, + sourceRoots = listOf(SourceRootImpl("pl1")) + ) + private val pl2 = defaultSourceSet.copy( + "root", + "pl2", + "pl2", + analysisPlatform = Platform.jvm, + sourceRoots = listOf(SourceRootImpl("pl1")) + ) + private val pl3 = defaultSourceSet.copy( + "root", + "pl3", + "pl3", + analysisPlatform = Platform.native, + sourceRoots = listOf(SourceRootImpl("pl1")) + ) @Test fun platformIndependentCase() { diff --git a/plugins/base/src/test/kotlin/renderers/html/defaultSourceSet.kt b/plugins/base/src/test/kotlin/renderers/html/defaultSourceSet.kt new file mode 100644 index 00000000..771cabaa --- /dev/null +++ b/plugins/base/src/test/kotlin/renderers/html/defaultSourceSet.kt @@ -0,0 +1,30 @@ +package renderers.html + +import org.jetbrains.dokka.DokkaSourceSetImpl +import org.jetbrains.dokka.Platform + +internal val defaultSourceSet = DokkaSourceSetImpl( + moduleName = "DEFAULT", + displayName = "DEFAULT", + sourceSetID = "DEFAULT", + classpath = emptyList(), + sourceRoots = emptyList(), + dependentSourceSets = emptyList(), + samples = emptyList(), + includes = emptyList(), + includeNonPublic = false, + includeRootPackage = false, + reportUndocumented = false, + skipEmptyPackages = true, + skipDeprecated = false, + jdkVersion = 8, + sourceLinks = emptyList(), + perPackageOptions = emptyList(), + externalDocumentationLinks = emptyList(), + languageVersion = null, + apiVersion = null, + noStdlibLink = false, + noJdkLink = false, + suppressedFiles = emptyList(), + analysisPlatform = Platform.DEFAULT +)
\ No newline at end of file diff --git a/plugins/gfm/src/main/kotlin/GfmPlugin.kt b/plugins/gfm/src/main/kotlin/GfmPlugin.kt index fb83d3b0..53ee2b53 100644 --- a/plugins/gfm/src/main/kotlin/GfmPlugin.kt +++ b/plugins/gfm/src/main/kotlin/GfmPlugin.kt @@ -1,20 +1,19 @@ package org.jetbrains.dokka.gfm import org.jetbrains.dokka.CoreExtensions +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.DefaultRenderer import org.jetbrains.dokka.base.renderers.PackageListCreator import org.jetbrains.dokka.base.renderers.RootCreator import org.jetbrains.dokka.base.resolvers.local.DefaultLocationProvider import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory -import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.query import org.jetbrains.dokka.transformers.pages.PageTransformer -import java.lang.StringBuilder class GfmPlugin : DokkaPlugin() { @@ -66,7 +65,7 @@ open class CommonmarkRenderer( override fun StringBuilder.buildList( node: ContentList, pageContext: ContentPage, - platformRestriction: Set<SourceSetData>? + platformRestriction: Set<DokkaSourceSet>? ) { buildParagraph() buildListLevel(node, pageContext) @@ -114,17 +113,21 @@ open class CommonmarkRenderer( override fun StringBuilder.buildPlatformDependent( content: PlatformHintedContent, pageContext: ContentPage, - sourceSetRestriction: Set<SourceSetData>? + sourceSetRestriction: Set<DokkaSourceSet>? ) { val distinct = content.sourceSets.map { - it to StringBuilder().apply {buildContentNode(content.inner, pageContext, setOf(it)) }.toString() - }.groupBy(Pair<SourceSetData, String>::second, Pair<SourceSetData, String>::first) + it to StringBuilder().apply { buildContentNode(content.inner, pageContext, setOf(it)) }.toString() + }.groupBy(Pair<DokkaSourceSet, String>::second, Pair<DokkaSourceSet, String>::first) if (distinct.size == 1) append(distinct.keys.single()) else distinct.forEach { text, platforms -> - append(platforms.joinToString(prefix = " [", postfix = "] $text") { "${it.moduleName}/${it.sourceSetID}" }) + append( + platforms.joinToString( + prefix = " [", + postfix = "] $text" + ) { "${it.moduleName}/${it.sourceSetID}" }) } } @@ -135,7 +138,7 @@ open class CommonmarkRenderer( override fun StringBuilder.buildTable( node: ContentTable, pageContext: ContentPage, - platformRestriction: Set<SourceSetData>? + platformRestriction: Set<DokkaSourceSet>? ) { buildParagraph() diff --git a/plugins/javadoc/src/main/kotlin/javadoc/JavadocLocationProvider.kt b/plugins/javadoc/src/main/kotlin/javadoc/JavadocLocationProvider.kt index a92320dd..f8ecf868 100644 --- a/plugins/javadoc/src/main/kotlin/javadoc/JavadocLocationProvider.kt +++ b/plugins/javadoc/src/main/kotlin/javadoc/JavadocLocationProvider.kt @@ -1,11 +1,11 @@ package javadoc import javadoc.pages.* +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.Platform import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.resolvers.local.LocationProvider import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.pages.ContentPage import org.jetbrains.dokka.pages.PageNode import org.jetbrains.dokka.pages.RootPageNode @@ -22,8 +22,8 @@ class JavadocLocationProvider(pageRoot: RootPageNode, private val context: Dokka externalLocationProviderFactories.asSequence().map { it.getExternalLocationProvider("javadoc10") } .filterNotNull().take(1).firstOrNull() private val externalDocumentationLinks by lazy { - context.configuration.passesConfigurations - .filter { passConfig -> passConfig.analysisPlatform == Platform.jvm } + context.configuration.sourceSets + .filter { sourceSet -> sourceSet.analysisPlatform == Platform.jvm } .flatMap { it.externalDocumentationLinks } .distinct() } @@ -65,7 +65,7 @@ class JavadocLocationProvider(pageRoot: RootPageNode, private val context: Dokka private operator fun IdentityHashMap<PageNode, List<String>>.get(dri: DRI) = this[nodeIndex[dri]] - override fun resolve(dri: DRI, sourceSets: List<SourceSetData>, context: PageNode?): String = + override fun resolve(dri: DRI, sourceSets: List<DokkaSourceSet>, context: PageNode?): String = context?.let { resolve(it, skipExtension = false) } ?: nodeIndex[dri]?.let { resolve(it, skipExtension = true) } ?: with(externalLocationProvider!!) { @@ -79,19 +79,20 @@ class JavadocLocationProvider(pageRoot: RootPageNode, private val context: Dokka throw IllegalStateException("Path for ${node::class.java.canonicalName}:${node.name} not found") } - fun resolve(link: LinkJavadocListEntry, dir: String = "", skipExtension: Boolean = true) = pathIndex[link.dri.first()]?.let { - when (link.kind) { - JavadocContentKind.Class -> it - JavadocContentKind.OverviewSummary -> it.dropLast(1) + "index" - JavadocContentKind.PackageSummary -> it.dropLast(1) + "package-summary" - JavadocContentKind.AllClasses -> it.dropLast(1) + "allclasses" - JavadocContentKind.OverviewTree -> it.dropLast(1) + "overview-tree" - JavadocContentKind.PackageTree -> it.dropLast(1) + "package-tree" - else -> it - } - }?.joinToString("/")?.let {if (skipExtension) "$it.html" else it}?.let { - Paths.get(dir).relativize(Paths.get(it)).toString() - } ?: run {""} //TODO just a glue to compile it on HMPP + fun resolve(link: LinkJavadocListEntry, dir: String = "", skipExtension: Boolean = true) = + pathIndex[link.dri.first()]?.let { + when (link.kind) { + JavadocContentKind.Class -> it + JavadocContentKind.OverviewSummary -> it.dropLast(1) + "index" + JavadocContentKind.PackageSummary -> it.dropLast(1) + "package-summary" + JavadocContentKind.AllClasses -> it.dropLast(1) + "allclasses" + JavadocContentKind.OverviewTree -> it.dropLast(1) + "overview-tree" + JavadocContentKind.PackageTree -> it.dropLast(1) + "package-tree" + else -> it + } + }?.joinToString("/")?.let { if (skipExtension) "$it.html" else it }?.let { + Paths.get(dir).relativize(Paths.get(it)).toString() + } ?: run { "" } //TODO just a glue to compile it on HMPP override fun resolveRoot(node: PageNode): String { TODO("Not yet implemented") diff --git a/plugins/javadoc/src/main/kotlin/javadoc/JavadocPageCreator.kt b/plugins/javadoc/src/main/kotlin/javadoc/JavadocPageCreator.kt index 53292225..6cf34ed1 100644 --- a/plugins/javadoc/src/main/kotlin/javadoc/JavadocPageCreator.kt +++ b/plugins/javadoc/src/main/kotlin/javadoc/JavadocPageCreator.kt @@ -1,6 +1,7 @@ package javadoc import javadoc.pages.* +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.Platform import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.signatures.function @@ -40,7 +41,7 @@ open class JavadocPageCreator( ) fun pageForClasslike(c: DClasslike): JavadocClasslikePageNode? = - c.sourceSets.firstOrNull { it.platform == Platform.jvm }?.let { jvm -> + c.sourceSets.firstOrNull { it.analysisPlatform == Platform.jvm }?.let { jvm -> JavadocClasslikePageNode( name = c.name.orEmpty(), content = contentForClasslike(c), @@ -72,11 +73,11 @@ open class JavadocPageCreator( JavadocContentGroup( setOf(m.dri), JavadocContentKind.OverviewSummary, - m.sourceSets.filter { it.platform == Platform.jvm }.toSet() + m.sourceSets.filter { it.analysisPlatform == Platform.jvm }.toSet() ) { title(m.name, "0.0.1", dri = setOf(m.dri), kind = ContentKind.Main) list("Packages", "Package", setOf(m.dri), ContentKind.Packages, m.packages.sortedBy { it.name }.map { p -> - val description = p.documentation.entries.find { (k, _) -> k.platform == Platform.jvm }?.value?.let { + val description = p.documentation.entries.find { (k, _) -> k.analysisPlatform == Platform.jvm }?.value?.let { it.children.firstIsInstanceOrNull<Description>()?.let { description -> DocTagToContentConverter.buildContent( description.root, @@ -96,7 +97,7 @@ open class JavadocPageCreator( JavadocContentGroup( setOf(p.dri), JavadocContentKind.PackageSummary, - p.sourceSets.filter { it.platform == Platform.jvm }.toSet() + p.sourceSets.filter { it.analysisPlatform == Platform.jvm }.toSet() ) { title(p.name, "0.0.1", dri = setOf(p.dri), kind = ContentKind.Packages) list("Packages", "Package", setOf(p.dri), ContentKind.Packages, p.classlikes.sortedBy { it.name }.map { c -> @@ -111,7 +112,7 @@ open class JavadocPageCreator( JavadocContentGroup( setOf(c.dri), JavadocContentKind.Class, - c.sourceSets.filter { it.platform == Platform.jvm }.toSet() + c.sourceSets.filter { it.analysisPlatform == Platform.jvm }.toSet() ) { title( c.name.orEmpty(), @@ -146,7 +147,7 @@ open class JavadocPageCreator( is UnresolvedBound -> p.name } - private fun DFunction.toJavadocFunction(sourceSetData: SourceSetData) = JavadocFunctionNode( + private fun DFunction.toJavadocFunction(sourceSetData: DokkaSourceSet) = JavadocFunctionNode( name = name, signature = signatureProvider.signature(this).jvmSignature(), brief = TextNode(description(sourceSetData), setOf(sourceSetData)), @@ -161,12 +162,12 @@ open class JavadocPageCreator( ) fun List<ContentNode>.jvmSignature(): ContentNode = - first { it.sourceSets.any { it.platform == Platform.jvm } } + first { it.sourceSets.any { it.analysisPlatform == Platform.jvm } } - private fun Documentable.description(sourceSetData: SourceSetData): String = + private fun Documentable.description(sourceSetData: DokkaSourceSet): String = findNodeInDocumentation<Description>(sourceSetData) - private inline fun <reified T : TagWrapper> Documentable.findNodeInDocumentation(sourceSetData: SourceSetData): String = + private inline fun <reified T : TagWrapper> Documentable.findNodeInDocumentation(sourceSetData: DokkaSourceSet): String = documentation[sourceSetData]?.children?.firstIsInstanceOrNull<T>()?.root?.children?.firstIsInstanceOrNull<Text>()?.body.orEmpty() } diff --git a/plugins/javadoc/src/main/kotlin/javadoc/KorteJavadocRenderer.kt b/plugins/javadoc/src/main/kotlin/javadoc/KorteJavadocRenderer.kt index 370ee68b..23a7c9ed 100644 --- a/plugins/javadoc/src/main/kotlin/javadoc/KorteJavadocRenderer.kt +++ b/plugins/javadoc/src/main/kotlin/javadoc/KorteJavadocRenderer.kt @@ -12,7 +12,7 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.sureClassNames import org.jetbrains.dokka.model.ImplementedInterfaces import org.jetbrains.dokka.model.InheritedFunction -import org.jetbrains.dokka.model.SourceSetData +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.renderers.Renderer @@ -269,13 +269,13 @@ class KorteJavadocRenderer(val outputWriter: OutputWriter, val context: DokkaCon ) + renderJavadocContentNode(node.content) private fun renderImplementedInterfaces(node: JavadocClasslikePageNode) = - node.extras[ImplementedInterfaces]?.interfaces?.entries?.firstOrNull { it.key.platform == Platform.jvm }?.value?.map { it.displayable() } // TODO: REMOVE HARDCODED JVM DEPENDENCY + node.extras[ImplementedInterfaces]?.interfaces?.entries?.firstOrNull { it.key.analysisPlatform == Platform.jvm }?.value?.map { it.displayable() } // TODO: REMOVE HARDCODED JVM DEPENDENCY .orEmpty() private fun renderClasslikeMethods(nodes: List<JavadocFunctionNode>): TemplateMap { val (inherited, own) = nodes.partition { val extra = it.extras[InheritedFunction] - extra?.inheritedFrom?.keys?.first { it.platform == Platform.jvm }?.let { jvm -> + extra?.inheritedFrom?.keys?.first { it.analysisPlatform == Platform.jvm }?.let { jvm -> extra.isInherited(jvm) } ?: false } @@ -294,7 +294,7 @@ class KorteJavadocRenderer(val outputWriter: OutputWriter, val context: DokkaCon private fun renderInheritedMethod(node: JavadocFunctionNode): TemplateMap { val inheritedFrom = node.extras[InheritedFunction]?.inheritedFrom return mapOf( - "inheritedFrom" to inheritedFrom?.entries?.firstOrNull { it.key.platform == Platform.jvm }?.value?.displayable() // TODO: REMOVE HARDCODED JVM DEPENDENCY + "inheritedFrom" to inheritedFrom?.entries?.firstOrNull { it.key.analysisPlatform == Platform.jvm }?.value?.displayable() // TODO: REMOVE HARDCODED JVM DEPENDENCY .orEmpty(), "name" to node.name ) @@ -370,7 +370,7 @@ class KorteJavadocRenderer(val outputWriter: OutputWriter, val context: DokkaCon ) } - private fun resolveLink(address: DRI, sourceSets: Set<SourceSetData>) = + private fun resolveLink(address: DRI, sourceSets: Set<DokkaSourceSet>) = locationProvider.resolve(address, sourceSets.toList()).let { val afterFormattingToHtml = formatToEndWithHtml(it) if (currentLocation != null) afterFormattingToHtml.relativizePath(currentLocation) diff --git a/plugins/javadoc/src/main/kotlin/javadoc/pages/JavadocContentNodes.kt b/plugins/javadoc/src/main/kotlin/javadoc/pages/JavadocContentNodes.kt index 6587e290..286223fa 100644 --- a/plugins/javadoc/src/main/kotlin/javadoc/pages/JavadocContentNodes.kt +++ b/plugins/javadoc/src/main/kotlin/javadoc/pages/JavadocContentNodes.kt @@ -1,7 +1,7 @@ package javadoc.pages import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.SourceSetData +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.pages.* @@ -12,7 +12,7 @@ enum class JavadocContentKind : Kind { abstract class JavadocContentNode( dri: Set<DRI>, kind: Kind, - override val sourceSets: Set<SourceSetData> + override val sourceSets: Set<DokkaSourceSet> ) : ContentNode { override val dci: DCI = DCI(dri, kind) override val style: Set<Style> = emptySet() @@ -27,7 +27,7 @@ interface JavadocListEntry { class EmptyNode( dri: DRI, kind: Kind, - override val sourceSets: Set<SourceSetData>, + override val sourceSets: Set<DokkaSourceSet>, override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty() ) : ContentNode { override val dci: DCI = DCI(setOf(dri), kind) @@ -42,7 +42,7 @@ class EmptyNode( class JavadocContentGroup( val dri: Set<DRI>, val kind: Kind, - sourceSets: Set<SourceSetData>, + sourceSets: Set<DokkaSourceSet>, val children: List<JavadocContentNode> ) : JavadocContentNode(dri, kind, sourceSets) { @@ -50,7 +50,7 @@ class JavadocContentGroup( operator fun invoke( dri: Set<DRI>, kind: Kind, - sourceSets: Set<SourceSetData>, + sourceSets: Set<DokkaSourceSet>, block: JavaContentGroupBuilder.() -> Unit ): JavadocContentGroup = JavadocContentGroup(dri, kind, sourceSets, JavaContentGroupBuilder(sourceSets).apply(block).list) @@ -59,7 +59,7 @@ class JavadocContentGroup( override fun hasAnyContent(): Boolean = children.isNotEmpty() } -class JavaContentGroupBuilder(val sourceSets: Set<SourceSetData>) { +class JavaContentGroupBuilder(val sourceSets: Set<DokkaSourceSet>) { val list = mutableListOf<JavadocContentNode>() } @@ -69,7 +69,7 @@ class TitleNode( val parent: String?, val dri: Set<DRI>, val kind: Kind, - sourceSets: Set<SourceSetData> + sourceSets: Set<DokkaSourceSet> ) : JavadocContentNode(dri, kind, sourceSets) { override fun hasAnyContent(): Boolean = !title.isBlank() || !version.isBlank() } @@ -86,7 +86,7 @@ fun JavaContentGroupBuilder.title( data class TextNode( val text: String, - override val sourceSets: Set<SourceSetData> + override val sourceSets: Set<DokkaSourceSet> ) : JavadocContentNode(emptySet(), ContentKind.Main, sourceSets) { override fun hasAnyContent(): Boolean = !text.isBlank() } @@ -97,7 +97,7 @@ class ListNode( val children: List<JavadocListEntry>, val dri: Set<DRI>, val kind: Kind, - sourceSets: Set<SourceSetData> + sourceSets: Set<DokkaSourceSet> ) : JavadocContentNode(dri, kind, sourceSets) { override fun hasAnyContent(): Boolean = children.isNotEmpty() } @@ -117,7 +117,7 @@ class LinkJavadocListEntry( val name: String, val dri: Set<DRI>, val kind: Kind = ContentKind.Symbol, - val sourceSets: Set<SourceSetData> + val sourceSets: Set<DokkaSourceSet> ) : JavadocListEntry { override val stringTag: String @@ -127,7 +127,7 @@ class LinkJavadocListEntry( private var builtString: String? = null - fun build(body: (String, Set<DRI>, Kind, List<SourceSetData>) -> String) { + fun build(body: (String, Set<DRI>, Kind, List<DokkaSourceSet>) -> String) { builtString = body(name, dri, kind, sourceSets.toList()) } } diff --git a/plugins/javadoc/src/main/kotlin/javadoc/pages/JavadocPageNodes.kt b/plugins/javadoc/src/main/kotlin/javadoc/pages/JavadocPageNodes.kt index becacd26..8cd16dba 100644 --- a/plugins/javadoc/src/main/kotlin/javadoc/pages/JavadocPageNodes.kt +++ b/plugins/javadoc/src/main/kotlin/javadoc/pages/JavadocPageNodes.kt @@ -418,7 +418,7 @@ class TreeViewPage( (this as? WithExpectActual).descriptorForPlatform(platform) private fun WithExpectActual?.descriptorForPlatform(platform: Platform = Platform.jvm) = this?.let { - it.sources.entries.find { it.key.platform == platform }?.value?.let { it as? DescriptorDocumentableSource }?.descriptor as? ClassDescriptor + it.sources.entries.find { it.key.analysisPlatform == platform }?.value?.let { it as? DescriptorDocumentableSource }?.descriptor as? ClassDescriptor } data class InheritanceNode( diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index 80971ae2..37c13442 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -3,7 +3,7 @@ package org.jetbrains.dokka import com.google.gson.Gson import kotlinx.cli.* import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink -import org.jetbrains.dokka.DokkaConfiguration.PassConfiguration.* +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet.* import org.jetbrains.dokka.utilities.DokkaConsoleLogger import org.jetbrains.dokka.utilities.cast import java.io.* @@ -31,9 +31,9 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration { description = "Path to cache folder, or 'default' to use ~/.cache/dokka, if not provided caching is disabled" ) - override val passesConfigurations by parser.option( + override val sourceSets by parser.option( ArgTypeArgument, - description = "Single dokka pass", + description = "Single dokka source set", fullName = "pass" ).multiple() @@ -83,18 +83,18 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration { init { parser.parse(args) - passesConfigurations.all { + sourceSets.all { it.perPackageOptions.cast<MutableList<DokkaConfiguration.PackageOptions>>() .addAll(parsePerPackageOptions(globalPackageOptions)) } - passesConfigurations.all { + sourceSets.all { it.externalDocumentationLinks.cast<MutableList<ExternalDocumentationLink>>().addAll(parseLinks(globalLinks)) } globalSrcLink.forEach { if (it.isNotEmpty() && it.contains("=")) - passesConfigurations.all { pass -> + sourceSets.all { pass -> pass.sourceLinks.cast<MutableList<SourceLinkDefinitionImpl>>() .add(SourceLinkDefinitionImpl.parseSourceLinkDefinition(it)) } @@ -103,13 +103,13 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration { } } - passesConfigurations.forEach { + sourceSets.forEach { it.externalDocumentationLinks.cast<MutableList<ExternalDocumentationLink>>().addAll(defaultLinks(it)) } } } -fun passArguments(args: Array<String>): DokkaConfiguration.PassConfiguration { +fun passArguments(args: Array<String>): DokkaConfiguration.DokkaSourceSet { val parser = ArgParser("passConfiguration", prefixStyle = ArgParser.OptionPrefixStyle.JVM) @@ -226,7 +226,7 @@ fun passArguments(args: Array<String>): DokkaConfiguration.PassConfiguration { parser.parse(args) - return object : DokkaConfiguration.PassConfiguration { + return object : DokkaConfiguration.DokkaSourceSet { override val moduleName = moduleName override val displayName = displayName override val sourceSetID = sourceSetID @@ -289,8 +289,8 @@ object ArgTypeSourceLinkDefinition : ArgType<DokkaConfiguration.SourceLinkDefini get() = "{ String that represent source links }" } -object ArgTypeArgument : ArgType<DokkaConfiguration.PassConfiguration>(true) { - override fun convert(value: kotlin.String, name: kotlin.String): DokkaConfiguration.PassConfiguration = +object ArgTypeArgument : ArgType<DokkaConfiguration.DokkaSourceSet>(true) { + override fun convert(value: kotlin.String, name: kotlin.String): DokkaConfiguration.DokkaSourceSet = passArguments(value.split(" ").filter { it.isNotBlank() }.toTypedArray()) override val description: kotlin.String @@ -305,7 +305,7 @@ object ArgTypeHelpPass : ArgType<Any>(false) { get() = "" } -fun defaultLinks(config: DokkaConfiguration.PassConfiguration): MutableList<ExternalDocumentationLink> = +fun defaultLinks(config: DokkaConfiguration.DokkaSourceSet): MutableList<ExternalDocumentationLink> = mutableListOf<ExternalDocumentationLink>().apply { if (!config.noJdkLink) this += DokkaConfiguration.ExternalDocumentationLink diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt index cef3695a..8483cd60 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt @@ -38,7 +38,7 @@ open class DokkaCollectorTask : DefaultTask() { configuration = passesConfigurations.fold(initial) { acc, it: GradleDokkaConfigurationImpl -> if(acc.format != it.format || acc.cacheRoot != it.cacheRoot) throw IllegalStateException("Dokka task configurations differ on core arguments (format, cacheRoot)") - acc.passesConfigurations = acc.passesConfigurations + it.passesConfigurations + acc.sourceSets = acc.sourceSets + it.sourceSets acc.pluginsClasspath = (acc.pluginsClasspath + it.pluginsClasspath).distinct() acc } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt index 1759b6f3..cc9471a1 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt @@ -69,9 +69,9 @@ open class DokkaTask : DefaultTask(), Configurable { internal var config: GradleDokkaConfigurationImpl? = null - var dokkaSourceSets: NamedDomainObjectContainer<GradlePassConfigurationImpl> + var dokkaSourceSets: NamedDomainObjectContainer<GradleDokkaSourceSet> @Suppress("UNCHECKED_CAST") - @Nested get() = (DslObject(this).extensions.getByName(SOURCE_SETS_EXTENSION_NAME) as NamedDomainObjectContainer<GradlePassConfigurationImpl>) + @Nested get() = (DslObject(this).extensions.getByName(SOURCE_SETS_EXTENSION_NAME) as NamedDomainObjectContainer<GradleDokkaSourceSet>) internal set(value) = DslObject(this).extensions.add(SOURCE_SETS_EXTENSION_NAME, value) private val kotlinTasks: List<Task> by lazy { @@ -184,7 +184,7 @@ open class DokkaTask : DefaultTask(), Configurable { .map { defaultPassConfiguration(it, globalConfig) }.takeIf { it.isNotEmpty() } ?: listOf( defaultPassConfiguration( - collectSinglePassConfiguration(GradlePassConfigurationImpl("main")), + collectSinglePassConfiguration(GradleDokkaSourceSet("main")), null ) ).takeIf { project.isNotMultiplatformProject() } ?: emptyList() @@ -199,7 +199,7 @@ open class DokkaTask : DefaultTask(), Configurable { format = outputFormat cacheRoot = this@DokkaTask.cacheRoot offlineMode = this@DokkaTask.offlineMode - passesConfigurations = defaultModulesConfiguration + sourceSets = passConfigurations pluginsClasspath = pluginsClasspathConfiguration.resolve().toList() pluginsConfiguration = this@DokkaTask.pluginsConfiguration failOnWarning = this@DokkaTask.failOnWarning @@ -207,12 +207,12 @@ open class DokkaTask : DefaultTask(), Configurable { } - protected val passConfigurations: List<GradlePassConfigurationImpl> + protected val passConfigurations: List<GradleDokkaSourceSet> get() = dokkaSourceSets .filterNot { it.name.toLowerCase() == GLOBAL_CONFIGURATION_NAME } .map { collectSinglePassConfiguration(it) } - protected fun collectSinglePassConfiguration(config: GradlePassConfigurationImpl): GradlePassConfigurationImpl { + protected fun collectSinglePassConfiguration(config: GradleDokkaSourceSet): GradleDokkaSourceSet { val userConfig = config .apply { collectKotlinTasks?.let { @@ -259,7 +259,7 @@ open class DokkaTask : DefaultTask(), Configurable { } } - protected fun collectFromSinglePlatformOldPlugin(name: String, userConfig: GradlePassConfigurationImpl) = + protected fun collectFromSinglePlatformOldPlugin(name: String, userConfig: GradleDokkaSourceSet) = kotlinTasks.find { it.name == name } ?.let { configExtractor.extractFromKotlinTasks(listOf(it)) } ?.singleOrNull() @@ -269,7 +269,7 @@ open class DokkaTask : DefaultTask(), Configurable { ?: userConfig protected fun mergeUserConfigurationAndPlatformData( - userConfig: GradlePassConfigurationImpl, + userConfig: GradleDokkaSourceSet, autoConfig: PlatformData ) = userConfig.copy().apply { @@ -281,9 +281,9 @@ open class DokkaTask : DefaultTask(), Configurable { } protected fun defaultPassConfiguration( - config: GradlePassConfigurationImpl, - globalConfig: GradlePassConfigurationImpl? - ): GradlePassConfigurationImpl { + config: GradleDokkaSourceSet, + globalConfig: GradleDokkaSourceSet? + ): GradleDokkaSourceSet { if (config.moduleName.isBlank()) { config.moduleName = project.name } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt index f4e7730e..c5169ef8 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt @@ -16,7 +16,7 @@ import java.util.concurrent.Callable import kotlin.reflect.KMutableProperty import kotlin.reflect.full.memberProperties -class GradleSourceRootImpl: SourceRoot, Serializable { +class GradleSourceRootImpl : SourceRoot, Serializable { override var path: String = "" set(value) { field = File(value).absolutePath @@ -25,33 +25,63 @@ class GradleSourceRootImpl: SourceRoot, Serializable { override fun toString(): String = path } -open class GradlePassConfigurationImpl(@Transient val name: String = ""): PassConfiguration { - @Input @Optional override var classpath: List<String> = emptyList() - @Input override var moduleName: String = "" - @Input override var displayName: String = "" - @Input override var sourceSetID: String = "" - @Input override var sourceRoots: MutableList<SourceRoot> = mutableListOf() - @Input override var dependentSourceSets: MutableList<String> = mutableListOf() - @Input override var samples: List<String> = emptyList() - @Input override var includes: List<String> = emptyList() - @Input override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic - @Input override var includeRootPackage: Boolean = DokkaDefaults.includeRootPackage - @Input override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented - @Input override var skipEmptyPackages: Boolean = DokkaDefaults.skipEmptyPackages - @Input override var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated - @Input override var jdkVersion: Int = DokkaDefaults.jdkVersion - @Input override var sourceLinks: MutableList<SourceLinkDefinition> = mutableListOf() - @Input override var perPackageOptions: MutableList<PackageOptions> = mutableListOf() - @Input override var externalDocumentationLinks: MutableList<ExternalDocumentationLink> = mutableListOf() - @Input @Optional override var languageVersion: String? = null - @Input @Optional override var apiVersion: String? = null - @Input override var noStdlibLink: Boolean = DokkaDefaults.noStdlibLink - @Input override var noJdkLink: Boolean = DokkaDefaults.noJdkLink - @Input var noAndroidSdkLink: Boolean = false - @Input override var suppressedFiles: List<String> = emptyList() - @Input override var analysisPlatform: Platform = DokkaDefaults.analysisPlatform - @Input @Optional var platform: String? = null - @Transient var collectKotlinTasks: (() -> List<Any?>?)? = null +open class GradleDokkaSourceSet(@Transient val name: String = "") : DokkaSourceSet { + @Input + @Optional + override var classpath: List<String> = emptyList() + @Input + override var moduleName: String = "" + @Input + override var displayName: String = "" + @Input + override var sourceSetID: String = "" + @Input + override var sourceRoots: MutableList<SourceRoot> = mutableListOf() + @Input + override var dependentSourceSets: MutableList<String> = mutableListOf() + @Input + override var samples: List<String> = emptyList() + @Input + override var includes: List<String> = emptyList() + @Input + override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic + @Input + override var includeRootPackage: Boolean = DokkaDefaults.includeRootPackage + @Input + override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented + @Input + override var skipEmptyPackages: Boolean = DokkaDefaults.skipEmptyPackages + @Input + override var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated + @Input + override var jdkVersion: Int = DokkaDefaults.jdkVersion + @Input + override var sourceLinks: MutableList<SourceLinkDefinition> = mutableListOf() + @Input + override var perPackageOptions: MutableList<PackageOptions> = mutableListOf() + @Input + override var externalDocumentationLinks: MutableList<ExternalDocumentationLink> = mutableListOf() + @Input + @Optional + override var languageVersion: String? = null + @Input + @Optional + override var apiVersion: String? = null + @Input + override var noStdlibLink: Boolean = DokkaDefaults.noStdlibLink + @Input + override var noJdkLink: Boolean = DokkaDefaults.noJdkLink + @Input + var noAndroidSdkLink: Boolean = false + @Input + override var suppressedFiles: List<String> = emptyList() + @Input + override var analysisPlatform: Platform = DokkaDefaults.analysisPlatform + @Input + @Optional + var platform: String? = null + @Transient + var collectKotlinTasks: (() -> List<Any?>?)? = null fun kotlinTasks(taskSupplier: Callable<List<Any>>) { collectKotlinTasks = { taskSupplier.call() } @@ -117,25 +147,25 @@ class GradleExternalDocumentationLinkImpl : ExternalDocumentationLink, Serializa override var packageListUrl: URL = URL("http://") } -class GradleDokkaModuleDescription: DokkaModuleDescription { +class GradleDokkaModuleDescription : DokkaModuleDescription { override var name: String = "" override var path: String = "" override var docFile: String = "" } -class GradleDokkaConfigurationImpl: DokkaConfiguration { +class GradleDokkaConfigurationImpl : DokkaConfiguration { override var outputDir: String = "" override var format: String = DokkaDefaults.format override var cacheRoot: String? = DokkaDefaults.cacheRoot override var offlineMode: Boolean = DokkaDefaults.offlineMode override var failOnWarning: Boolean = DokkaDefaults.failOnWarning - override var passesConfigurations: List<GradlePassConfigurationImpl> = emptyList() + override var sourceSets: List<GradleDokkaSourceSet> = emptyList() override var pluginsClasspath: List<File> = emptyList() override var pluginsConfiguration: Map<String, String> = mutableMapOf() override var modules: List<GradleDokkaModuleDescription> = emptyList() } -class GradlePackageOptionsImpl: PackageOptions, Serializable { +class GradlePackageOptionsImpl : PackageOptions, Serializable { override var prefix: String = "" override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented @@ -143,8 +173,8 @@ class GradlePackageOptionsImpl: PackageOptions, Serializable { override var suppress: Boolean = DokkaDefaults.suppress } -internal fun GradlePassConfigurationImpl.copy(): GradlePassConfigurationImpl { - val newObj = GradlePassConfigurationImpl(this.name) +internal fun GradleDokkaSourceSet.copy(): GradleDokkaSourceSet { + val newObj = GradleDokkaSourceSet(this.name) this::class.memberProperties.forEach { field -> if (field is KMutableProperty<*>) { val value = field.getter.call(this) diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt index 41d6e67a..2b076fd0 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt @@ -57,7 +57,7 @@ open class DokkaPlugin : Plugin<Project> { project.tasks.create(DOKKA_TASK_NAME, taskClass) } project.tasks.withType(taskClass) { task -> - task.dokkaSourceSets = project.container(GradlePassConfigurationImpl::class.java) + task.dokkaSourceSets = project.container(GradleDokkaSourceSet::class.java) task.dokkaRuntime = runtimeConfiguration task.pluginsClasspathConfiguration = pluginsConfiguration task.outputDirectory = File(project.buildDir, DOKKA_TASK_NAME).absolutePath diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index 1ef04772..b0baabee 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -29,7 +29,6 @@ import org.eclipse.aether.transport.file.FileTransporterFactory import org.eclipse.aether.transport.http.HttpTransporterFactory import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator import org.jetbrains.dokka.* -import org.jetbrains.dokka.DokkaConfiguration.PackageOptions import java.io.File import java.net.URL @@ -187,7 +186,7 @@ abstract class AbstractDokkaMojo : AbstractMojo() { throw MojoExecutionException("Incorrect path property, only Unix based path allowed.") } } - fun defaultLinks(config: PassConfigurationImpl): List<ExternalDocumentationLinkImpl> { + fun defaultLinks(config: DokkaSourceSetImpl): List<ExternalDocumentationLinkImpl> { val links = mutableListOf<ExternalDocumentationLinkImpl>() if (!config.noJdkLink) links += DokkaConfiguration.ExternalDocumentationLink @@ -201,7 +200,7 @@ abstract class AbstractDokkaMojo : AbstractMojo() { return links } - val passConfiguration = PassConfigurationImpl( + val sourceSet = DokkaSourceSetImpl( moduleName = moduleName, displayName = displayName, sourceSetID = sourceSetName, @@ -246,8 +245,8 @@ abstract class AbstractDokkaMojo : AbstractMojo() { format = getOutFormat(), offlineMode = offlineMode, cacheRoot = cacheRoot, - passesConfigurations = listOf(passConfiguration).also { - if (passConfiguration.moduleName.isEmpty()) logger.warn("Not specified module name. It can result in unexpected behaviour while including documentation for module") + sourceSets = listOf(sourceSet).also { + if (sourceSet.moduleName.isEmpty()) logger.warn("Not specified module name. It can result in unexpected behaviour while including documentation for module") }, pluginsClasspath = getArtifactByAether("org.jetbrains.dokka", "dokka-base", dokkaVersion) + dokkaPlugins.map { getArtifactByAether(it.groupId, it.artifactId, it.version) }.flatten(), diff --git a/testApi/src/main/kotlin/testApi/context/MockContext.kt b/testApi/src/main/kotlin/testApi/context/MockContext.kt index e3da5f68..07aedf28 100644 --- a/testApi/src/main/kotlin/testApi/context/MockContext.kt +++ b/testApi/src/main/kotlin/testApi/context/MockContext.kt @@ -1,8 +1,7 @@ package org.jetbrains.dokka.testApi.context import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.model.SourceSetCache -import org.jetbrains.dokka.model.SourceSetData +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.plugability.ExtensionPoint @@ -15,8 +14,7 @@ import kotlin.reflect.full.memberProperties class MockContext( vararg extensions: Pair<ExtensionPoint<*>, (DokkaContext) -> Any>, private val testConfiguration: DokkaConfiguration? = null, - private val unusedExtensionPoints: List<ExtensionPoint<*>>? = null, - override val sourceSetCache: SourceSetCache + private val unusedExtensionPoints: List<ExtensionPoint<*>>? = null ) : DokkaContext { private val extensionMap by lazy { extensions.groupBy(Pair<ExtensionPoint<*>, (DokkaContext) -> Any>::first) { diff --git a/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt b/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt index 7248a4cb..ec2be689 100644 --- a/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt +++ b/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt @@ -1,9 +1,8 @@ package org.jetbrains.dokka.testApi.testRunner import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.DokkaGenerator -import org.jetbrains.dokka.model.SourceSetCache -import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.utilities.DokkaLogger @@ -16,13 +15,12 @@ internal class DokkaTestGenerator( fun generate() = with(testMethods) { val dokkaGenerator = DokkaGenerator(configuration, logger) - val sourceSetsCache = SourceSetCache() val context = - dokkaGenerator.initializePlugins(configuration, logger, sourceSetsCache, pluginOverrides) + dokkaGenerator.initializePlugins(configuration, logger, pluginOverrides) pluginsSetupStage(context) - val modulesFromPlatforms = dokkaGenerator.createDocumentationModels(context, sourceSetsCache) + val modulesFromPlatforms = dokkaGenerator.createDocumentationModels(context) documentablesCreationStage(modulesFromPlatforms) val filteredModules = dokkaGenerator.transformDocumentationModelBeforeMerge(modulesFromPlatforms, context) diff --git a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt index 88595f85..624ea914 100644 --- a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt +++ b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt @@ -3,13 +3,11 @@ package org.jetbrains.dokka.testApi.testRunner import com.intellij.openapi.application.PathManager import org.jetbrains.dokka.* import org.jetbrains.dokka.model.DModule -import org.jetbrains.dokka.model.SourceSetData -import org.jetbrains.dokka.pages.ModulePageNode +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.utilities.DokkaConsoleLogger -import org.jetbrains.dokka.utilities.DokkaLogger import org.junit.rules.TemporaryFolder import testApi.logger.TestLogger import java.io.File @@ -66,7 +64,7 @@ abstract class AbstractCoreTest { val newConfiguration = configuration.copy( outputDir = testDirPath.toAbsolutePath().toString(), - passesConfigurations = configuration.passesConfigurations.map { + sourceSets = configuration.sourceSets.map { it.copy(sourceRoots = it.sourceRoots.map { it.copy(path = "${testDirPath.toAbsolutePath()}/${it.path}") }) } ) @@ -143,13 +141,13 @@ abstract class AbstractCoreTest { var pluginsClasspath: List<File> = emptyList() var pluginsConfigurations: Map<String, String> = emptyMap() var failOnWarning: Boolean = false - private val passesConfigurations = mutableListOf<PassConfigurationImpl>() + private val sourceSets = mutableListOf<DokkaSourceSetImpl>() fun build() = DokkaConfigurationImpl( outputDir = outputDir, format = format, cacheRoot = cacheRoot, offlineMode = offlineMode, - passesConfigurations = passesConfigurations, + sourceSets = sourceSets, pluginsClasspath = pluginsClasspath, pluginsConfiguration = pluginsConfigurations, modules = emptyList(), @@ -157,18 +155,18 @@ abstract class AbstractCoreTest { ) fun passes(block: Passes.() -> Unit) { - passesConfigurations.addAll(Passes().apply(block)) + sourceSets.addAll(Passes().apply(block)) } } @DokkaConfigurationDsl - protected class Passes : ArrayList<PassConfigurationImpl>() { - fun pass(block: DokkaPassConfigurationBuilder.() -> Unit) = - add(DokkaPassConfigurationBuilder().apply(block).build()) + protected class Passes : ArrayList<DokkaSourceSetImpl>() { + fun pass(block: DokkaSourceSetBuilder.() -> Unit) = + add(DokkaSourceSetBuilder().apply(block).build()) } @DokkaConfigurationDsl - protected class DokkaPassConfigurationBuilder( + protected class DokkaSourceSetBuilder( var moduleName: String = "root", var sourceSetID: String = "main", var displayName: String = "JVM", @@ -193,7 +191,7 @@ abstract class AbstractCoreTest { var externalDocumentationLinks: List<ExternalDocumentationLinkImpl> = emptyList(), var sourceLinks: List<SourceLinkDefinitionImpl> = emptyList() ) { - fun build() = PassConfigurationImpl( + fun build() = DokkaSourceSetImpl( moduleName = moduleName, displayName = displayName, sourceSetID = sourceSetID, |