From 02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Thu, 31 Aug 2023 20:16:01 +0200 Subject: Enable explicit API mode (#3139) --- .../javadoc/JavadocDocumentableToPageTranslator.kt | 2 +- .../jetbrains/dokka/javadoc/JavadocPageCreator.kt | 19 ++-- .../org/jetbrains/dokka/javadoc/JavadocPlugin.kt | 47 +++++---- .../javadoc/location/JavadocLocationProvider.kt | 16 +-- .../location/JavadocLocationProviderFactory.kt | 7 +- .../dokka/javadoc/pages/JavadocContentNodes.kt | 81 +++++++++------- .../dokka/javadoc/pages/JavadocIndexExtra.kt | 4 +- .../dokka/javadoc/pages/JavadocPageNodes.kt | 108 ++++++++++++--------- .../dokka/javadoc/pages/htmlPreprocessors.kt | 17 +++- .../renderer/JavadocContentToHtmlTranslator.kt | 2 +- .../dokka/javadoc/renderer/KorteJavadocRenderer.kt | 19 ++-- .../dokka/javadoc/renderer/SearchScriptsCreator.kt | 6 +- .../javadoc/signatures/JavadocSignatureProvider.kt | 10 +- .../JavadocDocumentableJVMSourceSetFilter.kt | 4 +- .../documentables/JavadocPageContentBuilder.kt | 24 ++--- .../validity/MultiplatformConfiguredChecker.kt | 8 +- 16 files changed, 215 insertions(+), 159 deletions(-) (limited to 'plugins/javadoc/src/main/kotlin') diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocDocumentableToPageTranslator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocDocumentableToPageTranslator.kt index 07a58c1b..595c307a 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocDocumentableToPageTranslator.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocDocumentableToPageTranslator.kt @@ -9,7 +9,7 @@ import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator -class JavadocDocumentableToPageTranslator( +public class JavadocDocumentableToPageTranslator( private val context: DokkaContext ) : DocumentableToPageTranslator { override fun invoke(module: DModule): RootPageNode = JavadocPageCreator(context).pageForModule(module) diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt index d078b492..cfdda649 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt @@ -20,25 +20,27 @@ import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.querySingle import kotlin.reflect.KClass -open class JavadocPageCreator(context: DokkaContext) { +public open class JavadocPageCreator(context: DokkaContext) { private val signatureProvider: SignatureProvider = context.plugin().querySingle { signatureProvider } private val documentationVersion = context.configuration.moduleVersion - fun pageForModule(m: DModule): JavadocModulePageNode = - JavadocModulePageNode( + public fun pageForModule(m: DModule): JavadocModulePageNode { + return JavadocModulePageNode( name = m.name.ifEmpty { "root" }, content = contentForModule(m), children = m.packages.map { pageForPackage(it) }, dri = setOf(m.dri), extra = ((m as? WithExtraProperties)?.extra ?: PropertyContainer.empty()) ) + } - fun pageForPackage(p: DPackage) = - JavadocPackagePageNode(p.name, contentForPackage(p), setOf(p.dri), listOf(p), + public fun pageForPackage(p: DPackage): JavadocPackagePageNode { + return JavadocPackagePageNode(p.name, contentForPackage(p), setOf(p.dri), listOf(p), p.classlikes.mapNotNull { pageForClasslike(it) } ) + } - fun pageForClasslike(c: DClasslike): JavadocClasslikePageNode? { + public fun pageForClasslike(c: DClasslike): JavadocClasslikePageNode? { return c.highestJvmSourceSet?.let { jvm -> @Suppress("UNCHECKED_CAST") val extra = ((c as? WithExtraProperties)?.extra ?: PropertyContainer.empty()) @@ -209,9 +211,10 @@ open class JavadocPageCreator(context: DokkaContext) { ) } - fun List.nodeForJvm(jvm: DokkaSourceSet): ContentNode = - firstOrNull { jvm.sourceSetID in it.sourceSets.computeSourceSetIds() } + public fun List.nodeForJvm(jvm: DokkaSourceSet): ContentNode { + return firstOrNull { jvm.sourceSetID in it.sourceSets.computeSourceSetIds() } ?: throw IllegalStateException("No source set found for ${jvm.sourceSetID} ") + } private fun Documentable.brief(sourceSet: DokkaSourceSet? = highestJvmSourceSet): List = firstSentenceBriefFromContentNodes(descriptionToContentNodes(sourceSet)) diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt index 37037101..6a5749ab 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt @@ -8,8 +8,10 @@ import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.PackageListCreator import org.jetbrains.dokka.base.renderers.RootCreator +import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory import org.jetbrains.dokka.base.resolvers.shared.PackageList.Companion.PACKAGE_LIST_NAME import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat +import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.javadoc.location.JavadocLocationProviderFactory import org.jetbrains.dokka.javadoc.pages.* import org.jetbrains.dokka.javadoc.renderer.KorteJavadocRenderer @@ -17,49 +19,52 @@ import org.jetbrains.dokka.javadoc.signatures.JavadocSignatureProvider import org.jetbrains.dokka.javadoc.transformers.documentables.JavadocDocumentableJVMSourceSetFilter import org.jetbrains.dokka.javadoc.validity.MultiplatformConfiguredChecker import org.jetbrains.dokka.kotlinAsJava.KotlinAsJavaPlugin -import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.plugability.DokkaPluginApiPreview -import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement +import org.jetbrains.dokka.plugability.* import org.jetbrains.dokka.renderers.PostAction +import org.jetbrains.dokka.renderers.Renderer +import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator +import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer import org.jetbrains.dokka.transformers.pages.PageTransformer +import org.jetbrains.dokka.validity.PreGenerationChecker -class JavadocPlugin : DokkaPlugin() { +public class JavadocPlugin : DokkaPlugin() { - val dokkaBasePlugin by lazy { plugin() } - val kotinAsJavaPlugin by lazy { plugin() } - val locationProviderFactory by lazy { dokkaBasePlugin.locationProviderFactory } - val javadocPreprocessors by extensionPoint() + private val dokkaBasePlugin: DokkaBase by lazy { plugin() } + private val kotinAsJavaPlugin: KotlinAsJavaPlugin by lazy { plugin() } - val dokkaJavadocPlugin by extending { + public val locationProviderFactory: ExtensionPoint by lazy { dokkaBasePlugin.locationProviderFactory } + public val javadocPreprocessors: ExtensionPoint by extensionPoint() + + public val dokkaJavadocPlugin: Extension by extending { CoreExtensions.renderer providing { ctx -> KorteJavadocRenderer(ctx, "views") } override dokkaBasePlugin.htmlRenderer } - val javadocMultiplatformCheck by extending { + public val javadocMultiplatformCheck: Extension by extending { CoreExtensions.preGenerationCheck providing ::MultiplatformConfiguredChecker } - val pageTranslator by extending { + public val pageTranslator: Extension by extending { CoreExtensions.documentableToPageTranslator providing ::JavadocDocumentableToPageTranslator override kotinAsJavaPlugin.kotlinAsJavaDocumentableToPageTranslator } - val documentableSourceSetFilter by extending { + public val documentableSourceSetFilter: Extension by extending { dokkaBasePlugin.preMergeDocumentableTransformer providing ::JavadocDocumentableJVMSourceSetFilter } - val javadocLocationProviderFactory by extending { + public val javadocLocationProviderFactory: Extension by extending { dokkaBasePlugin.locationProviderFactory providing ::JavadocLocationProviderFactory override dokkaBasePlugin.locationProvider } - val javadocSignatureProvider by extending { + public val javadocSignatureProvider: Extension by extending { dokkaBasePlugin.signatureProvider providing ::JavadocSignatureProvider override kotinAsJavaPlugin.javaSignatureProvider } - val rootCreator by extending { + public val rootCreator: Extension by extending { javadocPreprocessors with RootCreator } - val packageListCreator by extending { + public val packageListCreator: Extension by extending { javadocPreprocessors providing { PackageListCreator( context = it, @@ -69,23 +74,23 @@ class JavadocPlugin : DokkaPlugin() { } order { after(rootCreator) } } - val resourcesInstaller by extending { + public val resourcesInstaller: Extension by extending { javadocPreprocessors with ResourcesInstaller order { after(rootCreator) } } - val treeViewInstaller by extending { + public val treeViewInstaller: Extension by extending { javadocPreprocessors providing ::TreeViewInstaller order { after(rootCreator) } } - val allClassessPageInstaller by extending { + public val allClassessPageInstaller: Extension by extending { javadocPreprocessors with AllClassesPageInstaller order { before(rootCreator) } } - val indexGenerator by extending { + public val indexGenerator: Extension by extending { javadocPreprocessors with IndexGenerator order { before(rootCreator) } } - val deprecatedPageCreator by extending { + public val deprecatedPageCreator: Extension by extending { javadocPreprocessors with DeprecatedPageCreator order { before(rootCreator) } } diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationProvider.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationProvider.kt index 114355d3..6de4c808 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationProvider.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationProvider.kt @@ -16,8 +16,10 @@ import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import java.util.* -class JavadocLocationProvider(pageRoot: RootPageNode, dokkaContext: DokkaContext) : - DefaultLocationProvider(pageRoot, dokkaContext) { +public class JavadocLocationProvider( + pageRoot: RootPageNode, + dokkaContext: DokkaContext +) : DefaultLocationProvider(pageRoot, dokkaContext) { private val pathIndex = IdentityHashMap>().apply { fun registerPath(page: PageNode, prefix: List = emptyList()) { @@ -103,15 +105,16 @@ class JavadocLocationProvider(pageRoot: RootPageNode, dokkaContext: DokkaContext })" } ?: dri.classNames.orEmpty() - override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean) = - pathIndex[node]?.relativeTo(pathIndex[context].orEmpty())?.let { + override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean): String { + return pathIndex[node]?.relativeTo(pathIndex[context].orEmpty())?.let { if (skipExtension) it.removeSuffix(".html") else it } ?: run { throw IllegalStateException("Path for ${node::class.java.canonicalName}:${node.name} not found") } + } - fun resolve(link: LinkJavadocListEntry, contextRoot: PageNode? = null, skipExtension: Boolean = true) = - pathIndex[link.dri.first()]?.let { + public fun resolve(link: LinkJavadocListEntry, contextRoot: PageNode? = null, skipExtension: Boolean = true): String { + return pathIndex[link.dri.first()]?.let { when (link.kind) { JavadocContentKind.Class -> it JavadocContentKind.OverviewSummary -> it.dropLast(1) + "index" @@ -123,6 +126,7 @@ class JavadocLocationProvider(pageRoot: RootPageNode, dokkaContext: DokkaContext else -> it } }?.relativeTo(pathIndex[contextRoot].orEmpty())?.let { if (skipExtension) "$it.html" else it }.orEmpty() + } override fun pathToRoot(from: PageNode): String { TODO("Not yet implemented") diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationProviderFactory.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationProviderFactory.kt index ebc7ca27..10e7d416 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationProviderFactory.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationProviderFactory.kt @@ -4,11 +4,14 @@ package org.jetbrains.dokka.javadoc.location +import org.jetbrains.dokka.base.resolvers.local.LocationProvider import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext -class JavadocLocationProviderFactory(private val context: DokkaContext) : LocationProviderFactory { - override fun getLocationProvider(pageNode: RootPageNode) = +public class JavadocLocationProviderFactory( + private val context: DokkaContext +) : LocationProviderFactory { + override fun getLocationProvider(pageNode: RootPageNode): LocationProvider = JavadocLocationProvider(pageNode, context) } diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt index 41506d1c..427ad98e 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt @@ -9,11 +9,11 @@ import org.jetbrains.dokka.model.DisplaySourceSet import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.pages.* -enum class JavadocContentKind : Kind { +public enum class JavadocContentKind : Kind { AllClasses, OverviewSummary, PackageSummary, Class, OverviewTree, PackageTree, IndexPage } -abstract class JavadocContentNode( +public abstract class JavadocContentNode( dri: Set, kind: Kind, override val sourceSets: Set @@ -24,17 +24,17 @@ abstract class JavadocContentNode( override fun withNewExtras(newExtras: PropertyContainer): ContentNode = this } -interface JavadocList { - val tabTitle: String - val colTitle: String - val children: List +public interface JavadocList { + public val tabTitle: String + public val colTitle: String + public val children: List } -interface JavadocListEntry { - val stringTag: String +public interface JavadocListEntry { + public val stringTag: String } -data class EmptyNode( +public data class EmptyNode( val dri: DRI, val kind: Kind, override val sourceSets: Set, @@ -51,15 +51,15 @@ data class EmptyNode( override fun hasAnyContent(): Boolean = false } -data class JavadocContentGroup( +public data class JavadocContentGroup( val dri: Set, val kind: Kind, override val sourceSets: Set, override val children: List ) : JavadocContentNode(dri, kind, sourceSets) { - companion object { - operator fun invoke( + public companion object { + public operator fun invoke( dri: Set, kind: Kind, sourceSets: Set, @@ -76,11 +76,13 @@ data class JavadocContentGroup( copy(sourceSets = sourceSets) } -class JavaContentGroupBuilder(val sourceSets: Set) { - val list = mutableListOf() +public class JavaContentGroupBuilder( + public val sourceSets: Set +) { + public val list: MutableList = mutableListOf() } -data class TitleNode( +public data class TitleNode( val title: String, val subtitle: List, val version: String?, @@ -97,7 +99,7 @@ data class TitleNode( copy(sourceSets = sourceSets) } -fun JavaContentGroupBuilder.title( +public fun JavaContentGroupBuilder.title( title: String, subtitle: List, version: String? = null, @@ -108,7 +110,7 @@ fun JavaContentGroupBuilder.title( list.add(TitleNode(title, subtitle, version, parent, dri, kind, sourceSets)) } -data class RootListNode( +public data class RootListNode( val entries: List, val dri: Set, val kind: Kind, @@ -121,7 +123,7 @@ data class RootListNode( copy(sourceSets = sourceSets) } -data class LeafListNode( +public data class LeafListNode( val tabTitle: String, val colTitle: String, val entries: List, @@ -135,7 +137,7 @@ data class LeafListNode( } -fun JavaContentGroupBuilder.rootList( +public fun JavaContentGroupBuilder.rootList( dri: Set, kind: Kind, rootList: List @@ -146,7 +148,7 @@ fun JavaContentGroupBuilder.rootList( list.add(RootListNode(children, dri, kind, sourceSets)) } -fun JavaContentGroupBuilder.leafList( +public fun JavaContentGroupBuilder.leafList( dri: Set, kind: Kind, leafList: JavadocList @@ -154,36 +156,41 @@ fun JavaContentGroupBuilder.leafList( list.add(LeafListNode(leafList.tabTitle, leafList.colTitle, leafList.children, dri, kind, sourceSets)) } -fun JavadocList(tabTitle: String, colTitle: String, children: List) = object : JavadocList { - override val tabTitle = tabTitle - override val colTitle = colTitle - override val children = children +public fun JavadocList(tabTitle: String, colTitle: String, children: List): JavadocList { + return object : JavadocList { + override val tabTitle = tabTitle + override val colTitle = colTitle + override val children = children + } } -class LinkJavadocListEntry( - val name: String, - val dri: Set, - val kind: Kind = ContentKind.Symbol, - val sourceSets: Set -) : - JavadocListEntry { +public class LinkJavadocListEntry( + public val name: String, + public val dri: Set, + public val kind: Kind = ContentKind.Symbol, + public val sourceSets: Set +) : JavadocListEntry { override val stringTag: String - get() = if (builtString == null) - throw IllegalStateException("stringTag for LinkJavadocListEntry accessed before build() call") - else builtString!! + get() { + return if (builtString == null) { + throw IllegalStateException("stringTag for LinkJavadocListEntry accessed before build() call") + } else { + builtString!! + } + } private var builtString: String? = null - fun build(body: (String, Set, Kind, List) -> String) { + public fun build(body: (String, Set, Kind, List) -> String) { builtString = body(name, dri, kind, sourceSets.toList()) } } -data class RowJavadocListEntry(val link: LinkJavadocListEntry, val doc: List) : JavadocListEntry { +public data class RowJavadocListEntry(val link: LinkJavadocListEntry, val doc: List) : JavadocListEntry { override val stringTag: String = "" } -data class JavadocSignatureContentNode( +public data class JavadocSignatureContentNode( val dri: DRI, val kind: Kind = ContentKind.Symbol, val annotations: ContentNode?, diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocIndexExtra.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocIndexExtra.kt index 217bdb9d..4ed0864a 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocIndexExtra.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocIndexExtra.kt @@ -8,7 +8,7 @@ import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.pages.ContentNode -data class JavadocIndexExtra(val index: List) : ExtraProperty { +public data class JavadocIndexExtra(val index: List) : ExtraProperty { override val key: ExtraProperty.Key = JavadocIndexExtra - companion object : ExtraProperty.Key + public companion object : ExtraProperty.Key } diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt index aa398c0d..3b5b63cc 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt @@ -14,22 +14,22 @@ import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.analysis.kotlin.internal.InheritanceBuilder import org.jetbrains.dokka.analysis.kotlin.internal.InheritanceNode -interface JavadocPageNode : ContentPage, WithDocumentables +public interface JavadocPageNode : ContentPage, WithDocumentables -interface WithJavadocExtra : WithExtraProperties { +public interface WithJavadocExtra : WithExtraProperties { override fun withNewExtras(newExtras: PropertyContainer): T = throw IllegalStateException("Merging extras is not applicable for javadoc") } -fun interface WithNavigable { - fun getAllNavigables(): List +public fun interface WithNavigable { + public fun getAllNavigables(): List } -interface WithBrief { - val brief: List +public interface WithBrief { + public val brief: List } -class JavadocModulePageNode( +public class JavadocModulePageNode( override val name: String, override val content: JavadocContentNode, override val children: List, @@ -60,7 +60,7 @@ class JavadocModulePageNode( override fun getDRI(): DRI = dri.first() } -class JavadocPackagePageNode( +public class JavadocPackagePageNode( override val name: String, override val content: JavadocContentNode, override val dri: Set, @@ -116,17 +116,20 @@ class JavadocPackagePageNode( override fun getDRI(): DRI = dri.first() } -interface NavigableJavadocNode { - fun getId(): String - fun getDRI(): DRI +public interface NavigableJavadocNode { + public fun getId(): String + public fun getDRI(): DRI } -sealed class AnchorableJavadocNode(open val name: String, open val dri: DRI) : NavigableJavadocNode { +public sealed class AnchorableJavadocNode( + public open val name: String, + public open val dri: DRI +) : NavigableJavadocNode { override fun getId(): String = name override fun getDRI(): DRI = dri } -data class JavadocEntryNode( +public data class JavadocEntryNode( override val dri: DRI, override val name: String, val signature: JavadocSignatureContentNode, @@ -134,7 +137,7 @@ data class JavadocEntryNode( override val extra: PropertyContainer = PropertyContainer.empty() ) : AnchorableJavadocNode(name, dri), WithJavadocExtra, WithBrief -data class JavadocParameterNode( +public data class JavadocParameterNode( override val dri: DRI, override val name: String, val type: ContentNode, @@ -143,7 +146,7 @@ data class JavadocParameterNode( override val extra: PropertyContainer = PropertyContainer.empty() ) : AnchorableJavadocNode(name, dri), WithJavadocExtra -data class JavadocPropertyNode( +public data class JavadocPropertyNode( override val dri: DRI, override val name: String, val signature: JavadocSignatureContentNode, @@ -152,7 +155,7 @@ data class JavadocPropertyNode( override val extra: PropertyContainer = PropertyContainer.empty() ) : AnchorableJavadocNode(name, dri), WithJavadocExtra, WithBrief -data class JavadocFunctionNode( +public data class JavadocFunctionNode( val signature: JavadocSignatureContentNode, override val brief: List, val description: List, @@ -174,21 +177,21 @@ data class JavadocFunctionNode( } } -class JavadocClasslikePageNode( +public class JavadocClasslikePageNode( override val name: String, override val content: JavadocContentNode, override val dri: Set, - val signature: JavadocSignatureContentNode, - val description: List, - val constructors: List, - val methods: List, - val entries: List, - val classlikes: List, - val properties: List, + public val signature: JavadocSignatureContentNode, + public val description: List, + public val constructors: List, + public val methods: List, + public val entries: List, + public val classlikes: List, + public val properties: List, override val brief: List, - val sinceTagContent: List>, - val authorTagContent: List>, + public val sinceTagContent: List>, + public val authorTagContent: List>, override val documentables: List = emptyList(), override val children: List = emptyList(), @@ -199,11 +202,11 @@ class JavadocClasslikePageNode( override fun getAllNavigables(): List = methods + entries + classlikes.map { it.getAllNavigables() }.flatten() + this - fun getAnchorables(): List = + public fun getAnchorables(): List = constructors + methods + entries + properties - val kind: String? = documentables.firstOrNull()?.kind() - val packageName = dri.first().packageName + public val kind: String? = documentables.firstOrNull()?.kind() + public val packageName: String? = dri.first().packageName override fun getId(): String = name override fun getDRI(): DRI = dri.first() @@ -259,8 +262,10 @@ class JavadocClasslikePageNode( ) } -class AllClassesPage(val classes: List) : JavadocPageNode { - val classEntries = +public class AllClassesPage( + public val classes: List +) : JavadocPageNode { + public val classEntries: List = classes.map { LinkJavadocListEntry(it.name, it.dri, ContentKind.Classlikes, it.sourceSets().toSet()) } override val name: String = "All Classes" @@ -291,8 +296,8 @@ class AllClassesPage(val classes: List) : JavadocPageN } -class DeprecatedPage( - val elements: Map>, +public class DeprecatedPage( + public val elements: Map>, sourceSet: Set ) : JavadocPageNode { override val name: String = "deprecated" @@ -322,14 +327,22 @@ class DeprecatedPage( } -class DeprecatedNode(val name: String, val address: DRI, val description: List) { +public class DeprecatedNode( + public val name: String, + public val address: DRI, + public val description: List +) { override fun equals(other: Any?): Boolean = (other as? DeprecatedNode)?.address == address override fun hashCode(): Int = address.hashCode() } -enum class DeprecatedPageSection(val id: String, val caption: String, val header: String) { +public enum class DeprecatedPageSection( + public val id: String, + public val caption: String, + public val header: String, +) { DeprecatedModules("module", "Modules", "Module"), DeprecatedInterfaces("interface", "Interfaces", "Interface"), DeprecatedClasses("class", "Classes", "Class"), @@ -344,10 +357,11 @@ enum class DeprecatedPageSection(val id: String, val caption: String, val header internal fun getPosition() = ordinal } -class IndexPage( - val id: Int, - val elements: List, - val keys: List, +public class IndexPage( + public val id: Int, + public val elements: List, + public val keys: List, + sourceSet: Set ) : JavadocPageNode { @@ -356,7 +370,7 @@ class IndexPage( override val documentables: List = emptyList() override val children: List = emptyList() override val embeddedResources: List = listOf() - val title: String = "${keys[id - 1]}-index" + public val title: String = "${keys[id - 1]}-index" override val content: ContentNode = EmptyNode( DRI.topLevel, @@ -379,14 +393,14 @@ class IndexPage( } -class TreeViewPage( +public class TreeViewPage( override val name: String, - val packages: List?, - val classes: List?, + public val packages: List?, + public val classes: List?, override val dri: Set, override val documentables: List = emptyList(), - val root: PageNode, - val inheritanceBuilder: InheritanceBuilder + public val root: PageNode, + public val inheritanceBuilder: InheritanceBuilder ) : JavadocPageNode { init { assert(packages == null || classes == null) @@ -403,12 +417,12 @@ class TreeViewPage( override val children: List = emptyList() - val title = when (documentables.firstOrNull()) { + public val title: String = when (documentables.firstOrNull()) { is DPackage -> "$name Class Hierarchy" else -> "All packages" } - val kind = when (documentables.firstOrNull()) { + public val kind: String = when (documentables.firstOrNull()) { is DPackage -> "package" else -> "main" } diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt index a9f5b4ae..f54c41fd 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt @@ -18,7 +18,8 @@ import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.transformers.pages.PageTransformer import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin -object ResourcesInstaller : PageTransformer { +public object ResourcesInstaller : PageTransformer { + override fun invoke(input: RootPageNode): RootPageNode = input.modified( children = input.children + RendererSpecificResourcePage( @@ -29,7 +30,10 @@ object ResourcesInstaller : PageTransformer { ) } -class TreeViewInstaller(private val context: DokkaContext) : PageTransformer { +public class TreeViewInstaller( + private val context: DokkaContext +) : PageTransformer { + override fun invoke(input: RootPageNode): RootPageNode = install(input, input) as RootPageNode private fun install(node: PageNode, root: RootPageNode): PageNode = when (node) { @@ -73,7 +77,8 @@ class TreeViewInstaller(private val context: DokkaContext) : PageTransformer { } } -object AllClassesPageInstaller : PageTransformer { +public object AllClassesPageInstaller : PageTransformer { + override fun invoke(input: RootPageNode): RootPageNode { val classes = (input as JavadocModulePageNode).children.filterIsInstance().flatMap { it.children.filterIsInstance() @@ -83,7 +88,8 @@ object AllClassesPageInstaller : PageTransformer { } } -object IndexGenerator : PageTransformer { +public object IndexGenerator : PageTransformer { + override fun invoke(input: RootPageNode): RootPageNode { val elements = HashMap>() (input as JavadocModulePageNode).children.filterIsInstance().forEach { @@ -125,7 +131,8 @@ object IndexGenerator : PageTransformer { } } -object DeprecatedPageCreator : PageTransformer { +public object DeprecatedPageCreator : PageTransformer { + override fun invoke(input: RootPageNode): RootPageNode { val elements = HashMap>().apply { diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToHtmlTranslator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToHtmlTranslator.kt index bcf16dcb..7b54488a 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToHtmlTranslator.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToHtmlTranslator.kt @@ -31,7 +31,7 @@ internal class JavadocContentToHtmlTranslator( else -> "" } - fun htmlForText(node: ContentText): String { + private fun htmlForText(node: ContentText): String { val escapedText = node.text.htmlEscape() return when { node.style.contains(ContentStyle.InDocumentationAnchor) -> """${escapedText}""" diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt index daa53e11..658e42ed 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt @@ -29,10 +29,11 @@ import org.jetbrains.dokka.renderers.Renderer import org.jetbrains.dokka.analysis.kotlin.internal.InheritanceNode import java.time.LocalDate -typealias TemplateMap = Map +public typealias TemplateMap = Map -class KorteJavadocRenderer(val context: DokkaContext, resourceDir: String) : - Renderer { +public class KorteJavadocRenderer( + public val context: DokkaContext, resourceDir: String +) : Renderer { private val outputWriter: OutputWriter = context.plugin().querySingle { outputWriter } private lateinit var locationProvider: JavadocLocationProvider private val registeredPreprocessors = context.plugin().query { javadocPreprocessors } @@ -45,11 +46,13 @@ class KorteJavadocRenderer(val context: DokkaContext, resourceDir: String) : JavadocContentToTemplateMapTranslator(locationProvider, context) } - override fun render(root: RootPageNode) = root.let { registeredPreprocessors.fold(root) { r, t -> t.invoke(r) } }.let { newRoot -> - locationProvider = context.plugin().querySingle { locationProviderFactory }.getLocationProvider(newRoot) as JavadocLocationProvider - runBlocking(Dispatchers.IO) { - renderPage(newRoot) - SearchScriptsCreator(locationProvider).invoke(newRoot).forEach { renderSpecificPage(it, "") } + override fun render(root: RootPageNode) { + root.let { registeredPreprocessors.fold(root) { r, t -> t.invoke(r) } }.let { newRoot -> + locationProvider = context.plugin().querySingle { locationProviderFactory }.getLocationProvider(newRoot) as JavadocLocationProvider + runBlocking(Dispatchers.IO) { + renderPage(newRoot) + SearchScriptsCreator(locationProvider).invoke(newRoot).forEach { renderSpecificPage(it, "") } + } } } diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt index 2107ab2d..af91a01d 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt @@ -15,9 +15,11 @@ import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.utilities.formatToEndWithHtml -class SearchScriptsCreator(private val locationProvider: LocationProvider) { +public class SearchScriptsCreator( + private val locationProvider: LocationProvider +) { - fun invoke(input: RootPageNode): List { + public fun invoke(input: RootPageNode): List { val data = when (input) { is JavadocModulePageNode -> processModules(listOf(input)) else -> processModules(input.children.filterIsInstance()) diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt index d0e39f8f..e3510686 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt @@ -23,12 +23,16 @@ import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.utilities.DokkaLogger -class JavadocSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogger) : SignatureProvider, - JvmSignatureUtils by JavaSignatureUtils { - constructor(context: DokkaContext) : this( +public class JavadocSignatureProvider( + ctcc: CommentsToContentConverter, + logger: DokkaLogger +) : SignatureProvider, JvmSignatureUtils by JavaSignatureUtils { + + public constructor(context: DokkaContext) : this( context.plugin().querySingle { commentsToContentConverter }, context.logger ) + private val contentBuilder = JavadocPageContentBuilder(ctcc, this, logger) private val ignoredVisibilities = setOf(JavaVisibility.Default) diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/transformers/documentables/JavadocDocumentableJVMSourceSetFilter.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/transformers/documentables/JavadocDocumentableJVMSourceSetFilter.kt index 4a6f415d..0ab5280e 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/transformers/documentables/JavadocDocumentableJVMSourceSetFilter.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/transformers/documentables/JavadocDocumentableJVMSourceSetFilter.kt @@ -10,7 +10,9 @@ import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer -class JavadocDocumentableJVMSourceSetFilter(val context: DokkaContext) : PreMergeDocumentableTransformer { +public class JavadocDocumentableJVMSourceSetFilter( + public val context: DokkaContext +) : PreMergeDocumentableTransformer { private val allowedSourceSets = context.configuration.sourceSets.filter { it.analysisPlatform == Platform.jvm } .flatMap { it.getAllDependentSourceSets() }.distinct() diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/translators/documentables/JavadocPageContentBuilder.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/translators/documentables/JavadocPageContentBuilder.kt index c622d7d1..9746376b 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/translators/documentables/JavadocPageContentBuilder.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/translators/documentables/JavadocPageContentBuilder.kt @@ -15,13 +15,13 @@ import org.jetbrains.dokka.pages.ContentKind import org.jetbrains.dokka.pages.ContentNode import org.jetbrains.dokka.utilities.DokkaLogger -class JavadocPageContentBuilder( +public class JavadocPageContentBuilder( commentsConverter: CommentsToContentConverter, signatureProvider: SignatureProvider, logger: DokkaLogger ) : PageContentBuilder(commentsConverter, signatureProvider, logger) { - fun PageContentBuilder.DocumentableContentBuilder.javadocGroup( + public fun PageContentBuilder.DocumentableContentBuilder.javadocGroup( dri: DRI = mainDRI.first(), sourceSets: Set = mainSourcesetData, extra: PropertyContainer = mainExtra, @@ -34,31 +34,31 @@ class JavadocPageContentBuilder( ).apply(block).build() } - open inner class JavadocContentBuilder( + public open inner class JavadocContentBuilder( private val mainDri: DRI, private val mainExtra: PropertyContainer, private val mainSourceSet: Set, ) { - var annotations: ContentNode? = null - var modifiers: ContentNode? = null - var signatureWithoutModifiers: ContentNode? = null - var supertypes: ContentNode? = null + public var annotations: ContentNode? = null + public var modifiers: ContentNode? = null + public var signatureWithoutModifiers: ContentNode? = null + public var supertypes: ContentNode? = null - fun annotations(block: PageContentBuilder.DocumentableContentBuilder.() -> Unit) { + public fun annotations(block: PageContentBuilder.DocumentableContentBuilder.() -> Unit) { val built = buildContentForBlock(block) if(built.hasAnyContent()) annotations = built } - fun modifiers(block: PageContentBuilder.DocumentableContentBuilder.() -> Unit) { + public fun modifiers(block: PageContentBuilder.DocumentableContentBuilder.() -> Unit) { val built = buildContentForBlock(block) if(built.hasAnyContent()) modifiers = built } - fun signatureWithoutModifiers(block: PageContentBuilder.DocumentableContentBuilder.() -> Unit) { + public fun signatureWithoutModifiers(block: PageContentBuilder.DocumentableContentBuilder.() -> Unit) { signatureWithoutModifiers = buildContentForBlock(block) } - fun supertypes(block: PageContentBuilder.DocumentableContentBuilder.() -> Unit) { + public fun supertypes(block: PageContentBuilder.DocumentableContentBuilder.() -> Unit) { val built = buildContentForBlock(block) if(built.hasAnyContent()) supertypes = built } @@ -72,7 +72,7 @@ class JavadocPageContentBuilder( block = block ) - fun build(): JavadocSignatureContentNode = JavadocSignatureContentNode( + public fun build(): JavadocSignatureContentNode = JavadocSignatureContentNode( dri = mainDri, annotations = annotations, modifiers = modifiers, diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/validity/MultiplatformConfiguredChecker.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/validity/MultiplatformConfiguredChecker.kt index 8b84e39a..7ecd6757 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/validity/MultiplatformConfiguredChecker.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/validity/MultiplatformConfiguredChecker.kt @@ -9,7 +9,9 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.validity.PreGenerationChecker import org.jetbrains.dokka.validity.PreGenerationCheckerOutput -class MultiplatformConfiguredChecker(val context: DokkaContext) : PreGenerationChecker { +public class MultiplatformConfiguredChecker( + public val context: DokkaContext +) : PreGenerationChecker { override fun invoke(): PreGenerationCheckerOutput { val isSinglePlatform = context.configuration.sourceSets.all { sourceSet -> @@ -19,8 +21,8 @@ class MultiplatformConfiguredChecker(val context: DokkaContext) : PreGenerationC return PreGenerationCheckerOutput(isSinglePlatform, listOfNotNull(errorMessage.takeUnless { isSinglePlatform })) } - companion object { - const val errorMessage = + public companion object { + public const val errorMessage: String = "Dokka Javadoc plugin currently does not support generating documentation for multiplatform project. Please, adjust your configuration" } } -- cgit