diff options
Diffstat (limited to 'plugins')
181 files changed, 1664 insertions, 1292 deletions
diff --git a/plugins/all-modules-page/api/all-modules-page.api b/plugins/all-modules-page/api/all-modules-page.api index 0763d75a..3e6dc898 100644 --- a/plugins/all-modules-page/api/all-modules-page.api +++ b/plugins/all-modules-page/api/all-modules-page.api @@ -30,7 +30,6 @@ public final class org/jetbrains/dokka/allModulesPage/AllModulesPagePlugin : org public final fun getAllModulesPageGeneration ()Lorg/jetbrains/dokka/plugability/Extension; public final fun getAllModulesPageTransformer ()Lorg/jetbrains/dokka/plugability/ExtensionPoint; public final fun getBaseLocationProviderFactory ()Lorg/jetbrains/dokka/plugability/Extension; - public final fun getDokkaBase ()Lorg/jetbrains/dokka/base/DokkaBase; public final fun getExternalModuleLinkResolver ()Lorg/jetbrains/dokka/plugability/ExtensionPoint; public final fun getMultiModuleLinkResolver ()Lorg/jetbrains/dokka/plugability/Extension; public final fun getMultimoduleLocationProvider ()Lorg/jetbrains/dokka/plugability/Extension; @@ -62,8 +61,7 @@ public class org/jetbrains/dokka/allModulesPage/MultimoduleLocationProvider : or public final class org/jetbrains/dokka/allModulesPage/MultimoduleLocationProvider$Factory : org/jetbrains/dokka/base/resolvers/local/LocationProviderFactory { public fun <init> (Lorg/jetbrains/dokka/plugability/DokkaContext;)V - public fun getLocationProvider (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/allModulesPage/MultimoduleLocationProvider; - public synthetic fun getLocationProvider (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/base/resolvers/local/LocationProvider; + public fun getLocationProvider (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/base/resolvers/local/LocationProvider; } public final class org/jetbrains/dokka/allModulesPage/MultimodulePageCreator : org/jetbrains/dokka/transformers/pages/PageCreator { diff --git a/plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt b/plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt index ea009c9e..11d2d32c 100644 --- a/plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt +++ b/plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt @@ -16,7 +16,7 @@ import org.jetbrains.dokka.templates.TemplatingPlugin import org.jetbrains.dokka.templates.TemplatingResult import org.jetbrains.dokka.transformers.pages.CreationContext -class AllModulesPageGeneration(private val context: DokkaContext) : Generation { +public class AllModulesPageGeneration(private val context: DokkaContext) : Generation { private val allModulesPagePlugin by lazy { context.plugin<AllModulesPagePlugin>() } private val templatingPlugin by lazy { context.plugin<TemplatingPlugin>() } @@ -44,34 +44,37 @@ class AllModulesPageGeneration(private val context: DokkaContext) : Generation { runPostActions() } - override val generationName = "index page for project" + override val generationName: String = "index page for project" - fun createAllModulesPage(allModulesContext: DefaultAllModulesContext) = + public fun createAllModulesPage(allModulesContext: DefaultAllModulesContext): RootPageNode = allModulesPagePlugin.querySingle { allModulesPageCreator }.invoke(allModulesContext) - fun transformAllModulesPage(pages: RootPageNode) = + public fun transformAllModulesPage(pages: RootPageNode): RootPageNode = allModulesPagePlugin.query { allModulesPageTransformer }.fold(pages) { acc, t -> t(acc) } - fun render(transformedPages: RootPageNode) { + public fun render(transformedPages: RootPageNode) { context.single(CoreExtensions.renderer).render(transformedPages) } - fun runPostActions() { + public fun runPostActions() { context[CoreExtensions.postActions].forEach { it() } } - fun processSubmodules() = - templatingPlugin.querySingle { submoduleTemplateProcessor } + public fun processSubmodules(): DefaultAllModulesContext { + return templatingPlugin.querySingle { submoduleTemplateProcessor } .process(context.configuration.modules) .let { DefaultAllModulesContext(it) } + } - fun processMultiModule(root: RootPageNode) = + public fun processMultiModule(root: RootPageNode) { templatingPlugin.querySingle { multimoduleTemplateProcessor }.process(root) + } - fun finishProcessingSubmodules() = + public fun finishProcessingSubmodules() { templatingPlugin.query { templateProcessingStrategy }.forEach { it.finish(context.configuration.outputDir) } + } - data class DefaultAllModulesContext(val nonEmptyModules: List<String>) : CreationContext { - constructor(templating: TemplatingResult) : this(templating.modules) + public data class DefaultAllModulesContext(val nonEmptyModules: List<String>) : CreationContext { + public constructor(templating: TemplatingResult) : this(templating.modules) } } diff --git a/plugins/all-modules-page/src/main/kotlin/AllModulesPagePlugin.kt b/plugins/all-modules-page/src/main/kotlin/AllModulesPagePlugin.kt index dec818ba..06202082 100644 --- a/plugins/all-modules-page/src/main/kotlin/AllModulesPagePlugin.kt +++ b/plugins/all-modules-page/src/main/kotlin/AllModulesPagePlugin.kt @@ -8,47 +8,47 @@ import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProviderFactory import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory -import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.plugability.DokkaPluginApiPreview -import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement +import org.jetbrains.dokka.generation.Generation +import org.jetbrains.dokka.plugability.* +import org.jetbrains.dokka.templates.CommandHandler import org.jetbrains.dokka.templates.TemplatingPlugin import org.jetbrains.dokka.transformers.pages.PageCreator import org.jetbrains.dokka.transformers.pages.PageTransformer -class AllModulesPagePlugin : DokkaPlugin() { +public class AllModulesPagePlugin : DokkaPlugin() { - val partialLocationProviderFactory by extensionPoint<LocationProviderFactory>() - val allModulesPageCreator by extensionPoint<PageCreator<AllModulesPageGeneration.DefaultAllModulesContext>>() - val allModulesPageTransformer by extensionPoint<PageTransformer>() - val externalModuleLinkResolver by extensionPoint<ExternalModuleLinkResolver>() + public val partialLocationProviderFactory: ExtensionPoint<LocationProviderFactory> by extensionPoint() + public val allModulesPageCreator: ExtensionPoint<PageCreator<AllModulesPageGeneration.DefaultAllModulesContext>> by extensionPoint() + public val allModulesPageTransformer: ExtensionPoint<PageTransformer> by extensionPoint() + public val externalModuleLinkResolver: ExtensionPoint<ExternalModuleLinkResolver> by extensionPoint() - val allModulesPageCreators by extending { + public val allModulesPageCreators: Extension<PageCreator<AllModulesPageGeneration.DefaultAllModulesContext>, *, *> by extending { allModulesPageCreator providing ::MultimodulePageCreator } - val dokkaBase by lazy { plugin<DokkaBase>() } + private val dokkaBase: DokkaBase by lazy { plugin<DokkaBase>() } - val multimoduleLocationProvider by extending { + public val multimoduleLocationProvider: Extension<LocationProviderFactory, *, *> by extending { (dokkaBase.locationProviderFactory providing MultimoduleLocationProvider::Factory override plugin<DokkaBase>().locationProvider) } - val baseLocationProviderFactory by extending { + public val baseLocationProviderFactory: Extension<LocationProviderFactory, *, *> by extending { partialLocationProviderFactory providing ::DokkaLocationProviderFactory } - val allModulesPageGeneration by extending { + public val allModulesPageGeneration: Extension<Generation, *, *> by extending { (CoreExtensions.generation providing ::AllModulesPageGeneration override dokkaBase.singleGeneration) } - val resolveLinkCommandHandler by extending { + public val resolveLinkCommandHandler: Extension<CommandHandler, *, *> by extending { plugin<TemplatingPlugin>().directiveBasedCommandHandlers providing ::ResolveLinkCommandHandler } - val multiModuleLinkResolver by extending { + public val multiModuleLinkResolver: Extension<ExternalModuleLinkResolver, *, *> by extending { externalModuleLinkResolver providing ::DefaultExternalModuleLinkResolver } diff --git a/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt b/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt index f7b7cac4..da747bda 100644 --- a/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt +++ b/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt @@ -16,12 +16,14 @@ import org.jetbrains.dokka.plugability.query import java.io.File import java.net.URL -interface ExternalModuleLinkResolver { - fun resolve(dri: DRI, fileContext: File): String? - fun resolveLinkToModuleIndex(moduleName: String): String? +public interface ExternalModuleLinkResolver { + public fun resolve(dri: DRI, fileContext: File): String? + public fun resolveLinkToModuleIndex(moduleName: String): String? } -class DefaultExternalModuleLinkResolver(val context: DokkaContext) : ExternalModuleLinkResolver { +public class DefaultExternalModuleLinkResolver( + public val context: DokkaContext +) : ExternalModuleLinkResolver { private val elpFactory = context.plugin<DokkaBase>().query { externalLocationProviderFactory } private val externalDocumentations by lazy(::setupExternalDocumentations) private val elps by lazy { diff --git a/plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt b/plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt index cfd0d675..b0fa13d0 100644 --- a/plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt +++ b/plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt @@ -6,6 +6,7 @@ package org.jetbrains.dokka.allModulesPage import org.jetbrains.dokka.allModulesPage.MultimodulePageCreator.Companion.MULTIMODULE_PACKAGE_PLACEHOLDER import org.jetbrains.dokka.base.resolvers.local.DokkaBaseLocationProvider +import org.jetbrains.dokka.base.resolvers.local.LocationProvider import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.DisplaySourceSet @@ -16,9 +17,10 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.querySingle -open class MultimoduleLocationProvider(private val root: RootPageNode, dokkaContext: DokkaContext, - val extension: String = ".html") : - DokkaBaseLocationProvider(root, dokkaContext) { +public open class MultimoduleLocationProvider( + private val root: RootPageNode, dokkaContext: DokkaContext, + public val extension: String = ".html" +) : DokkaBaseLocationProvider(root, dokkaContext) { private val defaultLocationProvider = dokkaContext.plugin<AllModulesPagePlugin>().querySingle { partialLocationProviderFactory } @@ -26,21 +28,32 @@ open class MultimoduleLocationProvider(private val root: RootPageNode, dokkaCont private val externalModuleLinkResolver = dokkaContext.plugin<AllModulesPagePlugin>().querySingle { externalModuleLinkResolver } - override fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode?) = - if (dri == MultimodulePageCreator.MULTIMODULE_ROOT_DRI) pathToRoot(root) + "index" - else dri.takeIf { it.packageName == MULTIMODULE_PACKAGE_PLACEHOLDER }?.classNames - ?.let(externalModuleLinkResolver::resolveLinkToModuleIndex) + override fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode?): String? { + return if (dri == MultimodulePageCreator.MULTIMODULE_ROOT_DRI) { + pathToRoot(root) + "index" + } else { + dri.takeIf { it.packageName == MULTIMODULE_PACKAGE_PLACEHOLDER } + ?.classNames + ?.let(externalModuleLinkResolver::resolveLinkToModuleIndex) + } + } - override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean) = - if (node is ContentPage && MultimodulePageCreator.MULTIMODULE_ROOT_DRI in node.dri) pathToRoot(root) + "index" + if (!skipExtension) extension else "" - else defaultLocationProvider.resolve(node, context, skipExtension) + override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean): String? { + return if (node is ContentPage && MultimodulePageCreator.MULTIMODULE_ROOT_DRI in node.dri) { + pathToRoot(root) + "index" + if (!skipExtension) extension else "" + } else { + defaultLocationProvider.resolve(node, context, skipExtension) + } + } override fun pathToRoot(from: PageNode): String = defaultLocationProvider.pathToRoot(from) override fun ancestors(node: PageNode): List<PageNode> = listOf(root) - class Factory(private val context: DokkaContext) : LocationProviderFactory { - override fun getLocationProvider(pageNode: RootPageNode) = + public class Factory( + private val context: DokkaContext + ) : LocationProviderFactory { + override fun getLocationProvider(pageNode: RootPageNode): LocationProvider = MultimoduleLocationProvider(pageNode, context) } } diff --git a/plugins/all-modules-page/src/main/kotlin/MultimodulePageCreator.kt b/plugins/all-modules-page/src/main/kotlin/MultimodulePageCreator.kt index 6fbec587..7b832d21 100644 --- a/plugins/all-modules-page/src/main/kotlin/MultimodulePageCreator.kt +++ b/plugins/all-modules-page/src/main/kotlin/MultimodulePageCreator.kt @@ -25,11 +25,9 @@ import org.jetbrains.dokka.utilities.DokkaLogger import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin import java.io.File -class MultimodulePageCreator( +public class MultimodulePageCreator( private val context: DokkaContext, ) : PageCreator<AllModulesPageGeneration.DefaultAllModulesContext> { - private val logger: DokkaLogger = context.logger - private val commentsConverter by lazy { context.plugin<DokkaBase>().querySingle { commentsToContentConverter } } private val signatureProvider by lazy { context.plugin<DokkaBase>().querySingle { signatureProvider } } private val moduleDocumentationReader by lazy { context.plugin<InternalKotlinAnalysisPlugin>().querySingle { moduleAndPackageDocumentationReader } } @@ -109,8 +107,9 @@ class MultimodulePageCreator( else firstChildParagraph } - companion object { - const val MULTIMODULE_PACKAGE_PLACEHOLDER = ".ext" - val MULTIMODULE_ROOT_DRI = DRI(packageName = MULTIMODULE_PACKAGE_PLACEHOLDER, classNames = "allModules") + public companion object { + public const val MULTIMODULE_PACKAGE_PLACEHOLDER: String = ".ext" + public val MULTIMODULE_ROOT_DRI: DRI = + DRI(packageName = MULTIMODULE_PACKAGE_PLACEHOLDER, classNames = "allModules") } } diff --git a/plugins/all-modules-page/src/main/kotlin/ResolveLinkCommandHandler.kt b/plugins/all-modules-page/src/main/kotlin/ResolveLinkCommandHandler.kt index 9720199c..f6d34271 100644 --- a/plugins/all-modules-page/src/main/kotlin/ResolveLinkCommandHandler.kt +++ b/plugins/all-modules-page/src/main/kotlin/ResolveLinkCommandHandler.kt @@ -15,7 +15,7 @@ import org.jsoup.nodes.Element import org.jsoup.parser.Tag import java.io.File -class ResolveLinkCommandHandler(context: DokkaContext) : CommandHandler { +public class ResolveLinkCommandHandler(context: DokkaContext) : CommandHandler { private val externalModuleLinkResolver = context.plugin<AllModulesPagePlugin>().querySingle { externalModuleLinkResolver } diff --git a/plugins/android-documentation/src/main/kotlin/AndroidDocumentationPlugin.kt b/plugins/android-documentation/src/main/kotlin/AndroidDocumentationPlugin.kt index 039f2485..089a19a4 100644 --- a/plugins/android-documentation/src/main/kotlin/AndroidDocumentationPlugin.kt +++ b/plugins/android-documentation/src/main/kotlin/AndroidDocumentationPlugin.kt @@ -8,12 +8,15 @@ import org.jetbrains.dokka.android.transformers.HideTagDocumentableFilter import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.plugability.DokkaPluginApiPreview +import org.jetbrains.dokka.plugability.Extension import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement +import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer + +public class AndroidDocumentationPlugin : DokkaPlugin() { -class AndroidDocumentationPlugin : DokkaPlugin() { private val dokkaBase by lazy { plugin<DokkaBase>() } - val suppressedByHideTagDocumentableFilter by extending { + public val suppressedByHideTagDocumentableFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending { dokkaBase.preMergeDocumentableTransformer providing ::HideTagDocumentableFilter order { before(dokkaBase.emptyPackagesFilter) } } diff --git a/plugins/android-documentation/src/main/kotlin/transformers/HideTagDocumentableFilter.kt b/plugins/android-documentation/src/main/kotlin/transformers/HideTagDocumentableFilter.kt index d746e7a1..ec05efc5 100644 --- a/plugins/android-documentation/src/main/kotlin/transformers/HideTagDocumentableFilter.kt +++ b/plugins/android-documentation/src/main/kotlin/transformers/HideTagDocumentableFilter.kt @@ -10,7 +10,7 @@ import org.jetbrains.dokka.model.dfs import org.jetbrains.dokka.model.doc.CustomTagWrapper import org.jetbrains.dokka.plugability.DokkaContext -class HideTagDocumentableFilter(val dokkaContext: DokkaContext) : +public class HideTagDocumentableFilter(public val dokkaContext: DokkaContext) : SuppressedByConditionDocumentableFilterTransformer(dokkaContext) { override fun shouldBeSuppressed(d: Documentable): Boolean = diff --git a/plugins/base/api/base.api b/plugins/base/api/base.api index fb55fe94..360073fe 100644 --- a/plugins/base/api/base.api +++ b/plugins/base/api/base.api @@ -1,7 +1,6 @@ public final class org/jetbrains/dokka/analysis/AnalysisContext : java/io/Closeable { public fun <init> (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - public fun close ()Ljava/lang/Void; - public synthetic fun close ()V + public fun close ()V public final fun component1 ()Ljava/lang/Object; public final fun component2 ()Ljava/lang/Object; public final fun getEnvironment ()Ljava/lang/Object; @@ -277,8 +276,7 @@ public final class org/jetbrains/dokka/base/renderers/PackageListService$Compani public final class org/jetbrains/dokka/base/renderers/RootCreator : org/jetbrains/dokka/transformers/pages/PageTransformer { public static final field INSTANCE Lorg/jetbrains/dokka/base/renderers/RootCreator; - public fun invoke (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/pages/RendererSpecificRootPage; - public synthetic fun invoke (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/pages/RootPageNode; + public fun invoke (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/pages/RootPageNode; } public abstract interface class org/jetbrains/dokka/base/renderers/TabSortingStrategy { @@ -412,8 +410,7 @@ public final class org/jetbrains/dokka/base/renderers/html/NavigationPage : org/ public final fun getModuleName ()Ljava/lang/String; public fun getName ()Ljava/lang/String; public final fun getRoot ()Lorg/jetbrains/dokka/base/renderers/html/NavigationNode; - public fun getStrategy ()Lorg/jetbrains/dokka/pages/RenderingStrategy$Callback; - public synthetic fun getStrategy ()Lorg/jetbrains/dokka/pages/RenderingStrategy; + public fun getStrategy ()Lorg/jetbrains/dokka/pages/RenderingStrategy; public fun modified (Ljava/lang/String;Ljava/util/List;)Lorg/jetbrains/dokka/base/renderers/html/NavigationPage; public synthetic fun modified (Ljava/lang/String;Ljava/util/List;)Lorg/jetbrains/dokka/pages/PageNode; } @@ -1103,7 +1100,7 @@ public final class org/jetbrains/dokka/base/transformers/documentables/CallableE public final class org/jetbrains/dokka/base/transformers/documentables/CallableExtensions$Key : org/jetbrains/dokka/model/properties/ExtraProperty$Key { public synthetic fun mergeStrategyFor (Ljava/lang/Object;Ljava/lang/Object;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; - public fun mergeStrategyFor (Lorg/jetbrains/dokka/base/transformers/documentables/CallableExtensions;Lorg/jetbrains/dokka/base/transformers/documentables/CallableExtensions;)Lorg/jetbrains/dokka/model/properties/MergeStrategy$Replace; + public fun mergeStrategyFor (Lorg/jetbrains/dokka/base/transformers/documentables/CallableExtensions;Lorg/jetbrains/dokka/base/transformers/documentables/CallableExtensions;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; } public final class org/jetbrains/dokka/base/transformers/documentables/ClashingDriIdentifier : org/jetbrains/dokka/model/properties/ExtraProperty { @@ -1504,8 +1501,8 @@ public class org/jetbrains/dokka/base/translators/documentables/PageContentBuild public static synthetic fun link$default (Lorg/jetbrains/dokka/base/translators/documentables/PageContentBuilder$DocumentableContentBuilder;Ljava/lang/String;Ljava/lang/String;Lorg/jetbrains/dokka/pages/Kind;Ljava/util/Set;Ljava/util/Set;Lorg/jetbrains/dokka/model/properties/PropertyContainer;ILjava/lang/Object;)V public static synthetic fun link$default (Lorg/jetbrains/dokka/base/translators/documentables/PageContentBuilder$DocumentableContentBuilder;Ljava/lang/String;Lorg/jetbrains/dokka/links/DRI;Lorg/jetbrains/dokka/pages/Kind;Ljava/util/Set;Ljava/util/Set;Lorg/jetbrains/dokka/model/properties/PropertyContainer;ILjava/lang/Object;)V public static synthetic fun link$default (Lorg/jetbrains/dokka/base/translators/documentables/PageContentBuilder$DocumentableContentBuilder;Lorg/jetbrains/dokka/links/DRI;Lorg/jetbrains/dokka/pages/Kind;Ljava/util/Set;Ljava/util/Set;Lorg/jetbrains/dokka/model/properties/PropertyContainer;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V - public final fun linkNode (Ljava/lang/String;Lorg/jetbrains/dokka/links/DRI;Lorg/jetbrains/dokka/pages/DCI;Ljava/util/Set;Ljava/util/Set;Lorg/jetbrains/dokka/model/properties/PropertyContainer;)Lorg/jetbrains/dokka/pages/ContentDRILink; - public static synthetic fun linkNode$default (Lorg/jetbrains/dokka/base/translators/documentables/PageContentBuilder$DocumentableContentBuilder;Ljava/lang/String;Lorg/jetbrains/dokka/links/DRI;Lorg/jetbrains/dokka/pages/DCI;Ljava/util/Set;Ljava/util/Set;Lorg/jetbrains/dokka/model/properties/PropertyContainer;ILjava/lang/Object;)Lorg/jetbrains/dokka/pages/ContentDRILink; + public final fun linkNode (Ljava/lang/String;Lorg/jetbrains/dokka/links/DRI;Lorg/jetbrains/dokka/pages/DCI;Ljava/util/Set;Ljava/util/Set;Lorg/jetbrains/dokka/model/properties/PropertyContainer;)Lorg/jetbrains/dokka/pages/ContentLink; + public static synthetic fun linkNode$default (Lorg/jetbrains/dokka/base/translators/documentables/PageContentBuilder$DocumentableContentBuilder;Ljava/lang/String;Lorg/jetbrains/dokka/links/DRI;Lorg/jetbrains/dokka/pages/DCI;Ljava/util/Set;Ljava/util/Set;Lorg/jetbrains/dokka/model/properties/PropertyContainer;ILjava/lang/Object;)Lorg/jetbrains/dokka/pages/ContentLink; public final fun list (Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;Lkotlin/jvm/functions/Function2;)V public static synthetic fun list$default (Lorg/jetbrains/dokka/base/translators/documentables/PageContentBuilder$DocumentableContentBuilder;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)V public final fun multiBlock (Ljava/lang/String;ILorg/jetbrains/dokka/pages/Kind;Ljava/lang/Iterable;Ljava/util/Set;Ljava/util/Set;Lorg/jetbrains/dokka/model/properties/PropertyContainer;ZZLjava/util/List;ZLkotlin/jvm/functions/Function3;)V diff --git a/plugins/base/base-test-utils/src/main/kotlin/renderers/JsoupUtils.kt b/plugins/base/base-test-utils/src/main/kotlin/renderers/JsoupUtils.kt index 9a715e39..fcd73ff0 100644 --- a/plugins/base/base-test-utils/src/main/kotlin/renderers/JsoupUtils.kt +++ b/plugins/base/base-test-utils/src/main/kotlin/renderers/JsoupUtils.kt @@ -8,7 +8,7 @@ import org.jsoup.nodes.Element import org.jsoup.nodes.Node import org.jsoup.nodes.TextNode -fun Element.match(vararg matchers: Any, ignoreSpanWithTokenStyle:Boolean = false): Unit = +public fun Element.match(vararg matchers: Any, ignoreSpanWithTokenStyle:Boolean = false): Unit = childNodes() .let { list -> if(ignoreSpanWithTokenStyle) { @@ -25,25 +25,28 @@ fun Element.match(vararg matchers: Any, ignoreSpanWithTokenStyle:Boolean = false .zip(matchers) .forEach { (n, m) -> m.accepts(n, ignoreSpan = ignoreSpanWithTokenStyle) } -open class Tag(val name: String, vararg val matchers: Any, val expectedClasses: List<String> = emptyList()) -class Div(vararg matchers: Any) : Tag("div", *matchers) -class P(vararg matchers: Any) : Tag("p", *matchers) -class Span(vararg matchers: Any) : Tag("span", *matchers) -class A(vararg matchers: Any) : Tag("a", *matchers) -class B(vararg matchers: Any) : Tag("b", *matchers) -class I(vararg matchers: Any) : Tag("i", *matchers) -class STRIKE(vararg matchers: Any) : Tag("strike", *matchers) +public open class Tag( + public val name: String, + public vararg val matchers: Any, + public val expectedClasses: List<String> = emptyList() +) +public class Div(vararg matchers: Any) : Tag("div", *matchers) +public class P(vararg matchers: Any) : Tag("p", *matchers) +public class Span(vararg matchers: Any) : Tag("span", *matchers) +public class A(vararg matchers: Any) : Tag("a", *matchers) +public class B(vararg matchers: Any) : Tag("b", *matchers) +public class I(vararg matchers: Any) : Tag("i", *matchers) +public class STRIKE(vararg matchers: Any) : Tag("strike", *matchers) +public class BlockQuote(vararg matchers: Any) : Tag("blockquote", *matchers) +public class Dl(vararg matchers: Any) : Tag("dl", *matchers) +public class Dt(vararg matchers: Any) : Tag("dt", *matchers) +public class Dd(vararg matchers: Any) : Tag("dd", *matchers) +public class Var(vararg matchers: Any) : Tag("var", *matchers) +public class U(vararg matchers: Any) : Tag("u", *matchers) +public object Wbr : Tag("wbr") +public object Br : Tag("br") -class BlockQuote(vararg matchers: Any) : Tag("blockquote", *matchers) -class Dl(vararg matchers: Any) : Tag("dl", *matchers) -class Dt(vararg matchers: Any) : Tag("dt", *matchers) -class Dd(vararg matchers: Any) : Tag("dd", *matchers) -class Var(vararg matchers: Any) : Tag("var", *matchers) -class U(vararg matchers: Any) : Tag("u", *matchers) -object Wbr : Tag("wbr") -object Br : Tag("br") - -fun Tag.withClasses(vararg classes: String) = Tag(name, *matchers, expectedClasses = classes.toList()) +public fun Tag.withClasses(vararg classes: String): Tag = Tag(name, *matchers, expectedClasses = classes.toList()) private fun Any.accepts(n: Node, ignoreSpan:Boolean = true) { when (this) { diff --git a/plugins/base/base-test-utils/src/main/kotlin/renderers/RenderingOnlyTestBase.kt b/plugins/base/base-test-utils/src/main/kotlin/renderers/RenderingOnlyTestBase.kt index cc050d0f..d2ff3ad4 100644 --- a/plugins/base/base-test-utils/src/main/kotlin/renderers/RenderingOnlyTestBase.kt +++ b/plugins/base/base-test-utils/src/main/kotlin/renderers/RenderingOnlyTestBase.kt @@ -6,7 +6,7 @@ package renderers import org.jetbrains.dokka.testApi.context.MockContext -abstract class RenderingOnlyTestBase<T> { - abstract val context: MockContext - abstract val renderedContent: T +public abstract class RenderingOnlyTestBase<T> { + public abstract val context: MockContext + public abstract val renderedContent: T } diff --git a/plugins/base/base-test-utils/src/main/kotlin/renderers/SignatureUtils.kt b/plugins/base/base-test-utils/src/main/kotlin/renderers/SignatureUtils.kt index da4cd732..ecbe809b 100644 --- a/plugins/base/base-test-utils/src/main/kotlin/renderers/SignatureUtils.kt +++ b/plugins/base/base-test-utils/src/main/kotlin/renderers/SignatureUtils.kt @@ -10,14 +10,14 @@ import org.jsoup.select.Elements import utils.Tag import utils.TestOutputWriter -fun TestOutputWriter.renderedContent(path: String = "root/example.html"): Element = +public fun TestOutputWriter.renderedContent(path: String = "root/example.html"): Element = contents.getValue(path).let { Jsoup.parse(it) }.select("#content") .single() -fun Element.signature(): Elements = select("div.symbol.monospace") -fun Element.tab(tabName: String): Elements = select("div[data-togglable=\"$tabName\"]") -fun Element.firstSignature(): Element = signature().first() ?: throw NoSuchElementException("No signature found") -fun Element.lastSignature(): Element = signature().last() ?: throw NoSuchElementException("No signature found") +public fun Element.signature(): Elements = select("div.symbol.monospace") +public fun Element.tab(tabName: String): Elements = select("div[data-togglable=\"$tabName\"]") +public fun Element.firstSignature(): Element = signature().first() ?: throw NoSuchElementException("No signature found") +public fun Element.lastSignature(): Element = signature().last() ?: throw NoSuchElementException("No signature found") -class Parameters(vararg matchers: Any) : Tag("span", *matchers, expectedClasses = listOf("parameters")) -class Parameter(vararg matchers: Any) : Tag("span", *matchers, expectedClasses = listOf("parameter")) +public class Parameters(vararg matchers: Any) : Tag("span", *matchers, expectedClasses = listOf("parameters")) +public class Parameter(vararg matchers: Any) : Tag("span", *matchers, expectedClasses = listOf("parameter")) diff --git a/plugins/base/base-test-utils/src/main/kotlin/renderers/TestPage.kt b/plugins/base/base-test-utils/src/main/kotlin/renderers/TestPage.kt index c5615f9b..6fb484bf 100644 --- a/plugins/base/base-test-utils/src/main/kotlin/renderers/TestPage.kt +++ b/plugins/base/base-test-utils/src/main/kotlin/renderers/TestPage.kt @@ -15,7 +15,7 @@ import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.utilities.DokkaConsoleLogger import org.jetbrains.dokka.utilities.LoggingLevel -fun testPage(callback: PageContentBuilder.DocumentableContentBuilder.() -> Unit): RawTestPage { +public fun testPage(callback: PageContentBuilder.DocumentableContentBuilder.() -> Unit): RawTestPage { val content = PageContentBuilder( EmptyCommentConverter, KotlinSignatureProvider(EmptyCommentConverter, DokkaConsoleLogger(LoggingLevel.DEBUG)), @@ -29,7 +29,7 @@ fun testPage(callback: PageContentBuilder.DocumentableContentBuilder.() -> Unit) return RawTestPage(content) } -class RawTestPage( +public class RawTestPage( override val content: ContentNode, override val name: String = "testPage", override val dri: Set<DRI> = setOf(DRI.topLevel), diff --git a/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt b/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt index d9b2b1d2..3dc0e54b 100644 --- a/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt +++ b/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt @@ -21,52 +21,54 @@ import org.jetbrains.dokka.utilities.DokkaConsoleLogger import org.jetbrains.dokka.utilities.DokkaLogger import org.jetbrains.dokka.utilities.LoggingLevel -class BaseDokkaTestGenerator( +public class BaseDokkaTestGenerator( configuration: DokkaConfiguration, logger: DokkaLogger, testMethods: BaseTestMethods, additionalPlugins: List<DokkaPlugin> = emptyList() ) : DokkaTestGenerator<BaseTestMethods>(configuration, logger, testMethods, additionalPlugins) { - override fun generate() = with(testMethods) { - val dokkaGenerator = DokkaGenerator(configuration, logger) + override fun generate() { + with(testMethods) { + val dokkaGenerator = DokkaGenerator(configuration, logger) - val context = - dokkaGenerator.initializePlugins(configuration, logger, additionalPlugins) - pluginsSetupStage(context) + val context = + dokkaGenerator.initializePlugins(configuration, logger, additionalPlugins) + pluginsSetupStage(context) - val singleModuleGeneration = context.single(CoreExtensions.generation) as SingleModuleGeneration + val singleModuleGeneration = context.single(CoreExtensions.generation) as SingleModuleGeneration - val modulesFromPlatforms = singleModuleGeneration.createDocumentationModels() - documentablesCreationStage(modulesFromPlatforms) + val modulesFromPlatforms = singleModuleGeneration.createDocumentationModels() + documentablesCreationStage(modulesFromPlatforms) - verificationStage { singleModuleGeneration.validityCheck(context) } + verificationStage { singleModuleGeneration.validityCheck(context) } - val filteredModules = singleModuleGeneration.transformDocumentationModelBeforeMerge(modulesFromPlatforms) - documentablesFirstTransformationStep(filteredModules) + val filteredModules = singleModuleGeneration.transformDocumentationModelBeforeMerge(modulesFromPlatforms) + documentablesFirstTransformationStep(filteredModules) - val documentationModel = singleModuleGeneration.mergeDocumentationModels(filteredModules) - documentablesMergingStage(documentationModel!!) + val documentationModel = singleModuleGeneration.mergeDocumentationModels(filteredModules) + documentablesMergingStage(documentationModel!!) - val transformedDocumentation = singleModuleGeneration.transformDocumentationModelAfterMerge(documentationModel) - documentablesTransformationStage(transformedDocumentation) + val transformedDocumentation = singleModuleGeneration.transformDocumentationModelAfterMerge(documentationModel) + documentablesTransformationStage(transformedDocumentation) - val pages = singleModuleGeneration.createPages(transformedDocumentation) - pagesGenerationStage(pages) + val pages = singleModuleGeneration.createPages(transformedDocumentation) + pagesGenerationStage(pages) - val transformedPages = singleModuleGeneration.transformPages(pages) - pagesTransformationStage(transformedPages) + val transformedPages = singleModuleGeneration.transformPages(pages) + pagesTransformationStage(transformedPages) - singleModuleGeneration.render(transformedPages) - renderingStage(transformedPages, context) + singleModuleGeneration.render(transformedPages) + renderingStage(transformedPages, context) - singleModuleGeneration.runPostActions() + singleModuleGeneration.runPostActions() - singleModuleGeneration.reportAfterRendering() + singleModuleGeneration.reportAfterRendering() + } } } -data class BaseTestMethods( +public data class BaseTestMethods( override val pluginsSetupStage: (DokkaContext) -> Unit, override val verificationStage: (() -> Unit) -> Unit, override val documentablesCreationStage: (List<DModule>) -> Unit, @@ -87,31 +89,35 @@ data class BaseTestMethods( renderingStage, ) -class BaseTestBuilder : TestBuilder<BaseTestMethods>() { - var pluginsSetupStage: (DokkaContext) -> Unit = {} - var verificationStage: (() -> Unit) -> Unit = {} - var documentablesCreationStage: (List<DModule>) -> Unit = {} - var preMergeDocumentablesTransformationStage: (List<DModule>) -> Unit = {} - var documentablesMergingStage: (DModule) -> Unit = {} - var documentablesTransformationStage: (DModule) -> Unit = {} - var pagesGenerationStage: (RootPageNode) -> Unit = {} - var pagesTransformationStage: (RootPageNode) -> Unit = {} - var renderingStage: (RootPageNode, DokkaContext) -> Unit = { _, _ -> } - - override fun build() = BaseTestMethods( - pluginsSetupStage, - verificationStage, - documentablesCreationStage, - preMergeDocumentablesTransformationStage, - documentablesMergingStage, - documentablesTransformationStage, - pagesGenerationStage, - pagesTransformationStage, - renderingStage - ) +public class BaseTestBuilder : TestBuilder<BaseTestMethods>() { + public var pluginsSetupStage: (DokkaContext) -> Unit = {} + public var verificationStage: (() -> Unit) -> Unit = {} + public var documentablesCreationStage: (List<DModule>) -> Unit = {} + public var preMergeDocumentablesTransformationStage: (List<DModule>) -> Unit = {} + public var documentablesMergingStage: (DModule) -> Unit = {} + public var documentablesTransformationStage: (DModule) -> Unit = {} + public var pagesGenerationStage: (RootPageNode) -> Unit = {} + public var pagesTransformationStage: (RootPageNode) -> Unit = {} + public var renderingStage: (RootPageNode, DokkaContext) -> Unit = { _, _ -> } + + override fun build(): BaseTestMethods { + return BaseTestMethods( + pluginsSetupStage, + verificationStage, + documentablesCreationStage, + preMergeDocumentablesTransformationStage, + documentablesMergingStage, + documentablesTransformationStage, + pagesGenerationStage, + pagesTransformationStage, + renderingStage + ) + } } -abstract class BaseAbstractTest(logger: TestLogger = TestLogger(DokkaConsoleLogger(LoggingLevel.DEBUG))) : AbstractTest<BaseTestMethods, BaseTestBuilder, BaseDokkaTestGenerator>( +public abstract class BaseAbstractTest( + logger: TestLogger = TestLogger(DokkaConsoleLogger(LoggingLevel.DEBUG)) +) : AbstractTest<BaseTestMethods, BaseTestBuilder, BaseDokkaTestGenerator>( ::BaseTestBuilder, ::BaseDokkaTestGenerator, logger, diff --git a/plugins/base/base-test-utils/src/main/kotlin/utils/TestOutputWriter.kt b/plugins/base/base-test-utils/src/main/kotlin/utils/TestOutputWriter.kt index 578bbfe7..089a94ca 100644 --- a/plugins/base/base-test-utils/src/main/kotlin/utils/TestOutputWriter.kt +++ b/plugins/base/base-test-utils/src/main/kotlin/utils/TestOutputWriter.kt @@ -8,15 +8,16 @@ import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.OutputWriter import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.plugability.DokkaPluginApiPreview +import org.jetbrains.dokka.plugability.Extension import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement import java.util.* -class TestOutputWriterPlugin(failOnOverwrite: Boolean = true) : DokkaPlugin() { - val writer = TestOutputWriter(failOnOverwrite) +public class TestOutputWriterPlugin(failOnOverwrite: Boolean = true) : DokkaPlugin() { + public val writer: TestOutputWriter = TestOutputWriter(failOnOverwrite) private val dokkaBase by lazy { plugin<DokkaBase>() } - val testWriter by extending { + public val testWriter: Extension<OutputWriter, *, *> by extending { (dokkaBase.outputWriter with writer override dokkaBase.fileWriter) @@ -27,10 +28,12 @@ class TestOutputWriterPlugin(failOnOverwrite: Boolean = true) : DokkaPlugin() { PluginApiPreviewAcknowledgement } -class TestOutputWriter(private val failOnOverwrite: Boolean = true) : OutputWriter { - val contents: Map<String, String> get() = _contents - +public class TestOutputWriter( + private val failOnOverwrite: Boolean = true +) : OutputWriter { + public val contents: Map<String, String> get() = _contents private val _contents = Collections.synchronizedMap(mutableMapOf<String, String>()) + override suspend fun write(path: String, text: String, ext: String) { val fullPath = "$path$ext" _contents.putIfAbsent(fullPath, text)?.also { @@ -38,6 +41,7 @@ class TestOutputWriter(private val failOnOverwrite: Boolean = true) : OutputWrit } } - override suspend fun writeResources(pathFrom: String, pathTo: String) = + override suspend fun writeResources(pathFrom: String, pathTo: String) { write(pathTo, "*** content of $pathFrom ***", "") + } } diff --git a/plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt b/plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt index 5b2ed612..207ebb8a 100644 --- a/plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt +++ b/plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt @@ -12,7 +12,7 @@ import kotlin.test.assertEquals * Parses it using JSOUP, trims whitespace at the end of the line and asserts if they are equal * parsing is required to unify the formatting */ -fun assertHtmlEqualsIgnoringWhitespace(expected: String, actual: String) { +public fun assertHtmlEqualsIgnoringWhitespace(expected: String, actual: String) { val ignoreFormattingSettings = Document.OutputSettings().indentAmount(0).outline(true) assertEquals( Jsoup.parse(expected).outputSettings(ignoreFormattingSettings).outerHtml().trimSpacesAtTheEndOfLine(), diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt index bd429c34..dfec2c15 100644 --- a/plugins/base/src/main/kotlin/DokkaBase.kt +++ b/plugins/base/src/main/kotlin/DokkaBase.kt @@ -30,67 +30,70 @@ import org.jetbrains.dokka.base.transformers.pages.sourcelinks.SourceLinksTransf import org.jetbrains.dokka.base.transformers.pages.tags.CustomTagContentProvider import org.jetbrains.dokka.base.transformers.pages.tags.SinceKotlinTagContentProvider import org.jetbrains.dokka.base.translators.documentables.DefaultDocumentableToPageTranslator -import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.plugability.DokkaPluginApiPreview -import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement +import org.jetbrains.dokka.generation.Generation +import org.jetbrains.dokka.plugability.* +import org.jetbrains.dokka.renderers.Renderer +import org.jetbrains.dokka.transformers.documentation.DocumentableMerger +import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator +import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer import org.jetbrains.dokka.transformers.pages.PageTransformer @Suppress("unused") -class DokkaBase : DokkaPlugin() { - - val preMergeDocumentableTransformer by extensionPoint<PreMergeDocumentableTransformer>() - val pageMergerStrategy by extensionPoint<PageMergerStrategy>() - val commentsToContentConverter by extensionPoint<CommentsToContentConverter>() - val customTagContentProvider by extensionPoint<CustomTagContentProvider>() - val signatureProvider by extensionPoint<SignatureProvider>() - val locationProviderFactory by extensionPoint<LocationProviderFactory>() - val externalLocationProviderFactory by extensionPoint<ExternalLocationProviderFactory>() - val outputWriter by extensionPoint<OutputWriter>() - val htmlPreprocessors by extensionPoint<PageTransformer>() +public class DokkaBase : DokkaPlugin() { + + public val preMergeDocumentableTransformer: ExtensionPoint<PreMergeDocumentableTransformer> by extensionPoint() + public val pageMergerStrategy: ExtensionPoint<PageMergerStrategy> by extensionPoint() + public val commentsToContentConverter: ExtensionPoint<CommentsToContentConverter> by extensionPoint() + public val customTagContentProvider: ExtensionPoint<CustomTagContentProvider> by extensionPoint() + public val signatureProvider: ExtensionPoint<SignatureProvider> by extensionPoint() + public val locationProviderFactory: ExtensionPoint<LocationProviderFactory> by extensionPoint() + public val externalLocationProviderFactory: ExtensionPoint<ExternalLocationProviderFactory> by extensionPoint() + public val outputWriter: ExtensionPoint<OutputWriter> by extensionPoint() + public val htmlPreprocessors: ExtensionPoint<PageTransformer> by extensionPoint() @Deprecated("It is not used anymore") - val tabSortingStrategy by extensionPoint<TabSortingStrategy>() - val immediateHtmlCommandConsumer by extensionPoint<ImmediateHtmlCommandConsumer>() + public val tabSortingStrategy: ExtensionPoint<TabSortingStrategy> by extensionPoint() + public val immediateHtmlCommandConsumer: ExtensionPoint<ImmediateHtmlCommandConsumer> by extensionPoint() - val singleGeneration by extending { + public val singleGeneration: Extension<Generation, *, *> by extending { CoreExtensions.generation providing ::SingleModuleGeneration } - val documentableMerger by extending { + public val documentableMerger: Extension<DocumentableMerger, *, *> by extending { CoreExtensions.documentableMerger providing ::DefaultDocumentableMerger } - val deprecatedDocumentableFilter by extending { + public val deprecatedDocumentableFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending { preMergeDocumentableTransformer providing ::DeprecatedDocumentableFilterTransformer } - val suppressedDocumentableFilter by extending { + public val suppressedDocumentableFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending { preMergeDocumentableTransformer providing ::SuppressedByConfigurationDocumentableFilterTransformer } - val suppressedBySuppressTagDocumentableFilter by extending { + public val suppressedBySuppressTagDocumentableFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending { preMergeDocumentableTransformer providing ::SuppressTagDocumentableFilter } - val documentableVisibilityFilter by extending { + public val documentableVisibilityFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending { preMergeDocumentableTransformer providing ::DocumentableVisibilityFilterTransformer } - val obviousFunctionsVisbilityFilter by extending { + public val obviousFunctionsVisbilityFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending { preMergeDocumentableTransformer providing ::ObviousFunctionsDocumentableFilterTransformer } - val inheritedEntriesVisbilityFilter by extending { + public val inheritedEntriesVisbilityFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending { preMergeDocumentableTransformer providing ::InheritedEntriesDocumentableFilterTransformer } - val kotlinArrayDocumentableReplacer by extending { + public val kotlinArrayDocumentableReplacer: Extension<PreMergeDocumentableTransformer, *, *> by extending { preMergeDocumentableTransformer providing ::KotlinArrayDocumentableReplacerTransformer } - val emptyPackagesFilter by extending { + public val emptyPackagesFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending { preMergeDocumentableTransformer providing ::EmptyPackagesFilterTransformer order { after( deprecatedDocumentableFilter, @@ -103,124 +106,127 @@ class DokkaBase : DokkaPlugin() { } } - val emptyModulesFilter by extending { + public val emptyModulesFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending { preMergeDocumentableTransformer with EmptyModulesFilterTransformer() order { after(emptyPackagesFilter) } } - val modulesAndPackagesDocumentation by extending { + public val modulesAndPackagesDocumentation: Extension<PreMergeDocumentableTransformer, *, *> by extending { preMergeDocumentableTransformer providing ::ModuleAndPackageDocumentationTransformer } - val actualTypealiasAdder by extending { + public val actualTypealiasAdder: Extension<DocumentableTransformer, *, *> by extending { CoreExtensions.documentableTransformer with ActualTypealiasAdder() } - val kotlinSignatureProvider by extending { + public val kotlinSignatureProvider: Extension<SignatureProvider, *, *> by extending { signatureProvider providing ::KotlinSignatureProvider } - val sinceKotlinTransformer by extending { - CoreExtensions.documentableTransformer providing ::SinceKotlinTransformer applyIf { SinceKotlinTransformer.shouldDisplaySinceKotlin() } order { + public val sinceKotlinTransformer: Extension<DocumentableTransformer, *, *> by extending { + CoreExtensions.documentableTransformer providing ::SinceKotlinTransformer applyIf { + SinceKotlinTransformer.shouldDisplaySinceKotlin() + } order { before(extensionsExtractor) } } - val inheritorsExtractor by extending { + public val inheritorsExtractor: Extension<DocumentableTransformer, *, *> by extending { CoreExtensions.documentableTransformer with InheritorsExtractorTransformer() } - val undocumentedCodeReporter by extending { + public val undocumentedCodeReporter: Extension<DocumentableTransformer, *, *> by extending { CoreExtensions.documentableTransformer with ReportUndocumentedTransformer() } - val extensionsExtractor by extending { + public val extensionsExtractor: Extension<DocumentableTransformer, *, *> by extending { CoreExtensions.documentableTransformer with ExtensionExtractorTransformer() } - val documentableToPageTranslator by extending { + public val documentableToPageTranslator: Extension<DocumentableToPageTranslator, *, *> by extending { CoreExtensions.documentableToPageTranslator providing ::DefaultDocumentableToPageTranslator } - val docTagToContentConverter by extending { + public val docTagToContentConverter: Extension<CommentsToContentConverter, *, *> by extending { commentsToContentConverter with DocTagToContentConverter() } - val sinceKotlinTagContentProvider by extending { - customTagContentProvider with SinceKotlinTagContentProvider applyIf { SinceKotlinTransformer.shouldDisplaySinceKotlin() } + public val sinceKotlinTagContentProvider: Extension<CustomTagContentProvider, *, *> by extending { + customTagContentProvider with SinceKotlinTagContentProvider applyIf { + SinceKotlinTransformer.shouldDisplaySinceKotlin() + } } - val pageMerger by extending { - CoreExtensions.pageTransformer providing ::PageMerger order { - } + public val pageMerger: Extension<PageTransformer, *, *> by extending { + CoreExtensions.pageTransformer providing ::PageMerger } - val sourceSetMerger by extending { + public val sourceSetMerger: Extension<PageTransformer, *, *> by extending { CoreExtensions.pageTransformer providing ::SourceSetMergingPageTransformer } - val fallbackMerger by extending { + public val fallbackMerger: Extension<PageMergerStrategy, *, *> by extending { pageMergerStrategy providing { ctx -> FallbackPageMergerStrategy(ctx.logger) } } - val sameMethodNameMerger by extending { + public val sameMethodNameMerger: Extension<PageMergerStrategy, *, *> by extending { pageMergerStrategy providing { ctx -> SameMethodNamePageMergerStrategy(ctx.logger) } order { before(fallbackMerger) } } - val htmlRenderer by extending { + public val htmlRenderer: Extension<Renderer, *, *> by extending { CoreExtensions.renderer providing ::HtmlRenderer } - val locationProvider by extending { + public val locationProvider: Extension<LocationProviderFactory, *, *> by extending { locationProviderFactory providing ::DokkaLocationProviderFactory } - val javadocLocationProvider by extending { + public val javadocLocationProvider: Extension<ExternalLocationProviderFactory, *, *> by extending { externalLocationProviderFactory providing ::JavadocExternalLocationProviderFactory } - val dokkaLocationProvider by extending { + public val dokkaLocationProvider: Extension<ExternalLocationProviderFactory, *, *> by extending { externalLocationProviderFactory providing ::DefaultExternalLocationProviderFactory } - val fileWriter by extending { + public val fileWriter: Extension<OutputWriter, *, *> by extending { outputWriter providing ::FileWriter } - val rootCreator by extending { + public val rootCreator: Extension<PageTransformer, *, *> by extending { htmlPreprocessors with RootCreator applyIf { !delayTemplateSubstitution } } - val defaultSamplesTransformer by extending { + public val defaultSamplesTransformer: Extension<PageTransformer, *, *> by extending { CoreExtensions.pageTransformer providing ::DefaultSamplesTransformer order { before(pageMerger) } } - val sourceLinksTransformer by extending { + public val sourceLinksTransformer: Extension<PageTransformer, *, *> by extending { htmlPreprocessors providing ::SourceLinksTransformer order { after(rootCreator) } } - val navigationPageInstaller by extending { + public val navigationPageInstaller: Extension<PageTransformer, *, *> by extending { htmlPreprocessors providing ::NavigationPageInstaller order { after(rootCreator) } } - val scriptsInstaller by extending { + public val scriptsInstaller: Extension<PageTransformer, *, *> by extending { htmlPreprocessors providing ::ScriptsInstaller order { after(rootCreator) } } - val stylesInstaller by extending { + public val stylesInstaller: Extension<PageTransformer, *, *> by extending { htmlPreprocessors providing ::StylesInstaller order { after(rootCreator) } } - val assetsInstaller by extending { + public val assetsInstaller: Extension<PageTransformer, *, *> by extending { htmlPreprocessors with AssetsInstaller order { after(rootCreator) } applyIf { !delayTemplateSubstitution } } - val customResourceInstaller by extending { + public val customResourceInstaller: Extension<PageTransformer, *, *> by extending { htmlPreprocessors providing { ctx -> CustomResourceInstaller(ctx) } order { after(stylesInstaller) after(scriptsInstaller) @@ -228,65 +234,65 @@ class DokkaBase : DokkaPlugin() { } } - val packageListCreator by extending { + public val packageListCreator: Extension<PageTransformer, *, *> by extending { htmlPreprocessors providing { PackageListCreator(it, RecognizedLinkFormat.DokkaHtml) } order { after(rootCreator) } } - val sourcesetDependencyAppender by extending { + public val sourcesetDependencyAppender: Extension<PageTransformer, *, *> by extending { htmlPreprocessors providing ::SourcesetDependencyAppender order { after(rootCreator) } } - val resolveLinkConsumer by extending { + public val resolveLinkConsumer: Extension<ImmediateHtmlCommandConsumer, *, *> by extending { immediateHtmlCommandConsumer with ResolveLinkConsumer } - val replaceVersionConsumer by extending { + public val replaceVersionConsumer: Extension<ImmediateHtmlCommandConsumer, *, *> by extending { immediateHtmlCommandConsumer providing ::ReplaceVersionsConsumer } - val pathToRootConsumer by extending { + public val pathToRootConsumer: Extension<ImmediateHtmlCommandConsumer, *, *> by extending { immediateHtmlCommandConsumer with PathToRootConsumer } - val baseSearchbarDataInstaller by extending { + public val baseSearchbarDataInstaller: Extension<PageTransformer, *, *> by extending { htmlPreprocessors providing ::SearchbarDataInstaller order { after(sourceLinksTransformer) } } //<editor-fold desc="Deprecated API left for compatibility"> @Suppress("DEPRECATION_ERROR") @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - val kotlinAnalysis by extensionPoint<org.jetbrains.dokka.analysis.KotlinAnalysis>() + public val kotlinAnalysis: ExtensionPoint<org.jetbrains.dokka.analysis.KotlinAnalysis> by extensionPoint() @Suppress("DEPRECATION_ERROR") @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - val externalDocumentablesProvider by extensionPoint<org.jetbrains.dokka.base.translators.descriptors.ExternalDocumentablesProvider>() + public val externalDocumentablesProvider: ExtensionPoint<org.jetbrains.dokka.base.translators.descriptors.ExternalDocumentablesProvider> by extensionPoint() @Suppress("DEPRECATION_ERROR") @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - val externalClasslikesTranslator by extensionPoint<org.jetbrains.dokka.base.translators.descriptors.ExternalClasslikesTranslator>() + public val externalClasslikesTranslator: ExtensionPoint<org.jetbrains.dokka.base.translators.descriptors.ExternalClasslikesTranslator> by extensionPoint() @Suppress("DeprecatedCallableAddReplaceWith") @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - val descriptorToDocumentableTranslator: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator, *, *> + public val descriptorToDocumentableTranslator: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator, *, *> get() = throw org.jetbrains.dokka.base.deprecated.AnalysisApiDeprecatedError() @Suppress("DeprecatedCallableAddReplaceWith") @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - val psiToDocumentableTranslator: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator, *, *> + public val psiToDocumentableTranslator: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator, *, *> get() = throw org.jetbrains.dokka.base.deprecated.AnalysisApiDeprecatedError() @Suppress("DEPRECATION_ERROR", "DeprecatedCallableAddReplaceWith") @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - val defaultKotlinAnalysis: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.analysis.KotlinAnalysis, *, *> + public val defaultKotlinAnalysis: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.analysis.KotlinAnalysis, *, *> get() = throw org.jetbrains.dokka.base.deprecated.AnalysisApiDeprecatedError() @Suppress("DEPRECATION_ERROR", "DeprecatedCallableAddReplaceWith") @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - val defaultExternalDocumentablesProvider: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.base.translators.descriptors.ExternalDocumentablesProvider, *, *> + public val defaultExternalDocumentablesProvider: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.base.translators.descriptors.ExternalDocumentablesProvider, *, *> get() = throw org.jetbrains.dokka.base.deprecated.AnalysisApiDeprecatedError() @Suppress("DEPRECATION_ERROR", "DeprecatedCallableAddReplaceWith") @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - val defaultExternalClasslikesTranslator: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.base.translators.descriptors.ExternalClasslikesTranslator, *, *> + public val defaultExternalClasslikesTranslator: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.base.translators.descriptors.ExternalClasslikesTranslator, *, *> get() = throw org.jetbrains.dokka.base.deprecated.AnalysisApiDeprecatedError() //</editor-fold> diff --git a/plugins/base/src/main/kotlin/DokkaBaseConfiguration.kt b/plugins/base/src/main/kotlin/DokkaBaseConfiguration.kt index 17a6d128..11184126 100644 --- a/plugins/base/src/main/kotlin/DokkaBaseConfiguration.kt +++ b/plugins/base/src/main/kotlin/DokkaBaseConfiguration.kt @@ -8,7 +8,7 @@ import org.jetbrains.dokka.plugability.ConfigurableBlock import java.io.File import java.time.Year -data class DokkaBaseConfiguration( +public data class DokkaBaseConfiguration( var customStyleSheets: List<File> = defaultCustomStyleSheets, var customAssets: List<File> = defaultCustomAssets, var separateInheritedMembers: Boolean = separateInheritedMembersDefault, @@ -16,12 +16,12 @@ data class DokkaBaseConfiguration( var mergeImplicitExpectActualDeclarations: Boolean = mergeImplicitExpectActualDeclarationsDefault, var templatesDir: File? = defaultTemplatesDir ) : ConfigurableBlock { - companion object { - val defaultFooterMessage = "© ${Year.now().value} Copyright" - val defaultCustomStyleSheets: List<File> = emptyList() - val defaultCustomAssets: List<File> = emptyList() - const val separateInheritedMembersDefault: Boolean = false - const val mergeImplicitExpectActualDeclarationsDefault: Boolean = false - val defaultTemplatesDir: File? = null + public companion object { + public val defaultFooterMessage: String = "© ${Year.now().value} Copyright" + public val defaultCustomStyleSheets: List<File> = emptyList() + public val defaultCustomAssets: List<File> = emptyList() + public const val separateInheritedMembersDefault: Boolean = false + public const val mergeImplicitExpectActualDeclarationsDefault: Boolean = false + public val defaultTemplatesDir: File? = null } } diff --git a/plugins/base/src/main/kotlin/deprecated/AnalysisApiDeprecatedError.kt b/plugins/base/src/main/kotlin/deprecated/AnalysisApiDeprecatedError.kt index 389a284e..52280b3e 100644 --- a/plugins/base/src/main/kotlin/deprecated/AnalysisApiDeprecatedError.kt +++ b/plugins/base/src/main/kotlin/deprecated/AnalysisApiDeprecatedError.kt @@ -13,4 +13,4 @@ internal const val ANALYSIS_API_DEPRECATION_MESSAGE = "https://github.com/Kotlin/dokka/issues/3099" @InternalDokkaApi -class AnalysisApiDeprecatedError : Error(ANALYSIS_API_DEPRECATION_MESSAGE) +public class AnalysisApiDeprecatedError : Error(ANALYSIS_API_DEPRECATION_MESSAGE) diff --git a/plugins/base/src/main/kotlin/deprecated/KotlinAnalysisDeprecatedApi.kt b/plugins/base/src/main/kotlin/deprecated/KotlinAnalysisDeprecatedApi.kt index 50c62889..1d9e7e9f 100644 --- a/plugins/base/src/main/kotlin/deprecated/KotlinAnalysisDeprecatedApi.kt +++ b/plugins/base/src/main/kotlin/deprecated/KotlinAnalysisDeprecatedApi.kt @@ -17,58 +17,58 @@ import org.jetbrains.dokka.utilities.DokkaLogger import java.io.Closeable @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -abstract class KotlinAnalysis( +public abstract class KotlinAnalysis( private val parent: KotlinAnalysis? = null ) : Closeable { @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - operator fun get(key: DokkaConfiguration.DokkaSourceSet): AnalysisContext = throw AnalysisApiDeprecatedError() + public operator fun get(key: DokkaConfiguration.DokkaSourceSet): AnalysisContext = throw AnalysisApiDeprecatedError() @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - operator fun get(key: DokkaSourceSetID): AnalysisContext = throw AnalysisApiDeprecatedError() + public operator fun get(key: DokkaSourceSetID): AnalysisContext = throw AnalysisApiDeprecatedError() @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) protected abstract fun find(sourceSetID: DokkaSourceSetID): AnalysisContext? } -class AnalysisContext(environment: Any, facade: Any, private val analysisEnvironment: Any) : Closeable { +public class AnalysisContext(environment: Any, facade: Any, private val analysisEnvironment: Any) : Closeable { @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - val environment: Any get() = throw AnalysisApiDeprecatedError() + public val environment: Any get() = throw AnalysisApiDeprecatedError() @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - val facade: Any get() = throw AnalysisApiDeprecatedError() + public val facade: Any get() = throw AnalysisApiDeprecatedError() @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - operator fun component1(): Any = throw AnalysisApiDeprecatedError() + public operator fun component1(): Any = throw AnalysisApiDeprecatedError() @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - operator fun component2(): Any = throw AnalysisApiDeprecatedError() + public operator fun component2(): Any = throw AnalysisApiDeprecatedError() @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - override fun close() = throw AnalysisApiDeprecatedError() + override fun close() { throw AnalysisApiDeprecatedError() } } @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -class DokkaAnalysisConfiguration(val ignoreCommonBuiltIns: Boolean = false) +public class DokkaAnalysisConfiguration(public val ignoreCommonBuiltIns: Boolean = false) @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -fun KotlinAnalysis(context: DokkaContext): KotlinAnalysis = throw AnalysisApiDeprecatedError() +public fun KotlinAnalysis(context: DokkaContext): KotlinAnalysis = throw AnalysisApiDeprecatedError() @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -fun KotlinAnalysis( +public fun KotlinAnalysis( sourceSets: List<DokkaConfiguration.DokkaSourceSet>, logger: DokkaLogger, analysisConfiguration: DokkaAnalysisConfiguration = DokkaAnalysisConfiguration() ): KotlinAnalysis = throw AnalysisApiDeprecatedError() @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -fun ProjectKotlinAnalysis( +public fun ProjectKotlinAnalysis( sourceSets: List<DokkaConfiguration.DokkaSourceSet>, logger: DokkaLogger, analysisConfiguration: DokkaAnalysisConfiguration = DokkaAnalysisConfiguration() ): KotlinAnalysis = throw AnalysisApiDeprecatedError() @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -fun SamplesKotlinAnalysis( +public fun SamplesKotlinAnalysis( sourceSets: List<DokkaConfiguration.DokkaSourceSet>, logger: DokkaLogger, projectKotlinAnalysis: KotlinAnalysis, diff --git a/plugins/base/src/main/kotlin/deprecated/ParsersDeprecatedAPI.kt b/plugins/base/src/main/kotlin/deprecated/ParsersDeprecatedAPI.kt index d60a570e..55b1daab 100644 --- a/plugins/base/src/main/kotlin/deprecated/ParsersDeprecatedAPI.kt +++ b/plugins/base/src/main/kotlin/deprecated/ParsersDeprecatedAPI.kt @@ -14,25 +14,25 @@ import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.model.doc.TagWrapper @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -abstract class Parser { +public abstract class Parser { @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - open fun parseStringToDocNode(extractedString: String): DocTag = throw AnalysisApiDeprecatedError() + public open fun parseStringToDocNode(extractedString: String): DocTag = throw AnalysisApiDeprecatedError() @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - open fun preparse(text: String): String = throw AnalysisApiDeprecatedError() + public open fun preparse(text: String): String = throw AnalysisApiDeprecatedError() @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - open fun parseTagWithBody(tagName: String, content: String): TagWrapper = throw AnalysisApiDeprecatedError() + public open fun parseTagWithBody(tagName: String, content: String): TagWrapper = throw AnalysisApiDeprecatedError() } @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -open class MarkdownParser( +public open class MarkdownParser( private val externalDri: (String) -> DRI?, private val kdocLocation: String?, ) : Parser() { - companion object { + public companion object { @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - fun parseFromKDocTag( + public fun parseFromKDocTag( @Suppress("UNUSED_PARAMETER") kDocTag: Any?, @Suppress("UNUSED_PARAMETER") externalDri: (String) -> DRI?, @Suppress("UNUSED_PARAMETER") kdocLocation: String?, diff --git a/plugins/base/src/main/kotlin/deprecated/ParsersFactoriesDeprecatedAPI.kt b/plugins/base/src/main/kotlin/deprecated/ParsersFactoriesDeprecatedAPI.kt index bfaabfcf..7b84803c 100644 --- a/plugins/base/src/main/kotlin/deprecated/ParsersFactoriesDeprecatedAPI.kt +++ b/plugins/base/src/main/kotlin/deprecated/ParsersFactoriesDeprecatedAPI.kt @@ -12,9 +12,9 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.doc.DocTag @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -object DocTagsFromStringFactory { +public object DocTagsFromStringFactory { @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - fun getInstance( + public fun getInstance( @Suppress("UNUSED_PARAMETER") name: String, @Suppress("UNUSED_PARAMETER") children: List<DocTag> = emptyList(), @Suppress("UNUSED_PARAMETER") params: Map<String, String> = emptyMap(), diff --git a/plugins/base/src/main/kotlin/deprecated/TranslatorDescriptorsDeprecatedAPI.kt b/plugins/base/src/main/kotlin/deprecated/TranslatorDescriptorsDeprecatedAPI.kt index f8b9fe10..87d82ccf 100644 --- a/plugins/base/src/main/kotlin/deprecated/TranslatorDescriptorsDeprecatedAPI.kt +++ b/plugins/base/src/main/kotlin/deprecated/TranslatorDescriptorsDeprecatedAPI.kt @@ -16,13 +16,13 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.sources.AsyncSourceToDocumentableTranslator @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -fun interface ExternalDocumentablesProvider { +public fun interface ExternalDocumentablesProvider { @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - fun findClasslike(dri: DRI, sourceSet: DokkaConfiguration.DokkaSourceSet): DClasslike? + public fun findClasslike(dri: DRI, sourceSet: DokkaConfiguration.DokkaSourceSet): DClasslike? } @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -class DefaultExternalDocumentablesProvider( +public class DefaultExternalDocumentablesProvider( @Suppress("UNUSED_PARAMETER") context: DokkaContext ) : ExternalDocumentablesProvider { @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) @@ -31,13 +31,13 @@ class DefaultExternalDocumentablesProvider( } @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -fun interface ExternalClasslikesTranslator { +public fun interface ExternalClasslikesTranslator { @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - fun translateClassDescriptor(descriptor: Any, sourceSet: DokkaConfiguration.DokkaSourceSet): DClasslike + public fun translateClassDescriptor(descriptor: Any, sourceSet: DokkaConfiguration.DokkaSourceSet): DClasslike } @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -class DefaultDescriptorToDocumentableTranslator( +public class DefaultDescriptorToDocumentableTranslator( private val context: DokkaContext ) : AsyncSourceToDocumentableTranslator, ExternalClasslikesTranslator { @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) diff --git a/plugins/base/src/main/kotlin/deprecated/TranslatorPsiDeprecatedAPI.kt b/plugins/base/src/main/kotlin/deprecated/TranslatorPsiDeprecatedAPI.kt index 124c3045..1906a7b1 100644 --- a/plugins/base/src/main/kotlin/deprecated/TranslatorPsiDeprecatedAPI.kt +++ b/plugins/base/src/main/kotlin/deprecated/TranslatorPsiDeprecatedAPI.kt @@ -14,7 +14,7 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.sources.AsyncSourceToDocumentableTranslator @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -class DefaultPsiToDocumentableTranslator( +public class DefaultPsiToDocumentableTranslator( @Suppress("UNUSED_PARAMETER") context: DokkaContext, ) : AsyncSourceToDocumentableTranslator { @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) diff --git a/plugins/base/src/main/kotlin/generation/SingleModuleGeneration.kt b/plugins/base/src/main/kotlin/generation/SingleModuleGeneration.kt index b99afb3d..602173f4 100644 --- a/plugins/base/src/main/kotlin/generation/SingleModuleGeneration.kt +++ b/plugins/base/src/main/kotlin/generation/SingleModuleGeneration.kt @@ -22,7 +22,7 @@ import org.jetbrains.dokka.transformers.sources.AsyncSourceToDocumentableTransla import org.jetbrains.dokka.utilities.parallelMap import org.jetbrains.dokka.utilities.report -class SingleModuleGeneration(private val context: DokkaContext) : Generation { +public class SingleModuleGeneration(private val context: DokkaContext) : Generation { override fun Timer.generate() { report("Validity check") @@ -59,38 +59,40 @@ class SingleModuleGeneration(private val context: DokkaContext) : Generation { reportAfterRendering() } - override val generationName = "documentation for ${context.configuration.moduleName}" + override val generationName: String = "documentation for ${context.configuration.moduleName}" - fun createDocumentationModels(): List<DModule> = runBlocking(Dispatchers.Default) { + public fun createDocumentationModels(): List<DModule> = runBlocking(Dispatchers.Default) { context.configuration.sourceSets.parallelMap { sourceSet -> translateSources(sourceSet, context) }.flatten() .also { modules -> if (modules.isEmpty()) exitGenerationGracefully("Nothing to document") } } - fun transformDocumentationModelBeforeMerge(modulesFromPlatforms: List<DModule>) = - context.plugin<DokkaBase>().query { preMergeDocumentableTransformer } + public fun transformDocumentationModelBeforeMerge(modulesFromPlatforms: List<DModule>): List<DModule> { + return context.plugin<DokkaBase>() + .query { preMergeDocumentableTransformer } .fold(modulesFromPlatforms) { acc, t -> t(acc) } + } - fun mergeDocumentationModels(modulesFromPlatforms: List<DModule>) = + public fun mergeDocumentationModels(modulesFromPlatforms: List<DModule>): DModule? = context.single(CoreExtensions.documentableMerger).invoke(modulesFromPlatforms) - fun transformDocumentationModelAfterMerge(documentationModel: DModule) = + public fun transformDocumentationModelAfterMerge(documentationModel: DModule): DModule = context[CoreExtensions.documentableTransformer].fold(documentationModel) { acc, t -> t(acc, context) } - fun createPages(transformedDocumentation: DModule): RootPageNode = + public fun createPages(transformedDocumentation: DModule): RootPageNode = context.single(CoreExtensions.documentableToPageTranslator).invoke(transformedDocumentation) - fun transformPages(pages: RootPageNode): RootPageNode = + public fun transformPages(pages: RootPageNode): RootPageNode = context[CoreExtensions.pageTransformer].fold(pages) { acc, t -> t(acc) } - fun render(transformedPages: RootPageNode) { + public fun render(transformedPages: RootPageNode) { context.single(CoreExtensions.renderer).render(transformedPages) } - fun runPostActions() { + public fun runPostActions() { context[CoreExtensions.postActions].forEach { it() } } - fun validityCheck(context: DokkaContext) { + public fun validityCheck(context: DokkaContext) { val (preGenerationCheckResult, checkMessages) = context[CoreExtensions.preGenerationCheck].fold( Pair(true, emptyList<String>()) ) { acc, checker -> checker() + acc } @@ -99,7 +101,7 @@ class SingleModuleGeneration(private val context: DokkaContext) : Generation { ) } - fun reportAfterRendering() { + public fun reportAfterRendering() { context.unusedPoints.takeIf { it.isNotEmpty() }?.also { context.logger.info("Unused extension points found: ${it.joinToString(", ")}") } diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt index edbf1037..eed7794e 100644 --- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt @@ -19,61 +19,68 @@ import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.renderers.Renderer import org.jetbrains.dokka.transformers.pages.PageTransformer -abstract class DefaultRenderer<T>( +public abstract class DefaultRenderer<T>( protected val context: DokkaContext ) : Renderer { - protected val outputWriter = context.plugin<DokkaBase>().querySingle { outputWriter } + protected val outputWriter: OutputWriter = context.plugin<DokkaBase>().querySingle { outputWriter } protected lateinit var locationProvider: LocationProvider private set protected open val preprocessors: Iterable<PageTransformer> = emptyList() - abstract fun T.buildHeader(level: Int, node: ContentHeader, content: T.() -> Unit) - abstract fun T.buildLink(address: String, content: T.() -> Unit) - abstract fun T.buildList( + public abstract fun T.buildHeader(level: Int, node: ContentHeader, content: T.() -> Unit) + public abstract fun T.buildLink(address: String, content: T.() -> Unit) + public abstract fun T.buildList( node: ContentList, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? = null ) - abstract fun T.buildLineBreak() - open fun T.buildLineBreak(node: ContentBreakLine, pageContext: ContentPage) = buildLineBreak() + public abstract fun T.buildLineBreak() + public open fun T.buildLineBreak(node: ContentBreakLine, pageContext: ContentPage) { + buildLineBreak() + } - abstract fun T.buildResource(node: ContentEmbeddedResource, pageContext: ContentPage) - abstract fun T.buildTable( + public abstract fun T.buildResource(node: ContentEmbeddedResource, pageContext: ContentPage) + public abstract fun T.buildTable( node: ContentTable, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? = null ) - abstract fun T.buildText(textNode: ContentText) - abstract fun T.buildNavigation(page: PageNode) + public abstract fun T.buildText(textNode: ContentText) + public abstract fun T.buildNavigation(page: PageNode) - abstract fun buildPage(page: ContentPage, content: (T, ContentPage) -> Unit): String - abstract fun buildError(node: ContentNode) + public abstract fun buildPage(page: ContentPage, content: (T, ContentPage) -> Unit): String + public abstract fun buildError(node: ContentNode) - open fun T.buildPlatformDependent( + public open fun T.buildPlatformDependent( content: PlatformHintedContent, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? - ) = buildContentNode(content.inner, pageContext) + ) { + buildContentNode(content.inner, pageContext) + } - open fun T.buildGroup( + public open fun T.buildGroup( node: ContentGroup, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? = null - ) = + ) { wrapGroup(node, pageContext) { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } } + } - open fun T.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) = + public open fun T.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) { node.children.forEach { it.build(this, pageContext) } + } - open fun T.wrapGroup(node: ContentGroup, pageContext: ContentPage, childrenCallback: T.() -> Unit) = + public open fun T.wrapGroup(node: ContentGroup, pageContext: ContentPage, childrenCallback: T.() -> Unit) { childrenCallback() + } - open fun T.buildText( + public open fun T.buildText( nodes: List<ContentNode>, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? = null @@ -81,15 +88,15 @@ abstract class DefaultRenderer<T>( nodes.forEach { it.build(this, pageContext, sourceSetRestriction) } } - open fun T.buildCodeBlock(code: ContentCodeBlock, pageContext: ContentPage) { + public open fun T.buildCodeBlock(code: ContentCodeBlock, pageContext: ContentPage) { code.children.forEach { it.build(this, pageContext) } } - open fun T.buildCodeInline(code: ContentCodeInline, pageContext: ContentPage) { + public open fun T.buildCodeInline(code: ContentCodeInline, pageContext: ContentPage) { code.children.forEach { it.build(this, pageContext) } } - open fun T.buildHeader( + public open fun T.buildHeader( node: ContentHeader, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? = null @@ -97,19 +104,23 @@ abstract class DefaultRenderer<T>( buildHeader(node.level, node) { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } } } - open fun ContentNode.build( + public open fun ContentNode.build( builder: T, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? = null - ) = builder.buildContentNode(this, pageContext, sourceSetRestriction) + ) { + builder.buildContentNode(this, pageContext, sourceSetRestriction) + } - fun T.buildContentNode( + public fun T.buildContentNode( node: ContentNode, pageContext: ContentPage, sourceSetRestriction: DisplaySourceSet - ) = buildContentNode(node, pageContext, setOf(sourceSetRestriction)) + ) { + buildContentNode(node, pageContext, setOf(sourceSetRestriction)) + } - open fun T.buildContentNode( + public open fun T.buildContentNode( node: ContentNode, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? = null @@ -135,7 +146,7 @@ abstract class DefaultRenderer<T>( } } - open fun T.buildDRILink( + public open fun T.buildDRILink( node: ContentDRILink, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? @@ -147,7 +158,7 @@ abstract class DefaultRenderer<T>( } ?: buildText(node.children, pageContext, sourceSetRestriction) } - open fun T.buildResolvedLink( + public open fun T.buildResolvedLink( node: ContentResolvedLink, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? @@ -157,18 +168,18 @@ abstract class DefaultRenderer<T>( } } - open fun T.buildDivergentInstance(node: ContentDivergentInstance, pageContext: ContentPage) { + public open fun T.buildDivergentInstance(node: ContentDivergentInstance, pageContext: ContentPage) { node.before?.build(this, pageContext) node.divergent.build(this, pageContext) node.after?.build(this, pageContext) } - open fun buildPageContent(context: T, page: ContentPage) { + public open fun buildPageContent(context: T, page: ContentPage) { context.buildNavigation(page) page.content.build(context, page) } - open suspend fun renderPage(page: PageNode) { + public open suspend fun renderPage(page: PageNode) { val path by lazy { locationProvider.resolve(page, skipExtension = true) ?: throw DokkaException("Cannot resolve path for ${page.name}") @@ -243,4 +254,4 @@ abstract class DefaultRenderer<T>( internal typealias SerializedBeforeAndAfter = Pair<String, String> internal typealias InstanceWithSource = Pair<ContentDivergentInstance, DisplaySourceSet> -fun ContentPage.sourceSets() = this.content.sourceSets +public fun ContentPage.sourceSets(): Set<DisplaySourceSet> = this.content.sourceSets diff --git a/plugins/base/src/main/kotlin/renderers/FileWriter.kt b/plugins/base/src/main/kotlin/renderers/FileWriter.kt index 0bca1591..1a1c3b42 100644 --- a/plugins/base/src/main/kotlin/renderers/FileWriter.kt +++ b/plugins/base/src/main/kotlin/renderers/FileWriter.kt @@ -14,7 +14,9 @@ import java.io.IOException import java.net.URI import java.nio.file.* -class FileWriter(val context: DokkaContext): OutputWriter { +public class FileWriter( + public val context: DokkaContext +): OutputWriter { private val createdFiles: MutableSet<String> = mutableSetOf() private val createdFilesMutex = Mutex() private val jarUriPrefix = "jar:file:" @@ -44,12 +46,13 @@ class FileWriter(val context: DokkaContext): OutputWriter { return false } - override suspend fun writeResources(pathFrom: String, pathTo: String) = + override suspend fun writeResources(pathFrom: String, pathTo: String) { if (javaClass.getResource(pathFrom)?.toURI()?.toString()?.startsWith(jarUriPrefix) == true) { copyFromJar(pathFrom, pathTo) } else { copyFromDirectory(pathFrom, pathTo) } + } private suspend fun copyFromDirectory(pathFrom: String, pathTo: String) { diff --git a/plugins/base/src/main/kotlin/renderers/OutputWriter.kt b/plugins/base/src/main/kotlin/renderers/OutputWriter.kt index 9c5de394..3fdd1802 100644 --- a/plugins/base/src/main/kotlin/renderers/OutputWriter.kt +++ b/plugins/base/src/main/kotlin/renderers/OutputWriter.kt @@ -4,8 +4,8 @@ package org.jetbrains.dokka.base.renderers -interface OutputWriter { +public interface OutputWriter { - suspend fun write(path: String, text: String, ext: String) - suspend fun writeResources(pathFrom: String, pathTo: String) + public suspend fun write(path: String, text: String, ext: String) + public suspend fun writeResources(pathFrom: String, pathTo: String) } diff --git a/plugins/base/src/main/kotlin/renderers/PackageListService.kt b/plugins/base/src/main/kotlin/renderers/PackageListService.kt index 1d062542..3ed6cd21 100644 --- a/plugins/base/src/main/kotlin/renderers/PackageListService.kt +++ b/plugins/base/src/main/kotlin/renderers/PackageListService.kt @@ -15,9 +15,12 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.querySingle -class PackageListService(val context: DokkaContext, val rootPage: RootPageNode) { +public class PackageListService( + public val context: DokkaContext, + public val rootPage: RootPageNode +) { - fun createPackageList(module: ModulePage, format: LinkFormat): String { + public fun createPackageList(module: ModulePage, format: LinkFormat): String { val packages = mutableSetOf<String>() val nonStandardLocations = mutableMapOf<String, String>() @@ -46,11 +49,21 @@ class PackageListService(val context: DokkaContext, val rootPage: RootPageNode) } visit(module) - return renderPackageList(nonStandardLocations, mapOf(SINGLE_MODULE_NAME to packages), format.formatName, format.linkExtension) + return renderPackageList( + nonStandardLocations = nonStandardLocations, + modules = mapOf(SINGLE_MODULE_NAME to packages), + format = format.formatName, + linkExtension = format.linkExtension + ) } - companion object { - fun renderPackageList(nonStandardLocations: Map<String, String>, modules: Map<String, Set<String>>, format: String, linkExtension: String): String = buildString { + public companion object { + public fun renderPackageList( + nonStandardLocations: Map<String, String>, + modules: Map<String, Set<String>>, + format: String, + linkExtension: String + ): String = buildString { appendLine("$DOKKA_PARAM_PREFIX.format:${format}") appendLine("$DOKKA_PARAM_PREFIX.linkExtension:${linkExtension}") nonStandardLocations.map { (signature, location) -> diff --git a/plugins/base/src/main/kotlin/renderers/TabSortingStrategy.kt b/plugins/base/src/main/kotlin/renderers/TabSortingStrategy.kt index c76094f9..665b6717 100644 --- a/plugins/base/src/main/kotlin/renderers/TabSortingStrategy.kt +++ b/plugins/base/src/main/kotlin/renderers/TabSortingStrategy.kt @@ -6,6 +6,6 @@ package org.jetbrains.dokka.base.renderers import org.jetbrains.dokka.pages.ContentNode -interface TabSortingStrategy { - fun <T: ContentNode> sort(tabs: Collection<T>) : List<T> +public interface TabSortingStrategy { + public fun <T: ContentNode> sort(tabs: Collection<T>) : List<T> } diff --git a/plugins/base/src/main/kotlin/renderers/contentTypeChecking.kt b/plugins/base/src/main/kotlin/renderers/contentTypeChecking.kt index 8074dab6..0fcb0efb 100644 --- a/plugins/base/src/main/kotlin/renderers/contentTypeChecking.kt +++ b/plugins/base/src/main/kotlin/renderers/contentTypeChecking.kt @@ -8,16 +8,17 @@ import org.jetbrains.dokka.base.renderers.HtmlFileExtensions.imageExtensions import org.jetbrains.dokka.pages.ContentEmbeddedResource import java.io.File -fun ContentEmbeddedResource.isImage(): Boolean { +public fun ContentEmbeddedResource.isImage(): Boolean { return File(address).extension.toLowerCase() in imageExtensions } -val String.URIExtension: String +public val String.URIExtension: String get() = substringBefore('?').substringAfterLast('.') -fun String.isImage(): Boolean = +public fun String.isImage(): Boolean = URIExtension in imageExtensions -object HtmlFileExtensions { - val imageExtensions = setOf("png", "jpg", "jpeg", "gif", "bmp", "tif", "webp", "svg") +public object HtmlFileExtensions { + public val imageExtensions: Set<String> = setOf("png", "jpg", "jpeg", "gif", "bmp", "tif", "webp", "svg") } + diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 9d361f70..083876d5 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -27,12 +27,13 @@ import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.pages.HtmlContent import org.jetbrains.dokka.plugability.* +import org.jetbrains.dokka.transformers.pages.PageTransformer import org.jetbrains.dokka.utilities.htmlEscape internal const val TEMPLATE_REPLACEMENT: String = "###" internal const val TOGGLEABLE_CONTENT_TYPE_ATTR = "data-togglable" -open class HtmlRenderer( +public open class HtmlRenderer( context: DokkaContext ) : DefaultRenderer<FlowContent>(context) { private val sourceSetDependencyMap: Map<DokkaSourceSetID, List<DokkaSourceSetID>> = @@ -50,7 +51,7 @@ open class HtmlRenderer( private var shouldRenderSourceSetTabs: Boolean = false - override val preprocessors = context.plugin<DokkaBase>().query { htmlPreprocessors } + override val preprocessors: List<PageTransformer> = context.plugin<DokkaBase>().query { htmlPreprocessors } /** * Tabs themselves are created in HTML plugin since, currently, only HTML format supports them. @@ -253,7 +254,7 @@ open class HtmlRenderer( content: PlatformHintedContent, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? - ) = + ) { buildPlatformDependent( content.sourceSets.filter { sourceSetRestriction == null || it in sourceSetRestriction @@ -262,6 +263,7 @@ open class HtmlRenderer( content.extra, content.style ) + } private fun FlowContent.buildPlatformDependent( nodes: Map<DisplaySourceSet, Collection<ContentNode>>, @@ -409,19 +411,21 @@ open class HtmlRenderer( node: ContentList, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? - ) = when { - node.ordered -> { - ol { buildListItems(node.children, pageContext, sourceSetRestriction) } - } - node.hasStyle(ListStyle.DescriptionList) -> { - dl { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } } - } - else -> { - ul { buildListItems(node.children, pageContext, sourceSetRestriction) } + ) { + return when { + node.ordered -> { + ol { buildListItems(node.children, pageContext, sourceSetRestriction) } + } + node.hasStyle(ListStyle.DescriptionList) -> { + dl { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } } + } + else -> { + ul { buildListItems(node.children, pageContext, sourceSetRestriction) } + } } } - open fun OL.buildListItems( + public open fun OL.buildListItems( items: List<ContentNode>, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? = null @@ -434,7 +438,7 @@ open class HtmlRenderer( } } - open fun UL.buildListItems( + public open fun UL.buildListItems( items: List<ContentNode>, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? = null @@ -450,12 +454,13 @@ open class HtmlRenderer( override fun FlowContent.buildResource( node: ContentEmbeddedResource, pageContext: ContentPage - ) = // TODO: extension point there + ) { // TODO: extension point there if (node.isImage()) { img(src = node.address, alt = node.altText) } else { println("Unrecognized resource type: $node") } + } private fun FlowContent.buildRow( node: ContentGroup, @@ -642,7 +647,7 @@ open class HtmlRenderer( } - fun FlowContent.buildDefaultTable( + public fun FlowContent.buildDefaultTable( node: ContentTable, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? @@ -709,7 +714,7 @@ open class HtmlRenderer( } - override fun FlowContent.buildNavigation(page: PageNode) = + override fun FlowContent.buildNavigation(page: PageNode) { div(classes = "breadcrumbs") { val path = locationProvider.ancestors(page).filterNot { it is RendererSpecificPage }.asReversed() if (path.size > 1) { @@ -722,6 +727,7 @@ open class HtmlRenderer( } } } + } private fun FlowContent.buildNavigationElement(node: PageNode, page: PageNode) = if (node.isNavigable) { @@ -747,7 +753,7 @@ open class HtmlRenderer( text(to.name) } - fun FlowContent.buildAnchorCopyButton(pointingTo: String) { + public fun FlowContent.buildAnchorCopyButton(pointingTo: String) { span(classes = "anchor-wrapper") { span(classes = "anchor-icon") { attributes["pointing-to"] = pointingTo @@ -756,17 +762,23 @@ open class HtmlRenderer( } } - fun FlowContent.buildLink( + public fun FlowContent.buildLink( to: DRI, platforms: List<DisplaySourceSet>, from: PageNode? = null, block: FlowContent.() -> Unit - ) = locationProvider.resolve(to, platforms.toSet(), from)?.let { buildLink(it, block) } - ?: run { context.logger.error("Cannot resolve path for `$to` from `$from`"); block() } + ) { + locationProvider.resolve(to, platforms.toSet(), from)?.let { buildLink(it, block) } + ?: run { context.logger.error("Cannot resolve path for `$to` from `$from`"); block() } + } - override fun buildError(node: ContentNode) = context.logger.error("Unknown ContentNode type: $node") + override fun buildError(node: ContentNode) { + context.logger.error("Unknown ContentNode type: $node") + } - override fun FlowContent.buildLineBreak() = br() + override fun FlowContent.buildLineBreak() { + br() + } override fun FlowContent.buildLineBreak(node: ContentBreakLine, pageContext: ContentPage) { if (node.style.contains(HorizontalBreakLineStyle)) { hr() @@ -775,25 +787,28 @@ open class HtmlRenderer( } } - override fun FlowContent.buildLink(address: String, content: FlowContent.() -> Unit) = + override fun FlowContent.buildLink(address: String, content: FlowContent.() -> Unit) { a(href = address, block = content) + } override fun FlowContent.buildDRILink( node: ContentDRILink, pageContext: ContentPage, sourceSetRestriction: Set<DisplaySourceSet>? - ) = locationProvider.resolve(node.address, node.sourceSets, pageContext)?.let { address -> - buildLink(address) { - buildText(node.children, pageContext, sourceSetRestriction) - } - } ?: if (isPartial) { - templateCommand(ResolveLinkCommand(node.address)) { - buildText(node.children, pageContext, sourceSetRestriction) - } - } else { - span { - attributes["data-unresolved-link"] = node.address.toString().htmlEscape() - buildText(node.children, pageContext, sourceSetRestriction) + ) { + locationProvider.resolve(node.address, node.sourceSets, pageContext)?.let { address -> + buildLink(address) { + buildText(node.children, pageContext, sourceSetRestriction) + } + } ?: if (isPartial) { + templateCommand(ResolveLinkCommand(node.address)) { + buildText(node.children, pageContext, sourceSetRestriction) + } + } else { + span { + attributes["data-unresolved-link"] = node.address.toString().htmlEscape() + buildText(node.children, pageContext, sourceSetRestriction) + } } } @@ -830,7 +845,9 @@ open class HtmlRenderer( } } - override fun FlowContent.buildText(textNode: ContentText) = buildText(textNode, textNode.style) + override fun FlowContent.buildText(textNode: ContentText) { + buildText(textNode, textNode.style) + } private fun FlowContent.buildText(textNode: ContentText, unappliedStyles: Set<Style>) { when { @@ -891,8 +908,11 @@ open class HtmlRenderer( else -> null } - open fun buildHtml(page: PageNode, resources: List<String>, content: FlowContent.() -> Unit): String = - templater.renderFromTemplate(DokkaTemplateTypes.BASE) { + public open fun buildHtml( + page: PageNode, + resources: List<String>, content: FlowContent.() -> Unit + ): String { + return templater.renderFromTemplate(DokkaTemplateTypes.BASE) { val generatedContent = createHTML().div("main-content") { page.getDocumentableType()?.let { attributes["data-page-type"] = it } @@ -912,12 +932,13 @@ open class HtmlRenderer( ) } } + } /** * This is deliberately left open for plugins that have some other pages above ours and would like to link to them * instead of ours when clicking the logo */ - open fun FlowContent.clickableLogo(page: PageNode, pathToRoot: String) { + public open fun FlowContent.clickableLogo(page: PageNode, pathToRoot: String) { if (context.configuration.delayTemplateSubstitution && page is ContentPage) { templateCommand(PathToRootSubstitutionCommand(pattern = "###", default = pathToRoot)) { a { @@ -978,7 +999,7 @@ private fun TabbedContentType.toHtmlAttribute(): String = */ private data class ContentTab(val text: String, val tabbedContentTypes: List<TabbedContentType>) -fun List<SimpleAttr>.joinAttr() = joinToString(" ") { it.extraKey + "=" + it.extraValue } +public fun List<SimpleAttr>.joinAttr(): String = joinToString(" ") { it.extraKey + "=" + it.extraValue } private fun String.stripDiv() = drop(5).dropLast(6) // TODO: Find a way to do it without arbitrary trims diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt index 1c414ad8..fccfd145 100644 --- a/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt +++ b/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt @@ -17,15 +17,15 @@ import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.analysis.kotlin.internal.DocumentableLanguage import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin -abstract class NavigationDataProvider( +public abstract class NavigationDataProvider( dokkaContext: DokkaContext ) { private val documentableSourceLanguageParser = dokkaContext.plugin<InternalKotlinAnalysisPlugin>().querySingle { documentableSourceLanguageParser } - open fun navigableChildren(input: RootPageNode): NavigationNode = input.withDescendants() + public open fun navigableChildren(input: RootPageNode): NavigationNode = input.withDescendants() .first { it is ModulePage || it is MultimoduleRootPage }.let { visit(it as ContentPage) } - open fun visit(page: ContentPage): NavigationNode = + public open fun visit(page: ContentPage): NavigationNode = NavigationNode( name = page.displayableName(), dri = page.dri.first(), diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt index c4d53588..eae43daf 100644 --- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt +++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt @@ -16,19 +16,19 @@ import org.jetbrains.dokka.model.WithChildren import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext -class NavigationPage( - val root: NavigationNode, - val moduleName: String, - val context: DokkaContext +public class NavigationPage( + public val root: NavigationNode, + public val moduleName: String, + public val context: DokkaContext ) : RendererSpecificPage { - override val name = "navigation" + override val name: String = "navigation" - override val children = emptyList<PageNode>() + override val children: List<PageNode> = emptyList() - override fun modified(name: String, children: List<PageNode>) = this + override fun modified(name: String, children: List<PageNode>): NavigationPage = this - override val strategy = RenderingStrategy<HtmlRenderer> { + override val strategy: RenderingStrategy = RenderingStrategy<HtmlRenderer> { createHTML().visit(root, this) } @@ -86,7 +86,7 @@ class NavigationPage( } } -data class NavigationNode( +public data class NavigationNode( val name: String, val dri: DRI, val sourceSets: Set<DisplaySourceSet>, @@ -99,7 +99,7 @@ data class NavigationNode( * [CLASS] represents a neutral (a.k.a Java-style) icon, * whereas [CLASS_KT] should be Kotlin-styled */ -enum class NavigationNodeIcon( +public enum class NavigationNodeIcon( private val cssClass: String ) { CLASS("class"), @@ -122,8 +122,8 @@ enum class NavigationNodeIcon( internal fun style(): String = "nav-icon $cssClass" } -fun NavigationPage.transform(block: (NavigationNode) -> NavigationNode) = +public fun NavigationPage.transform(block: (NavigationNode) -> NavigationNode): NavigationPage = NavigationPage(root.transform(block), moduleName, context) -fun NavigationNode.transform(block: (NavigationNode) -> NavigationNode) = +public fun NavigationNode.transform(block: (NavigationNode) -> NavigationNode): NavigationNode = run(block).let { NavigationNode(it.name, it.dri, it.sourceSets, it.icon, it.styles, it.children.map(block)) } diff --git a/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt b/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt index f985e4d0..83d4b24f 100644 --- a/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt +++ b/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt @@ -16,19 +16,23 @@ import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.pages.PageTransformer -data class SearchRecord( +public data class SearchRecord( val name: String, val description: String? = null, val location: String, val searchKeys: List<String> = listOf(name) ) { - companion object + public companion object } -open class SearchbarDataInstaller(val context: DokkaContext) : PageTransformer { - data class DRIWithSourceSets(val dri: DRI, val sourceSet: Set<DisplaySourceSet>) - data class SignatureWithId(val driWithSourceSets: DRIWithSourceSets, val displayableSignature: String) { - constructor(dri: DRI, page: ContentPage) : this( DRIWithSourceSets(dri, page.sourceSets()), +public open class SearchbarDataInstaller( + public val context: DokkaContext +) : PageTransformer { + + public data class DRIWithSourceSets(val dri: DRI, val sourceSet: Set<DisplaySourceSet>) + + public data class SignatureWithId(val driWithSourceSets: DRIWithSourceSets, val displayableSignature: String) { + public constructor(dri: DRI, page: ContentPage) : this( DRIWithSourceSets(dri, page.sourceSets()), getSymbolSignature(page, dri)?.let { flattenToText(it) } ?: page.name) val id: String @@ -43,7 +47,10 @@ open class SearchbarDataInstaller(val context: DokkaContext) : PageTransformer { private val mapper = jacksonObjectMapper() - open fun generatePagesList(pages: List<SignatureWithId>, locationResolver: DriResolver): List<SearchRecord> = + public open fun generatePagesList( + pages: List<SignatureWithId>, + locationResolver: DriResolver + ): List<SearchRecord> = pages.map { pageWithId -> createSearchRecord( name = pageWithId.displayableSignature, @@ -57,7 +64,7 @@ open class SearchbarDataInstaller(val context: DokkaContext) : PageTransformer { ) }.sortedWith(compareBy({ it.name }, { it.description })) - open fun createSearchRecord( + public open fun createSearchRecord( name: String, description: String?, location: String, @@ -65,7 +72,7 @@ open class SearchbarDataInstaller(val context: DokkaContext) : PageTransformer { ): SearchRecord = SearchRecord(name, description, location, searchKeys) - open fun processPage(page: PageNode): List<SignatureWithId> = + public open fun processPage(page: PageNode): List<SignatureWithId> = when (page) { is ContentPage -> page.takeIf { page !is ModulePageNode && page !is PackagePageNode }?.dri ?.map { dri -> SignatureWithId(dri, page) }.orEmpty() diff --git a/plugins/base/src/main/kotlin/renderers/html/Tags.kt b/plugins/base/src/main/kotlin/renderers/html/Tags.kt index 7d135c95..7d6fc390 100644 --- a/plugins/base/src/main/kotlin/renderers/html/Tags.kt +++ b/plugins/base/src/main/kotlin/renderers/html/Tags.kt @@ -10,14 +10,14 @@ import org.jetbrains.dokka.base.renderers.html.command.consumers.ImmediateResolu import org.jetbrains.dokka.base.templating.Command import org.jetbrains.dokka.base.templating.toJsonString -typealias TemplateBlock = TemplateCommand.() -> Unit +public typealias TemplateBlock = TemplateCommand.() -> Unit @HtmlTagMarker -fun FlowOrPhrasingContent.wbr(classes: String? = null, block: WBR.() -> Unit = {}): Unit = +public fun FlowOrPhrasingContent.wbr(classes: String? = null, block: WBR.() -> Unit = {}): Unit = WBR(attributesMapOf("class", classes), consumer).visit(block) @Suppress("unused") -open class WBR(initialAttributes: Map<String, String>, consumer: TagConsumer<*>) : +public open class WBR(initialAttributes: Map<String, String>, consumer: TagConsumer<*>) : HTMLTag("wbr", consumer, initialAttributes, namespace = null, inlineTag = true, emptyTag = false), HtmlBlockInlineTag @@ -25,22 +25,22 @@ open class WBR(initialAttributes: Map<String, String>, consumer: TagConsumer<*>) * Work-around until next version of kotlinx.html doesn't come out */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.strike(classes : String? = null, crossinline block : STRIKE.() -> Unit = {}) : Unit = STRIKE(attributesMapOf("class", classes), consumer).visit(block) +public inline fun FlowOrPhrasingContent.strike(classes : String? = null, crossinline block : STRIKE.() -> Unit = {}) : Unit = STRIKE(attributesMapOf("class", classes), consumer).visit(block) -open class STRIKE(initialAttributes: Map<String, String>, override val consumer: TagConsumer<*>) : +public open class STRIKE(initialAttributes: Map<String, String>, override val consumer: TagConsumer<*>) : HTMLTag("strike", consumer, initialAttributes, null, false, false), HtmlBlockInlineTag @HtmlTagMarker -inline fun FlowOrPhrasingContent.underline(classes : String? = null, crossinline block : UNDERLINE.() -> Unit = {}) : Unit = UNDERLINE(attributesMapOf("class", classes), consumer).visit(block) +public inline fun FlowOrPhrasingContent.underline(classes : String? = null, crossinline block : UNDERLINE.() -> Unit = {}) : Unit = UNDERLINE(attributesMapOf("class", classes), consumer).visit(block) -open class UNDERLINE(initialAttributes: Map<String, String>, override val consumer: TagConsumer<*>) : +public open class UNDERLINE(initialAttributes: Map<String, String>, override val consumer: TagConsumer<*>) : HTMLTag("u", consumer, initialAttributes, null, false, false), HtmlBlockInlineTag -const val TEMPLATE_COMMAND_SEPARATOR = ":" -const val TEMPLATE_COMMAND_BEGIN_BORDER = "[+]cmd" -const val TEMPLATE_COMMAND_END_BORDER = "[-]cmd" +public const val TEMPLATE_COMMAND_SEPARATOR: String = ":" +public const val TEMPLATE_COMMAND_BEGIN_BORDER: String = "[+]cmd" +public const val TEMPLATE_COMMAND_END_BORDER: String = "[-]cmd" -fun FlowOrMetaDataContent.templateCommandAsHtmlComment(data: Command, block: FlowOrMetaDataContent.() -> Unit = {}): Unit = +public fun FlowOrMetaDataContent.templateCommandAsHtmlComment(data: Command, block: FlowOrMetaDataContent.() -> Unit = {}): Unit = (consumer as? ImmediateResolutionTagConsumer)?.processCommand(data, block) ?: let{ comment( "$TEMPLATE_COMMAND_BEGIN_BORDER$TEMPLATE_COMMAND_SEPARATOR${toJsonString(data)}") @@ -48,24 +48,24 @@ fun FlowOrMetaDataContent.templateCommandAsHtmlComment(data: Command, block: Flo comment(TEMPLATE_COMMAND_END_BORDER) } -fun <T: Appendable> T.templateCommandAsHtmlComment(command: Command, action: T.() -> Unit ) { +public fun <T: Appendable> T.templateCommandAsHtmlComment(command: Command, action: T.() -> Unit ) { append("<!--$TEMPLATE_COMMAND_BEGIN_BORDER$TEMPLATE_COMMAND_SEPARATOR${toJsonString(command)}-->") action() append("<!--$TEMPLATE_COMMAND_END_BORDER-->") } -fun FlowOrMetaDataContent.templateCommand(data: Command, block: TemplateBlock = {}): Unit = +public fun FlowOrMetaDataContent.templateCommand(data: Command, block: TemplateBlock = {}): Unit = (consumer as? ImmediateResolutionTagConsumer)?.processCommand(data, block) ?: TemplateCommand(attributesMapOf("data", toJsonString(data)), consumer).visit(block) -fun <T> TagConsumer<T>.templateCommand(data: Command, block: TemplateBlock = {}): T = +public fun <T> TagConsumer<T>.templateCommand(data: Command, block: TemplateBlock = {}): T = (this as? ImmediateResolutionTagConsumer)?.processCommandAndFinalize(data, block) ?: TemplateCommand(attributesMapOf("data", toJsonString(data)), this).visitAndFinalize(this, block) -fun templateCommandFor(data: Command, consumer: TagConsumer<*>) = +public fun templateCommandFor(data: Command, consumer: TagConsumer<*>): TemplateCommand = TemplateCommand(attributesMapOf("data", toJsonString(data)), consumer) -class TemplateCommand(initialAttributes: Map<String, String>, consumer: TagConsumer<*>) : +public class TemplateCommand(initialAttributes: Map<String, String>, consumer: TagConsumer<*>) : HTMLTag( "dokka-template-command", consumer, @@ -77,6 +77,6 @@ class TemplateCommand(initialAttributes: Map<String, String>, consumer: TagConsu CommonAttributeGroupFacadeFlowInteractivePhrasingContent // This hack is outrageous. I hate it but I cannot find any other way around `kotlinx.html` type system. -fun TemplateBlock.buildAsInnerHtml(): String = createHTML(prettyPrint = false).run { +public fun TemplateBlock.buildAsInnerHtml(): String = createHTML(prettyPrint = false).run { TemplateCommand(emptyMap, this).visitAndFinalize(this, this@buildAsInnerHtml).substringAfter(">").substringBeforeLast("<") } diff --git a/plugins/base/src/main/kotlin/renderers/html/command/consumers/ImmediateResolutionTagConsumer.kt b/plugins/base/src/main/kotlin/renderers/html/command/consumers/ImmediateResolutionTagConsumer.kt index 78d684fa..9cde1fca 100644 --- a/plugins/base/src/main/kotlin/renderers/html/command/consumers/ImmediateResolutionTagConsumer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/command/consumers/ImmediateResolutionTagConsumer.kt @@ -15,21 +15,23 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.query -class ImmediateResolutionTagConsumer<out R>( +public class ImmediateResolutionTagConsumer<out R>( private val downstream: TagConsumer<R>, private val context: DokkaContext ): TagConsumer<R> by downstream { - fun processCommand(command: Command, block: TemplateBlock) { + + public fun processCommand(command: Command, block: TemplateBlock) { context.plugin<DokkaBase>().query { immediateHtmlCommandConsumer } .find { it.canProcess(command) } ?.processCommand(command, block, this) ?: run { templateCommandFor(command, downstream).visit(block) } } - fun processCommandAndFinalize(command: Command, block: TemplateBlock): R = - context.plugin<DokkaBase>().query { immediateHtmlCommandConsumer } + public fun processCommandAndFinalize(command: Command, block: TemplateBlock): R { + return context.plugin<DokkaBase>().query { immediateHtmlCommandConsumer } .find { it.canProcess(command) } ?.processCommandAndFinalize(command, block, this) ?: downstream.templateCommand(command, block) + } } diff --git a/plugins/base/src/main/kotlin/renderers/html/command/consumers/PathToRootConsumer.kt b/plugins/base/src/main/kotlin/renderers/html/command/consumers/PathToRootConsumer.kt index a05d7f42..9ac6eb91 100644 --- a/plugins/base/src/main/kotlin/renderers/html/command/consumers/PathToRootConsumer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/command/consumers/PathToRootConsumer.kt @@ -10,8 +10,8 @@ import org.jetbrains.dokka.base.templating.Command import org.jetbrains.dokka.base.templating.ImmediateHtmlCommandConsumer import org.jetbrains.dokka.base.templating.PathToRootSubstitutionCommand -object PathToRootConsumer: ImmediateHtmlCommandConsumer { - override fun canProcess(command: Command) = command is PathToRootSubstitutionCommand +public object PathToRootConsumer: ImmediateHtmlCommandConsumer { + override fun canProcess(command: Command): Boolean = command is PathToRootSubstitutionCommand override fun <R> processCommand(command: Command, block: TemplateBlock, tagConsumer: ImmediateResolutionTagConsumer<R>) { command as PathToRootSubstitutionCommand diff --git a/plugins/base/src/main/kotlin/renderers/html/command/consumers/ReplaceVersionsConsumer.kt b/plugins/base/src/main/kotlin/renderers/html/command/consumers/ReplaceVersionsConsumer.kt index bec33799..dd95c202 100644 --- a/plugins/base/src/main/kotlin/renderers/html/command/consumers/ReplaceVersionsConsumer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/command/consumers/ReplaceVersionsConsumer.kt @@ -10,8 +10,8 @@ import org.jetbrains.dokka.base.templating.ImmediateHtmlCommandConsumer import org.jetbrains.dokka.base.templating.ReplaceVersionsCommand import org.jetbrains.dokka.plugability.DokkaContext -class ReplaceVersionsConsumer(private val context: DokkaContext) : ImmediateHtmlCommandConsumer { - override fun canProcess(command: Command) = command is ReplaceVersionsCommand +public class ReplaceVersionsConsumer(private val context: DokkaContext) : ImmediateHtmlCommandConsumer { + override fun canProcess(command: Command): Boolean = command is ReplaceVersionsCommand override fun <R> processCommand( command: Command, diff --git a/plugins/base/src/main/kotlin/renderers/html/command/consumers/ResolveLinkConsumer.kt b/plugins/base/src/main/kotlin/renderers/html/command/consumers/ResolveLinkConsumer.kt index 25f079d0..292e88b0 100644 --- a/plugins/base/src/main/kotlin/renderers/html/command/consumers/ResolveLinkConsumer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/command/consumers/ResolveLinkConsumer.kt @@ -15,8 +15,8 @@ import org.jetbrains.dokka.base.templating.ImmediateHtmlCommandConsumer import org.jetbrains.dokka.base.templating.ResolveLinkCommand import org.jetbrains.dokka.utilities.htmlEscape -object ResolveLinkConsumer: ImmediateHtmlCommandConsumer { - override fun canProcess(command: Command) = command is ResolveLinkCommand +public object ResolveLinkConsumer: ImmediateHtmlCommandConsumer { + override fun canProcess(command: Command): Boolean = command is ResolveLinkCommand override fun <R> processCommand(command: Command, block: TemplateBlock, tagConsumer: ImmediateResolutionTagConsumer<R>) { command as ResolveLinkCommand diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt b/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt index 1754ea32..b6ce4147 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt @@ -7,7 +7,7 @@ package org.jetbrains.dokka.base.renderers.html import kotlinx.html.FlowContent import kotlinx.html.span -fun FlowContent.buildTextBreakableAfterCapitalLetters(name: String, hasLastElement: Boolean = false) { +public fun FlowContent.buildTextBreakableAfterCapitalLetters(name: String, hasLastElement: Boolean = false) { if (name.contains(" ")) { val withOutSpaces = name.split(" ") withOutSpaces.dropLast(1).forEach { @@ -23,7 +23,7 @@ fun FlowContent.buildTextBreakableAfterCapitalLetters(name: String, hasLastEleme } } -fun FlowContent.buildBreakableDotSeparatedHtml(name: String) { +public fun FlowContent.buildBreakableDotSeparatedHtml(name: String) { val phrases = name.split(".") phrases.forEachIndexed { i, e -> val elementWithOptionalDot = e.takeIf { i == phrases.lastIndex } ?: "$e." @@ -61,6 +61,7 @@ private fun FlowContent.buildBreakableHtmlElement(element: String, last: Boolean } } -fun FlowContent.buildBreakableText(name: String) = +public fun FlowContent.buildBreakableText(name: String) { if (name.contains(".")) buildBreakableDotSeparatedHtml(name) else buildTextBreakableAfterCapitalLetters(name, hasLastElement = true) +} diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index 349fa1a0..dc877605 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -15,7 +15,9 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.configuration import org.jetbrains.dokka.transformers.pages.PageTransformer -open class NavigationPageInstaller(val context: DokkaContext) : NavigationDataProvider(context), PageTransformer { +public open class NavigationPageInstaller( + public val context: DokkaContext +) : NavigationDataProvider(context), PageTransformer { override fun invoke(input: RootPageNode): RootPageNode = input.modified( children = input.children + NavigationPage( @@ -26,7 +28,9 @@ open class NavigationPageInstaller(val context: DokkaContext) : NavigationDataPr ) } -class CustomResourceInstaller(val dokkaContext: DokkaContext) : PageTransformer { +public class CustomResourceInstaller( + public val dokkaContext: DokkaContext +) : PageTransformer { private val configuration = configuration<DokkaBase, DokkaBaseConfiguration>(dokkaContext) private val customAssets = configuration?.customAssets?.map { @@ -48,7 +52,7 @@ class CustomResourceInstaller(val dokkaContext: DokkaContext) : PageTransformer } } -class ScriptsInstaller(private val dokkaContext: DokkaContext) : PageTransformer { +public class ScriptsInstaller(private val dokkaContext: DokkaContext) : PageTransformer { // scripts ending with `_deferred.js` are loaded with `defer`, otherwise `async` private val scriptsPages = listOf( @@ -76,7 +80,7 @@ class ScriptsInstaller(private val dokkaContext: DokkaContext) : PageTransformer } } -class StylesInstaller(private val dokkaContext: DokkaContext) : PageTransformer { +public class StylesInstaller(private val dokkaContext: DokkaContext) : PageTransformer { private val stylesPages = listOf( "styles/style.css", "styles/main.css", @@ -96,7 +100,7 @@ class StylesInstaller(private val dokkaContext: DokkaContext) : PageTransformer } } -object AssetsInstaller : PageTransformer { +public object AssetsInstaller : PageTransformer { private val imagesPages = listOf( "images/arrow_down.svg", "images/logo-icon.svg", @@ -127,7 +131,7 @@ object AssetsInstaller : PageTransformer { "images/nav-icons/typealias-kotlin.svg", ) - override fun invoke(input: RootPageNode) = input.modified( + override fun invoke(input: RootPageNode): RootPageNode = input.modified( children = input.children + imagesPages.toRenderSpecificResourcePage() ) } @@ -135,7 +139,9 @@ object AssetsInstaller : PageTransformer { private fun List<String>.toRenderSpecificResourcePage(): List<RendererSpecificResourcePage> = map { RendererSpecificResourcePage(it, emptyList(), RenderingStrategy.Copy("/dokka/$it")) } -class SourcesetDependencyAppender(val context: DokkaContext) : PageTransformer { +public class SourcesetDependencyAppender( + public val context: DokkaContext +) : PageTransformer { private val name = "scripts/sourceset_dependencies.js" override fun invoke(input: RootPageNode): RootPageNode { val dependenciesMap = context.configuration.sourceSets.associate { diff --git a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt index 8402d236..3883bc4a 100644 --- a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt +++ b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt @@ -30,7 +30,9 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.configuration import java.net.URI -class DefaultTemplateModelFactory(val context: DokkaContext) : TemplateModelFactory { +public class DefaultTemplateModelFactory( + public val context: DokkaContext +) : TemplateModelFactory { private val configuration = configuration<DokkaBase, DokkaBaseConfiguration>(context) private val isPartial = context.configuration.delayTemplateSubstitution @@ -38,7 +40,7 @@ class DefaultTemplateModelFactory(val context: DokkaContext) : TemplateModelFact if (context.configuration.delayTemplateSubstitution || this is ImmediateResolutionTagConsumer) this else ImmediateResolutionTagConsumer(this, context) - data class SourceSetModel(val name: String, val platform: String, val filter: String) + public data class SourceSetModel(val name: String, val platform: String, val filter: String) override fun buildModel( page: PageNode, diff --git a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelMerger.kt b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelMerger.kt index 4f4f4f78..2f17183d 100644 --- a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelMerger.kt +++ b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelMerger.kt @@ -4,7 +4,7 @@ package org.jetbrains.dokka.base.renderers.html.innerTemplating -class DefaultTemplateModelMerger : TemplateModelMerger { +public class DefaultTemplateModelMerger : TemplateModelMerger { override fun invoke( factories: List<TemplateModelFactory>, buildModel: TemplateModelFactory.() -> TemplateMap diff --git a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/HtmlTemplater.kt b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/HtmlTemplater.kt index cfd6b2c7..1638c9c0 100644 --- a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/HtmlTemplater.kt +++ b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/HtmlTemplater.kt @@ -17,13 +17,15 @@ import org.jetbrains.dokka.plugability.configuration import java.io.StringWriter -enum class DokkaTemplateTypes(val path: String) { +public enum class DokkaTemplateTypes( + public val path: String +) { BASE("base.ftl") } -typealias TemplateMap = Map<String, Any?> +public typealias TemplateMap = Map<String, Any?> -class HtmlTemplater( +public class HtmlTemplater( context: DokkaContext ) { @@ -60,11 +62,11 @@ class HtmlTemplater( templateUpdateDelayMilliseconds = Long.MAX_VALUE } - fun setupSharedModel(model: TemplateMap) { + public fun setupSharedModel(model: TemplateMap) { templaterConfiguration.setSharedVariables(model) } - fun renderFromTemplate( + public fun renderFromTemplate( templateType: DokkaTemplateTypes, generateModel: () -> TemplateMap ): String { diff --git a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelFactory.kt b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelFactory.kt index a669ee4d..3af11bf9 100644 --- a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelFactory.kt +++ b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelFactory.kt @@ -7,13 +7,13 @@ package org.jetbrains.dokka.base.renderers.html.innerTemplating import org.jetbrains.dokka.base.resolvers.local.LocationProvider import org.jetbrains.dokka.pages.PageNode -interface TemplateModelFactory { - fun buildModel( +public interface TemplateModelFactory { + public fun buildModel( page: PageNode, resources: List<String>, locationProvider: LocationProvider, content: String ): TemplateMap - fun buildSharedModel(): TemplateMap + public fun buildSharedModel(): TemplateMap } diff --git a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelMerger.kt b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelMerger.kt index a28aca77..ada0c6cd 100644 --- a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelMerger.kt +++ b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelMerger.kt @@ -4,6 +4,6 @@ package org.jetbrains.dokka.base.renderers.html.innerTemplating -fun interface TemplateModelMerger { - fun invoke(factories: List<TemplateModelFactory>, buildModel: TemplateModelFactory.() -> TemplateMap): TemplateMap +public fun interface TemplateModelMerger { + public fun invoke(factories: List<TemplateModelFactory>, buildModel: TemplateModelFactory.() -> TemplateMap): TemplateMap } diff --git a/plugins/base/src/main/kotlin/renderers/preprocessors.kt b/plugins/base/src/main/kotlin/renderers/preprocessors.kt index c18748f4..a3a32651 100644 --- a/plugins/base/src/main/kotlin/renderers/preprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/preprocessors.kt @@ -9,19 +9,21 @@ import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.pages.PageTransformer -object RootCreator : PageTransformer { - override fun invoke(input: RootPageNode) = +public object RootCreator : PageTransformer { + override fun invoke(input: RootPageNode): RootPageNode = RendererSpecificRootPage("", listOf(input), RenderingStrategy.DoNothing) } -class PackageListCreator( - val context: DokkaContext, - val format: LinkFormat, - val outputFilesNames: List<String> = listOf("package-list") +public class PackageListCreator( + public val context: DokkaContext, + public val format: LinkFormat, + public val outputFilesNames: List<String> = listOf("package-list") ) : PageTransformer { - override fun invoke(input: RootPageNode) = input.transformPageNodeTree { pageNode -> + override fun invoke(input: RootPageNode): RootPageNode { + return input.transformPageNodeTree { pageNode -> pageNode.takeIf { it is ModulePage }?.let { it.modified(children = it.children + packageList(input, it as ModulePage)) } ?: pageNode } + } private fun packageList(rootPageNode: RootPageNode, module: ModulePage): List<RendererSpecificPage> { val content = PackageListService(context, rootPageNode).createPackageList( diff --git a/plugins/base/src/main/kotlin/resolvers/anchors/AnchorsHint.kt b/plugins/base/src/main/kotlin/resolvers/anchors/AnchorsHint.kt index a50fdcb2..c9218947 100644 --- a/plugins/base/src/main/kotlin/resolvers/anchors/AnchorsHint.kt +++ b/plugins/base/src/main/kotlin/resolvers/anchors/AnchorsHint.kt @@ -9,11 +9,11 @@ import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.pages.ContentNode import org.jetbrains.dokka.pages.Kind -data class SymbolAnchorHint(val anchorName: String, val contentKind: Kind) : ExtraProperty<ContentNode> { +public data class SymbolAnchorHint(val anchorName: String, val contentKind: Kind) : ExtraProperty<ContentNode> { override val key: ExtraProperty.Key<ContentNode, SymbolAnchorHint> = SymbolAnchorHint - companion object : ExtraProperty.Key<ContentNode, SymbolAnchorHint> { - fun from(d: Documentable, contentKind: Kind): SymbolAnchorHint? = + public companion object : ExtraProperty.Key<ContentNode, SymbolAnchorHint> { + public fun from(d: Documentable, contentKind: Kind): SymbolAnchorHint? = d.name?.let { SymbolAnchorHint(it, contentKind) } } } diff --git a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt index 1e4cc8dd..32825303 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt @@ -9,12 +9,12 @@ import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.plugability.DokkaContext -open class DefaultExternalLocationProvider( - val externalDocumentation: ExternalDocumentation, - val extension: String, - val dokkaContext: DokkaContext +public open class DefaultExternalLocationProvider( + public val externalDocumentation: ExternalDocumentation, + public val extension: String, + public val dokkaContext: DokkaContext ) : ExternalLocationProvider { - val docURL = externalDocumentation.documentationURL.toString().removeSuffix("/") + "/" + public val docURL: String = externalDocumentation.documentationURL.toString().removeSuffix("/") + "/" override fun resolve(dri: DRI): String? { externalDocumentation.packageList.locations[dri.toString()]?.let { path -> return "$docURL$path" } diff --git a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt index 62135446..09ddca01 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt @@ -7,17 +7,22 @@ package org.jetbrains.dokka.base.resolvers.external import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat import org.jetbrains.dokka.plugability.DokkaContext -class DefaultExternalLocationProviderFactory(val context: DokkaContext) : - ExternalLocationProviderFactory by ExternalLocationProviderFactoryWithCache( - { doc -> - when (doc.packageList.linkFormat) { - RecognizedLinkFormat.KotlinWebsite, - RecognizedLinkFormat.KotlinWebsiteHtml, - RecognizedLinkFormat.DokkaOldHtml -> Dokka010ExternalLocationProvider(doc, ".html", context) - RecognizedLinkFormat.DokkaHtml -> DefaultExternalLocationProvider(doc, ".html", context) - RecognizedLinkFormat.DokkaGFM, - RecognizedLinkFormat.DokkaJekyll -> DefaultExternalLocationProvider(doc, ".md", context) - else -> null - } +public class DefaultExternalLocationProviderFactory( + public val context: DokkaContext, +) : ExternalLocationProviderFactory by ExternalLocationProviderFactoryWithCache( + { doc -> + when (doc.packageList.linkFormat) { + RecognizedLinkFormat.KotlinWebsite, + RecognizedLinkFormat.KotlinWebsiteHtml, + RecognizedLinkFormat.DokkaOldHtml, + -> Dokka010ExternalLocationProvider(doc, ".html", context) + + RecognizedLinkFormat.DokkaHtml -> DefaultExternalLocationProvider(doc, ".html", context) + RecognizedLinkFormat.DokkaGFM, + RecognizedLinkFormat.DokkaJekyll, + -> DefaultExternalLocationProvider(doc, ".md", context) + + else -> null } - ) + } +) diff --git a/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt index 0e94ceb4..f887c9bc 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt @@ -10,12 +10,12 @@ import org.jetbrains.dokka.links.Callable import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.plugability.DokkaContext -open class Dokka010ExternalLocationProvider( - val externalDocumentation: ExternalDocumentation, - val extension: String, - val dokkaContext: DokkaContext +public open class Dokka010ExternalLocationProvider( + public val externalDocumentation: ExternalDocumentation, + public val extension: String, + public val dokkaContext: DokkaContext ) : ExternalLocationProvider { - val docURL = externalDocumentation.documentationURL.toString().removeSuffix("/") + "/" + public val docURL: String = externalDocumentation.documentationURL.toString().removeSuffix("/") + "/" override fun resolve(dri: DRI): String? { diff --git a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProvider.kt index 599dfc87..238b6342 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProvider.kt @@ -9,10 +9,10 @@ import org.jetbrains.dokka.links.DRI /** * Provides the path to the page documenting a [DRI] in an external documentation source */ -fun interface ExternalLocationProvider { +public fun interface ExternalLocationProvider { /** * @return Path to the page containing the [dri] or null if the path cannot be created * (eg. when the package-list does not contain [dri]'s package) */ - fun resolve(dri: DRI): String? + public fun resolve(dri: DRI): String? } diff --git a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt index 517024e4..952f4d51 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt @@ -6,6 +6,6 @@ package org.jetbrains.dokka.base.resolvers.external import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation -fun interface ExternalLocationProviderFactory { - fun getExternalLocationProvider(doc: ExternalDocumentation): ExternalLocationProvider? +public fun interface ExternalLocationProviderFactory { + public fun getExternalLocationProvider(doc: ExternalDocumentation): ExternalLocationProvider? } diff --git a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactoryWithCache.kt b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactoryWithCache.kt index 12b1b7eb..0b56e174 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactoryWithCache.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactoryWithCache.kt @@ -7,8 +7,9 @@ package org.jetbrains.dokka.base.resolvers.external import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation import java.util.concurrent.ConcurrentHashMap -class ExternalLocationProviderFactoryWithCache(val ext: ExternalLocationProviderFactory) : - ExternalLocationProviderFactory { +public class ExternalLocationProviderFactoryWithCache( + public val ext: ExternalLocationProviderFactory +) : ExternalLocationProviderFactory { private val locationProviders = ConcurrentHashMap<ExternalDocumentation, CacheWrapper>() diff --git a/plugins/base/src/main/kotlin/resolvers/external/javadoc/AndroidExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/javadoc/AndroidExternalLocationProvider.kt index e90adf6f..8c18be0c 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/AndroidExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/javadoc/AndroidExternalLocationProvider.kt @@ -8,11 +8,11 @@ import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation import org.jetbrains.dokka.links.Callable import org.jetbrains.dokka.plugability.DokkaContext -open class AndroidExternalLocationProvider( +public open class AndroidExternalLocationProvider( externalDocumentation: ExternalDocumentation, dokkaContext: DokkaContext ) : JavadocExternalLocationProvider(externalDocumentation, "", "", dokkaContext) { - override fun anchorPart(callable: Callable) = callable.name.toLowerCase() + override fun anchorPart(callable: Callable): String = callable.name.toLowerCase() } diff --git a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt index d7351556..65ee0e02 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt @@ -13,10 +13,10 @@ import org.jetbrains.dokka.links.EnumEntryDRIExtra import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.utilities.htmlEscape -open class JavadocExternalLocationProvider( +public open class JavadocExternalLocationProvider( externalDocumentation: ExternalDocumentation, - val brackets: String, - val separator: String, + public val brackets: String, + public val separator: String, dokkaContext: DokkaContext ) : DefaultExternalLocationProvider(externalDocumentation, ".html", dokkaContext) { @@ -53,9 +53,10 @@ open class JavadocExternalLocationProvider( return ("$docWithModule$classLink#" + anchorPart(callableChecked)).htmlEscape() } - protected open fun anchorPart(callable: Callable) = callable.name + - "${brackets.first()}" + - callable.params.joinToString(separator) + - "${brackets.last()}" - + protected open fun anchorPart(callable: Callable): String { + return callable.name + + "${brackets.first()}" + + callable.params.joinToString(separator) + + "${brackets.last()}" + } } diff --git a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt index 6b94a75b..dc184e49 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt @@ -12,24 +12,28 @@ import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProviderFacto import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat import org.jetbrains.dokka.plugability.DokkaContext -class JavadocExternalLocationProviderFactory(val context: DokkaContext) : - ExternalLocationProviderFactory by ExternalLocationProviderFactoryWithCache( - { doc -> - when (doc.packageList.url) { - DokkaConfiguration.ExternalDocumentationLink.androidX().packageListUrl, - DokkaConfiguration.ExternalDocumentationLink.androidSdk().packageListUrl -> - AndroidExternalLocationProvider(doc, context) - else -> - when (doc.packageList.linkFormat) { - RecognizedLinkFormat.Javadoc1 -> - JavadocExternalLocationProvider(doc, "()", ", ", context) // Covers JDK 1 - 7 - RecognizedLinkFormat.Javadoc8 -> - JavadocExternalLocationProvider(doc, "--", "-", context) // Covers JDK 8 - 9 - RecognizedLinkFormat.Javadoc10, - RecognizedLinkFormat.DokkaJavadoc -> - JavadocExternalLocationProvider(doc, "()", ",", context) // Covers JDK 10 - else -> null - } - } +public class JavadocExternalLocationProviderFactory( + public val context: DokkaContext, +) : ExternalLocationProviderFactory by ExternalLocationProviderFactoryWithCache( + { doc -> + when (doc.packageList.url) { + DokkaConfiguration.ExternalDocumentationLink.androidX().packageListUrl, + DokkaConfiguration.ExternalDocumentationLink.androidSdk().packageListUrl, + -> + AndroidExternalLocationProvider(doc, context) + + else -> + when (doc.packageList.linkFormat) { + RecognizedLinkFormat.Javadoc1 -> + JavadocExternalLocationProvider(doc, "()", ", ", context) // Covers JDK 1 - 7 + RecognizedLinkFormat.Javadoc8 -> + JavadocExternalLocationProvider(doc, "--", "-", context) // Covers JDK 8 - 9 + RecognizedLinkFormat.Javadoc10, + RecognizedLinkFormat.DokkaJavadoc, + -> + JavadocExternalLocationProvider(doc, "()", ",", context) // Covers JDK 10 + else -> null + } } - ) + } +) diff --git a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt index 7b9256c2..24d0f13e 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt @@ -8,6 +8,7 @@ import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.resolvers.external.DefaultExternalLocationProvider import org.jetbrains.dokka.base.resolvers.external.Dokka010ExternalLocationProvider import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProvider +import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProviderFactory import org.jetbrains.dokka.base.resolvers.external.javadoc.AndroidExternalLocationProvider import org.jetbrains.dokka.base.resolvers.external.javadoc.JavadocExternalLocationProvider import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation @@ -19,11 +20,11 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.query -abstract class DefaultLocationProvider( +public abstract class DefaultLocationProvider( protected val pageGraphRoot: RootPageNode, protected val dokkaContext: DokkaContext ) : LocationProvider { - protected val externalLocationProviderFactories = + protected val externalLocationProviderFactories: List<ExternalLocationProviderFactory> = dokkaContext.plugin<DokkaBase>().query { externalLocationProviderFactory } protected val externalLocationProviders: Map<ExternalDocumentation, ExternalLocationProvider?> = dokkaContext diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaBaseLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaBaseLocationProvider.kt index 7fe763d9..ca3786ad 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DokkaBaseLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaBaseLocationProvider.kt @@ -11,7 +11,7 @@ import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.utilities.urlEncoded -abstract class DokkaBaseLocationProvider( +public abstract class DokkaBaseLocationProvider( pageGraphRoot: RootPageNode, dokkaContext: DokkaContext ) : DefaultLocationProvider(pageGraphRoot, dokkaContext) { @@ -21,7 +21,7 @@ abstract class DokkaBaseLocationProvider( * The idea is to make them as short as possible and just use a hashCode from sourcesets in order to match the * 2040 characters limit */ - open fun anchorForDCI(dci: DCI, sourceSets: Set<DisplaySourceSet>): String = + public open fun anchorForDCI(dci: DCI, sourceSets: Set<DisplaySourceSet>): String = (dci.dri.shortenToUrl().toString() + "/" + dci.kind + "/" + sourceSets.shortenToUrl()).urlEncoded() } diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt index e6508d0e..aedbfb88 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt @@ -13,12 +13,12 @@ import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import java.util.* -open class DokkaLocationProvider( +public open class DokkaLocationProvider( pageGraphRoot: RootPageNode, dokkaContext: DokkaContext, - val extension: String = ".html" + public val extension: String = ".html" ) : DokkaBaseLocationProvider(pageGraphRoot, dokkaContext) { - protected open val PAGE_WITH_CHILDREN_SUFFIX = "index" + protected open val PAGE_WITH_CHILDREN_SUFFIX: String = "index" protected open val pathsIndex: Map<PageNode, List<String>> = IdentityHashMap<PageNode, List<String>>().apply { fun registerPath(page: PageNode, prefix: List<String>) { @@ -75,7 +75,7 @@ open class DokkaLocationProvider( } }.toMap() - override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean) = + override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean): String = pathTo(node, context) + if (!skipExtension) extension else "" override fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode?): String? = @@ -158,13 +158,13 @@ open class DokkaLocationProvider( protected data class PageWithKind(val page: ContentPage, val kind: Kind) - companion object { - val reservedFilenames = setOf("index", "con", "aux", "lst", "prn", "nul", "eof", "inp", "out") + public companion object { + public val reservedFilenames: Set<String> = setOf("index", "con", "aux", "lst", "prn", "nul", "eof", "inp", "out") //Taken from: https://stackoverflow.com/questions/1976007/what-characters-are-forbidden-in-windows-and-linux-directory-names internal val reservedCharacters = setOf('|', '>', '<', '*', ':', '"', '?', '%') - fun identifierToFilename(name: String): String { + public fun identifierToFilename(name: String): String { if (name.isEmpty()) return "--root--" return sanitizeFileName(name, reservedFilenames, reservedCharacters) } diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProviderFactory.kt index 81602589..bd9fa1bb 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProviderFactory.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProviderFactory.kt @@ -8,11 +8,15 @@ import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import java.util.concurrent.ConcurrentHashMap -class DokkaLocationProviderFactory(private val context: DokkaContext) : LocationProviderFactory { +public class DokkaLocationProviderFactory( + private val context: DokkaContext +) : LocationProviderFactory { private val cache = ConcurrentHashMap<CacheWrapper, LocationProvider>() - override fun getLocationProvider(pageNode: RootPageNode) = cache.computeIfAbsent(CacheWrapper(pageNode)) { - DokkaLocationProvider(pageNode, context) + override fun getLocationProvider(pageNode: RootPageNode): LocationProvider { + return cache.computeIfAbsent(CacheWrapper(pageNode)) { + DokkaLocationProvider(pageNode, context) + } } private class CacheWrapper(val pageNode: RootPageNode) { diff --git a/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt index cfabff7e..dbcd5c76 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt @@ -10,11 +10,11 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.DisplaySourceSet import org.jetbrains.dokka.pages.PageNode -interface LocationProvider { - fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode? = null): String? - fun resolve(node: PageNode, context: PageNode? = null, skipExtension: Boolean = false): String? - fun pathToRoot(from: PageNode): String - fun ancestors(node: PageNode): List<PageNode> +public interface LocationProvider { + public fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode? = null): String? + public fun resolve(node: PageNode, context: PageNode? = null, skipExtension: Boolean = false): String? + public fun pathToRoot(from: PageNode): String + public fun ancestors(node: PageNode): List<PageNode> /** * This method should return guessed filesystem location for a given [DRI] @@ -22,17 +22,26 @@ interface LocationProvider { * generated package-list so it is ok if the path differs from the one returned by [resolve] * @return Path to a giver [DRI] or null if path should not be considered for relocations */ - fun expectedLocationForDri(dri: DRI): String = + public fun expectedLocationForDri(dri: DRI): String = (listOf(dri.packageName) + dri.classNames?.split(".")?.map { identifierToFilename(it) }.orEmpty() + listOf(dri.callable?.let { identifierToFilename(it.name) } ?: "index") ).filterNotNull().joinToString("/") } -fun LocationProvider.resolveOrThrow(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode? = null): String = - resolve(dri = dri, sourceSets = sourceSets, context = context) +public fun LocationProvider.resolveOrThrow( + dri: DRI, sourceSets: Set<DisplaySourceSet>, + context: PageNode? = null +): String { + return resolve(dri = dri, sourceSets = sourceSets, context = context) ?: throw DokkaException("Cannot resolve path for $dri") +} -fun LocationProvider.resolveOrThrow(node: PageNode, context: PageNode? = null, skipExtension: Boolean = false): String = - resolve(node = node, context = context, skipExtension = skipExtension) +public fun LocationProvider.resolveOrThrow( + node: PageNode, + context: PageNode? = null, + skipExtension: Boolean = false +): String { + return resolve(node = node, context = context, skipExtension = skipExtension) ?: throw DokkaException("Cannot resolve path for ${node.name}") +} diff --git a/plugins/base/src/main/kotlin/resolvers/local/LocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/local/LocationProviderFactory.kt index 247d4eaa..31cac868 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/LocationProviderFactory.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/LocationProviderFactory.kt @@ -6,6 +6,6 @@ package org.jetbrains.dokka.base.resolvers.local import org.jetbrains.dokka.pages.RootPageNode -fun interface LocationProviderFactory { - fun getLocationProvider(pageNode: RootPageNode): LocationProvider +public fun interface LocationProviderFactory { + public fun getLocationProvider(pageNode: RootPageNode): LocationProvider } diff --git a/plugins/base/src/main/kotlin/resolvers/shared/ExternalDocumentation.kt b/plugins/base/src/main/kotlin/resolvers/shared/ExternalDocumentation.kt index ac9a189a..db0c5492 100644 --- a/plugins/base/src/main/kotlin/resolvers/shared/ExternalDocumentation.kt +++ b/plugins/base/src/main/kotlin/resolvers/shared/ExternalDocumentation.kt @@ -6,4 +6,4 @@ package org.jetbrains.dokka.base.resolvers.shared import java.net.URL -data class ExternalDocumentation(val documentationURL: URL, val packageList: PackageList) +public data class ExternalDocumentation(val documentationURL: URL, val packageList: PackageList) diff --git a/plugins/base/src/main/kotlin/resolvers/shared/LinkFormat.kt b/plugins/base/src/main/kotlin/resolvers/shared/LinkFormat.kt index ad21ac6f..4f0d4932 100644 --- a/plugins/base/src/main/kotlin/resolvers/shared/LinkFormat.kt +++ b/plugins/base/src/main/kotlin/resolvers/shared/LinkFormat.kt @@ -4,7 +4,7 @@ package org.jetbrains.dokka.base.resolvers.shared -interface LinkFormat { - val formatName: String - val linkExtension: String +public interface LinkFormat { + public val formatName: String + public val linkExtension: String } diff --git a/plugins/base/src/main/kotlin/resolvers/shared/PackageList.kt b/plugins/base/src/main/kotlin/resolvers/shared/PackageList.kt index ce45db98..8297f875 100644 --- a/plugins/base/src/main/kotlin/resolvers/shared/PackageList.kt +++ b/plugins/base/src/main/kotlin/resolvers/shared/PackageList.kt @@ -6,9 +6,9 @@ package org.jetbrains.dokka.base.resolvers.shared import java.net.URL -typealias Module = String +public typealias Module = String -data class PackageList( +public data class PackageList( val linkFormat: RecognizedLinkFormat, val modules: Map<Module, Set<String>>, val locations: Map<String, String>, @@ -17,17 +17,19 @@ data class PackageList( val packages: Set<String> get() = modules.values.flatten().toSet() - fun moduleFor(packageName: String) = modules.asSequence() + public fun moduleFor(packageName: String): Module? { + return modules.asSequence() .filter { it.value.contains(packageName) } .firstOrNull()?.key + } - companion object { - const val PACKAGE_LIST_NAME = "package-list" - const val MODULE_DELIMITER = "module:" - const val DOKKA_PARAM_PREFIX = "\$dokka" - const val SINGLE_MODULE_NAME = "" + public companion object { + public const val PACKAGE_LIST_NAME: String = "package-list" + public const val MODULE_DELIMITER: String = "module:" + public const val DOKKA_PARAM_PREFIX: String = "\$dokka" + public const val SINGLE_MODULE_NAME: String = "" - fun load(url: URL, jdkVersion: Int, offlineMode: Boolean = false): PackageList? { + public fun load(url: URL, jdkVersion: Int, offlineMode: Boolean = false): PackageList? { if (offlineMode && url.protocol.toLowerCase() != "file") return null diff --git a/plugins/base/src/main/kotlin/resolvers/shared/RecognizedLinkFormat.kt b/plugins/base/src/main/kotlin/resolvers/shared/RecognizedLinkFormat.kt index 7902fd09..4810c9e5 100644 --- a/plugins/base/src/main/kotlin/resolvers/shared/RecognizedLinkFormat.kt +++ b/plugins/base/src/main/kotlin/resolvers/shared/RecognizedLinkFormat.kt @@ -4,7 +4,10 @@ package org.jetbrains.dokka.base.resolvers.shared -enum class RecognizedLinkFormat(override val formatName: String, override val linkExtension: String) : LinkFormat { +public enum class RecognizedLinkFormat( + override val formatName: String, + override val linkExtension: String +) : LinkFormat { DokkaHtml("html-v1", "html"), DokkaJavadoc("javadoc-v1", "html"), DokkaGFM("gfm-v1", "md"), @@ -16,8 +19,11 @@ enum class RecognizedLinkFormat(override val formatName: String, override val li KotlinWebsite("kotlin-website", "html"), KotlinWebsiteHtml("kotlin-website-html", "html"); - companion object { - fun fromString(formatName: String) = - values().firstOrNull { it.formatName == formatName } + public companion object { + private val values = values() + + public fun fromString(formatName: String): RecognizedLinkFormat? { + return values.firstOrNull { it.formatName == formatName } + } } } diff --git a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt index f46b5100..e5f85803 100644 --- a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt +++ b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt @@ -13,35 +13,39 @@ import org.jetbrains.dokka.model.AnnotationTarget import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.dokka.pages.* -interface JvmSignatureUtils { +public interface JvmSignatureUtils { - fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: AnnotationTarget) + public fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: AnnotationTarget) - fun PageContentBuilder.DocumentableContentBuilder.annotationsInline(d: AnnotationTarget) + public fun PageContentBuilder.DocumentableContentBuilder.annotationsInline(d: AnnotationTarget) - fun <T : Documentable> WithExtraProperties<T>.modifiers(): SourceSetDependent<Set<ExtraModifiers>> + public fun <T : Documentable> WithExtraProperties<T>.modifiers(): SourceSetDependent<Set<ExtraModifiers>> - fun Collection<ExtraModifiers>.toSignatureString(): String = + public fun Collection<ExtraModifiers>.toSignatureString(): String = joinToString("") { it.name.toLowerCase() + " " } @Suppress("UNCHECKED_CAST") - fun Documentable.annotations() = (this as? WithExtraProperties<Documentable>)?.annotations() ?: emptyMap() + public fun Documentable.annotations(): Map<DokkaSourceSet, List<Annotations.Annotation>> { + return (this as? WithExtraProperties<Documentable>)?.annotations() ?: emptyMap() + } - fun <T : AnnotationTarget> WithExtraProperties<T>.annotations(): SourceSetDependent<List<Annotations.Annotation>> = + public fun <T : AnnotationTarget> WithExtraProperties<T>.annotations(): SourceSetDependent<List<Annotations.Annotation>> = extra[Annotations]?.directAnnotations ?: emptyMap() @Suppress("UNCHECKED_CAST") - operator fun <T : Iterable<*>> SourceSetDependent<T>.plus(other: SourceSetDependent<T>): SourceSetDependent<T> = - LinkedHashMap(this).apply { + public operator fun <T : Iterable<*>> SourceSetDependent<T>.plus(other: SourceSetDependent<T>): SourceSetDependent<T> { + return LinkedHashMap(this).apply { for ((k, v) in other) { put(k, get(k).let { if (it != null) (it + v) as T else v }) } } + } - fun DProperty.annotations(): SourceSetDependent<List<Annotations.Annotation>> = - (extra[Annotations]?.directAnnotations ?: emptyMap()) + - (getter?.annotations() ?: emptyMap()).mapValues { it.value.map { it.copy( scope = Annotations.AnnotationScope.GETTER) } } + - (setter?.annotations() ?: emptyMap()).mapValues { it.value.map { it.copy( scope = Annotations.AnnotationScope.SETTER) } } + public fun DProperty.annotations(): SourceSetDependent<List<Annotations.Annotation>> { + return (extra[Annotations]?.directAnnotations ?: emptyMap()) + + (getter?.annotations() ?: emptyMap()).mapValues { it.value.map { it.copy( scope = Annotations.AnnotationScope.GETTER) } } + + (setter?.annotations() ?: emptyMap()).mapValues { it.value.map { it.copy( scope = Annotations.AnnotationScope.SETTER) } } + } private fun PageContentBuilder.DocumentableContentBuilder.annotations( d: AnnotationTarget, @@ -77,7 +81,7 @@ interface JvmSignatureUtils { } } ?: Unit - fun PageContentBuilder.DocumentableContentBuilder.toSignatureString( + public fun PageContentBuilder.DocumentableContentBuilder.toSignatureString( a: Annotations.Annotation, renderAtStrategy: AtStrategy, listBrackets: Pair<Char, Char>, @@ -143,7 +147,7 @@ interface JvmSignatureUtils { listBrackets?.let{ punctuation(it.second.toString()) } } - fun PageContentBuilder.DocumentableContentBuilder.annotationsBlockWithIgnored( + public fun PageContentBuilder.DocumentableContentBuilder.annotationsBlockWithIgnored( d: AnnotationTarget, ignored: Set<Annotations.Annotation>, renderAtStrategy: AtStrategy, @@ -157,7 +161,7 @@ interface JvmSignatureUtils { } } - fun PageContentBuilder.DocumentableContentBuilder.annotationsInlineWithIgnored( + public fun PageContentBuilder.DocumentableContentBuilder.annotationsInlineWithIgnored( d: AnnotationTarget, ignored: Set<Annotations.Annotation>, renderAtStrategy: AtStrategy, @@ -170,7 +174,7 @@ interface JvmSignatureUtils { } } - fun <T : Documentable> WithExtraProperties<T>.stylesIfDeprecated(sourceSetData: DokkaSourceSet): Set<TextStyle> { + public fun <T : Documentable> WithExtraProperties<T>.stylesIfDeprecated(sourceSetData: DokkaSourceSet): Set<TextStyle> { val directAnnotations = extra[Annotations]?.directAnnotations?.get(sourceSetData) ?: emptyList() val hasAnyDeprecatedAnnotation = directAnnotations.any { it.dri == DRI("kotlin", "Deprecated") || it.dri == DRI("java.lang", "Deprecated") } @@ -178,7 +182,7 @@ interface JvmSignatureUtils { return if (hasAnyDeprecatedAnnotation) setOf(TextStyle.Strikethrough) else emptySet() } - infix fun DFunction.uses(typeParameter: DTypeParameter): Boolean { + public infix fun DFunction.uses(typeParameter: DTypeParameter): Boolean { val parameterDris = parameters.flatMap { listOf(it.dri) + it.type.drisOfAllNestedBounds } val receiverDris = listOfNotNull( @@ -203,8 +207,9 @@ interface JvmSignatureUtils { * ``` * Wrapping and indentation of parameters is applied conditionally, see [shouldWrapParams] */ - fun PageContentBuilder.DocumentableContentBuilder.parametersBlock( - function: DFunction, paramBuilder: PageContentBuilder.DocumentableContentBuilder.(DParameter) -> Unit + public fun PageContentBuilder.DocumentableContentBuilder.parametersBlock( + function: DFunction, + paramBuilder: PageContentBuilder.DocumentableContentBuilder.(DParameter) -> Unit ) { group(kind = SymbolContentKind.Parameters, styles = emptySet()) { function.parameters.dropLast(1).forEach { @@ -220,7 +225,7 @@ interface JvmSignatureUtils { } } -sealed class AtStrategy -object All : AtStrategy() -object OnlyOnce : AtStrategy() -object Never : AtStrategy() +public sealed class AtStrategy +public object All : AtStrategy() +public object OnlyOnce : AtStrategy() +public object Never : AtStrategy() diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index 9294240e..2180e776 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -23,13 +23,16 @@ import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.utilities.DokkaLogger import kotlin.text.Typography.nbsp -class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogger) - : SignatureProvider, JvmSignatureUtils by KotlinSignatureUtils { +public class KotlinSignatureProvider( + ctcc: CommentsToContentConverter, + logger: DokkaLogger +) : SignatureProvider, JvmSignatureUtils by KotlinSignatureUtils { - constructor(context: DokkaContext) : this( + public constructor(context: DokkaContext) : this( context.plugin<DokkaBase>().querySingle { commentsToContentConverter }, context.logger, ) + private val contentBuilder = PageContentBuilder(ctcc, this, logger) private val ignoredVisibilities = setOf(JavaVisibility.Public, KotlinVisibility.Public) diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt index 7999c22e..f16fbeb0 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt @@ -4,6 +4,7 @@ package org.jetbrains.dokka.base.signatures +import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.base.transformers.pages.annotations.SinceKotlinTransformer import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder import org.jetbrains.dokka.links.DRI @@ -14,7 +15,7 @@ import org.jetbrains.dokka.model.AnnotationTarget import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.dokka.pages.ContentKind -object KotlinSignatureUtils : JvmSignatureUtils { +public object KotlinSignatureUtils : JvmSignatureUtils { private const val classExtension = "::class" private val strategy = OnlyOnce @@ -34,21 +35,24 @@ object KotlinSignatureUtils : JvmSignatureUtils { ) - override fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: AnnotationTarget) = + override fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: AnnotationTarget) { annotationsBlockWithIgnored(d, ignoredAnnotations, strategy, listBrackets, classExtension) + } - override fun PageContentBuilder.DocumentableContentBuilder.annotationsInline(d: AnnotationTarget) = + override fun PageContentBuilder.DocumentableContentBuilder.annotationsInline(d: AnnotationTarget) { annotationsInlineWithIgnored(d, ignoredAnnotations, strategy, listBrackets, classExtension) + } - override fun <T : Documentable> WithExtraProperties<T>.modifiers() = - extra[AdditionalModifiers]?.content?.entries?.associate { + override fun <T : Documentable> WithExtraProperties<T>.modifiers(): SourceSetDependent<Set<ExtraModifiers>> { + return extra[AdditionalModifiers]?.content?.entries?.associate { it.key to it.value.filterIsInstance<ExtraModifiers.KotlinOnlyModifiers>().toSet() } ?: emptyMap() + } - val PrimitiveJavaType.dri: DRI get() = DRI("kotlin", name.capitalize()) + public val PrimitiveJavaType.dri: DRI get() = DRI("kotlin", name.capitalize()) - val Bound.driOrNull: DRI? + public val Bound.driOrNull: DRI? get() { return when (this) { is TypeParameter -> dri @@ -64,7 +68,7 @@ object KotlinSignatureUtils : JvmSignatureUtils { } } - val Projection.drisOfAllNestedBounds: List<DRI> get() = when (this) { + public val Projection.drisOfAllNestedBounds: List<DRI> get() = when (this) { is TypeParameter -> listOf(dri) is TypeConstructor -> listOf(dri) + projections.flatMap { it.drisOfAllNestedBounds } is Nullable -> inner.drisOfAllNestedBounds diff --git a/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt index b0b81ea8..76245a40 100644 --- a/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt @@ -7,6 +7,6 @@ package org.jetbrains.dokka.base.signatures import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.pages.ContentNode -fun interface SignatureProvider { - fun signature(documentable: Documentable): List<ContentNode> +public fun interface SignatureProvider { + public fun signature(documentable: Documentable): List<ContentNode> } diff --git a/plugins/base/src/main/kotlin/templating/AddToNavigationCommand.kt b/plugins/base/src/main/kotlin/templating/AddToNavigationCommand.kt index 8bb970e0..03bf8e6a 100644 --- a/plugins/base/src/main/kotlin/templating/AddToNavigationCommand.kt +++ b/plugins/base/src/main/kotlin/templating/AddToNavigationCommand.kt @@ -4,4 +4,6 @@ package org.jetbrains.dokka.base.templating -class AddToNavigationCommand(val moduleName: String) : Command +public class AddToNavigationCommand( + public val moduleName: String +) : Command diff --git a/plugins/base/src/main/kotlin/templating/AddToSearch.kt b/plugins/base/src/main/kotlin/templating/AddToSearch.kt index f69de5c8..8c2ccc79 100644 --- a/plugins/base/src/main/kotlin/templating/AddToSearch.kt +++ b/plugins/base/src/main/kotlin/templating/AddToSearch.kt @@ -6,4 +6,7 @@ package org.jetbrains.dokka.base.templating import org.jetbrains.dokka.base.renderers.html.SearchRecord -data class AddToSearch(val moduleName: String, val elements: List<SearchRecord>): Command +public data class AddToSearch( + val moduleName: String, + val elements: List<SearchRecord> +): Command diff --git a/plugins/base/src/main/kotlin/templating/AddToSourcesetDependencies.kt b/plugins/base/src/main/kotlin/templating/AddToSourcesetDependencies.kt index f7b23c10..c9774e30 100644 --- a/plugins/base/src/main/kotlin/templating/AddToSourcesetDependencies.kt +++ b/plugins/base/src/main/kotlin/templating/AddToSourcesetDependencies.kt @@ -4,4 +4,7 @@ package org.jetbrains.dokka.base.templating -data class AddToSourcesetDependencies(val moduleName: String, val content: Map<String, List<String>>) : Command +public data class AddToSourcesetDependencies( + val moduleName: String, + val content: Map<String, List<String>> +) : Command diff --git a/plugins/base/src/main/kotlin/templating/Command.kt b/plugins/base/src/main/kotlin/templating/Command.kt index 68dfb467..94ed00d4 100644 --- a/plugins/base/src/main/kotlin/templating/Command.kt +++ b/plugins/base/src/main/kotlin/templating/Command.kt @@ -8,8 +8,8 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo import com.fasterxml.jackson.annotation.JsonTypeInfo.Id.CLASS @JsonTypeInfo(use = CLASS) -interface Command +public interface Command -abstract class SubstitutionCommand : Command { - abstract val pattern: String +public abstract class SubstitutionCommand : Command { + public abstract val pattern: String } diff --git a/plugins/base/src/main/kotlin/templating/ImmediateHtmlCommandConsumer.kt b/plugins/base/src/main/kotlin/templating/ImmediateHtmlCommandConsumer.kt index 6653ba4c..f1735490 100644 --- a/plugins/base/src/main/kotlin/templating/ImmediateHtmlCommandConsumer.kt +++ b/plugins/base/src/main/kotlin/templating/ImmediateHtmlCommandConsumer.kt @@ -7,11 +7,11 @@ package org.jetbrains.dokka.base.templating import org.jetbrains.dokka.base.renderers.html.TemplateBlock import org.jetbrains.dokka.base.renderers.html.command.consumers.ImmediateResolutionTagConsumer -interface ImmediateHtmlCommandConsumer { - fun canProcess(command: Command): Boolean +public interface ImmediateHtmlCommandConsumer { + public fun canProcess(command: Command): Boolean - fun <R> processCommand(command: Command, block: TemplateBlock, tagConsumer: ImmediateResolutionTagConsumer<R>) + public fun <R> processCommand(command: Command, block: TemplateBlock, tagConsumer: ImmediateResolutionTagConsumer<R>) - fun <R> processCommandAndFinalize(command: Command, block: TemplateBlock, tagConsumer: ImmediateResolutionTagConsumer<R>): R + public fun <R> processCommandAndFinalize(command: Command, block: TemplateBlock, tagConsumer: ImmediateResolutionTagConsumer<R>): R } diff --git a/plugins/base/src/main/kotlin/templating/InsertTemplateExtra.kt b/plugins/base/src/main/kotlin/templating/InsertTemplateExtra.kt index f762164d..b4316e0f 100644 --- a/plugins/base/src/main/kotlin/templating/InsertTemplateExtra.kt +++ b/plugins/base/src/main/kotlin/templating/InsertTemplateExtra.kt @@ -7,9 +7,9 @@ package org.jetbrains.dokka.base.templating import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.pages.ContentNode -data class InsertTemplateExtra(val command: Command) : ExtraProperty<ContentNode> { +public data class InsertTemplateExtra(val command: Command) : ExtraProperty<ContentNode> { - companion object : ExtraProperty.Key<ContentNode, InsertTemplateExtra> + public companion object : ExtraProperty.Key<ContentNode, InsertTemplateExtra> override val key: ExtraProperty.Key<ContentNode, *> get() = Companion diff --git a/plugins/base/src/main/kotlin/templating/PathToRootSubstitutionCommand.kt b/plugins/base/src/main/kotlin/templating/PathToRootSubstitutionCommand.kt index f2be66e2..070a38ee 100644 --- a/plugins/base/src/main/kotlin/templating/PathToRootSubstitutionCommand.kt +++ b/plugins/base/src/main/kotlin/templating/PathToRootSubstitutionCommand.kt @@ -4,4 +4,7 @@ package org.jetbrains.dokka.base.templating -data class PathToRootSubstitutionCommand(override val pattern: String, val default: String): SubstitutionCommand() +public data class PathToRootSubstitutionCommand( + override val pattern: String, + val default: String +): SubstitutionCommand() diff --git a/plugins/base/src/main/kotlin/templating/ProjectNameSubstitutionCommand.kt b/plugins/base/src/main/kotlin/templating/ProjectNameSubstitutionCommand.kt index e45d3729..6218530e 100644 --- a/plugins/base/src/main/kotlin/templating/ProjectNameSubstitutionCommand.kt +++ b/plugins/base/src/main/kotlin/templating/ProjectNameSubstitutionCommand.kt @@ -4,4 +4,7 @@ package org.jetbrains.dokka.base.templating -data class ProjectNameSubstitutionCommand(override val pattern: String, val default: String): SubstitutionCommand() +public data class ProjectNameSubstitutionCommand( + override val pattern: String, + val default: String +): SubstitutionCommand() diff --git a/plugins/base/src/main/kotlin/templating/ReplaceVersionsCommand.kt b/plugins/base/src/main/kotlin/templating/ReplaceVersionsCommand.kt index 8d2760c3..62a51047 100644 --- a/plugins/base/src/main/kotlin/templating/ReplaceVersionsCommand.kt +++ b/plugins/base/src/main/kotlin/templating/ReplaceVersionsCommand.kt @@ -4,4 +4,4 @@ package org.jetbrains.dokka.base.templating -data class ReplaceVersionsCommand(val location: String = ""): Command +public data class ReplaceVersionsCommand(val location: String = ""): Command diff --git a/plugins/base/src/main/kotlin/templating/ResolveLinkCommand.kt b/plugins/base/src/main/kotlin/templating/ResolveLinkCommand.kt index 6a405bc2..1669b435 100644 --- a/plugins/base/src/main/kotlin/templating/ResolveLinkCommand.kt +++ b/plugins/base/src/main/kotlin/templating/ResolveLinkCommand.kt @@ -6,4 +6,6 @@ package org.jetbrains.dokka.base.templating import org.jetbrains.dokka.links.DRI -class ResolveLinkCommand(val dri: DRI): Command +public class ResolveLinkCommand( + public val dri: DRI +): Command diff --git a/plugins/base/src/main/kotlin/templating/jsonMapperForPlugins.kt b/plugins/base/src/main/kotlin/templating/jsonMapperForPlugins.kt index d7fb1c71..a679a23d 100644 --- a/plugins/base/src/main/kotlin/templating/jsonMapperForPlugins.kt +++ b/plugins/base/src/main/kotlin/templating/jsonMapperForPlugins.kt @@ -40,9 +40,9 @@ internal class TypeReference<T> @PublishedApi internal constructor( } } -fun toJsonString(value: Any): String = objectMapper.writeValueAsString(value) +public fun toJsonString(value: Any): String = objectMapper.writeValueAsString(value) -inline fun <reified T : Any> parseJson(json: String): T = parseJson(json, TypeReference()) +public inline fun <reified T : Any> parseJson(json: String): T = parseJson(json, TypeReference()) @PublishedApi internal fun <T : Any> parseJson(json: String, typeReference: TypeReference<T>): T = diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt b/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt index f144979a..dde1a2af 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt @@ -17,10 +17,14 @@ import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer * The transformer should be applied after merging all documentables */ // TODO assign actual [DTypeAlias.expectPresentInSet] an expect source set, currently, [DTypeAlias.expectPresentInSet] always = null -class ActualTypealiasAdder : DocumentableTransformer { +public class ActualTypealiasAdder : DocumentableTransformer { - override fun invoke(original: DModule, context: DokkaContext) = original.generateTypealiasesMap().let { aliases -> - original.copy(packages = original.packages.map { it.copy(classlikes = addActualTypeAliasToClasslikes(it.classlikes, aliases)) }) + override fun invoke(original: DModule, context: DokkaContext): DModule { + return original.generateTypealiasesMap().let { aliases -> + original.copy(packages = original.packages.map { + it.copy(classlikes = addActualTypeAliasToClasslikes(it.classlikes, aliases)) + }) + } } private fun DModule.generateTypealiasesMap(): Map<DRI, DTypeAlias> = diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt index 933b713a..ec53df78 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt @@ -274,8 +274,8 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab ).mergeExtras(this, other) } -data class ClashingDriIdentifier(val value: Set<DokkaConfiguration.DokkaSourceSet>) : ExtraProperty<Documentable> { - companion object : ExtraProperty.Key<Documentable, ClashingDriIdentifier> { +public data class ClashingDriIdentifier(val value: Set<DokkaConfiguration.DokkaSourceSet>) : ExtraProperty<Documentable> { + public companion object : ExtraProperty.Key<Documentable, ClashingDriIdentifier> { override fun mergeStrategyFor( left: ClashingDriIdentifier, right: ClashingDriIdentifier diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt index e6f96240..4905e876 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt @@ -22,8 +22,9 @@ import org.jetbrains.dokka.transformers.documentation.sourceSet * Documentables with [kotlin.Deprecated.level] set to [DeprecationLevel.HIDDEN] * are suppressed regardless of global and package options. */ -class DeprecatedDocumentableFilterTransformer(context: DokkaContext) : - SuppressedByConditionDocumentableFilterTransformer(context) { +public class DeprecatedDocumentableFilterTransformer( + context: DokkaContext +) : SuppressedByConditionDocumentableFilterTransformer(context) { override fun shouldBeSuppressed(d: Documentable): Boolean { val annotations = (d as? WithExtraProperties<*>)?.annotations() ?: return false diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableReplacerTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableReplacerTransformer.kt index eae477d5..10b25a20 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableReplacerTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableReplacerTransformer.kt @@ -8,8 +8,9 @@ import org.jetbrains.dokka.model.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer -abstract class DocumentableReplacerTransformer(val context: DokkaContext) : - PreMergeDocumentableTransformer { +public abstract class DocumentableReplacerTransformer( + public val context: DokkaContext +) : PreMergeDocumentableTransformer { override fun invoke(modules: List<DModule>): List<DModule> = modules.map { module -> val (documentable, wasChanged) = processModule(module) @@ -170,10 +171,12 @@ abstract class DocumentableReplacerTransformer(val context: DokkaContext) : )).let { AnyWithChanges(it, wasChanged) } } - protected open fun processBound(bound: Bound) = when(bound) { - is GenericTypeConstructor -> processGenericTypeConstructor(bound) - is FunctionalTypeConstructor -> processFunctionalTypeConstructor(bound) - else -> AnyWithChanges(bound, false) + protected open fun processBound(bound: Bound): AnyWithChanges<Bound> { + return when(bound) { + is GenericTypeConstructor -> processGenericTypeConstructor(bound) + is FunctionalTypeConstructor -> processFunctionalTypeConstructor(bound) + else -> AnyWithChanges(bound, false) + } } protected open fun processVariance(variance: Variance<*>): AnyWithChanges<Variance<*>> { @@ -198,7 +201,9 @@ abstract class DocumentableReplacerTransformer(val context: DokkaContext) : else -> AnyWithChanges(projection, false) } - protected open fun processGenericTypeConstructor(genericTypeConstructor: GenericTypeConstructor): AnyWithChanges<GenericTypeConstructor> { + protected open fun processGenericTypeConstructor( + genericTypeConstructor: GenericTypeConstructor + ): AnyWithChanges<GenericTypeConstructor> { val projections = genericTypeConstructor.projections.map { processProjection(it) } val wasChanged = projections.any { it.changed } @@ -207,7 +212,9 @@ abstract class DocumentableReplacerTransformer(val context: DokkaContext) : )).let { AnyWithChanges(it, wasChanged) } } - protected open fun processFunctionalTypeConstructor(functionalTypeConstructor: FunctionalTypeConstructor): AnyWithChanges<FunctionalTypeConstructor> { + protected open fun processFunctionalTypeConstructor( + functionalTypeConstructor: FunctionalTypeConstructor + ): AnyWithChanges<FunctionalTypeConstructor> { val projections = functionalTypeConstructor.projections.map { processProjection(it) } val wasChanged = projections.any { it.changed } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt index e7d3c10d..6155a71f 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt @@ -11,12 +11,16 @@ import org.jetbrains.dokka.model.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer -class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMergeDocumentableTransformer { +public class DocumentableVisibilityFilterTransformer( + public val context: DokkaContext +) : PreMergeDocumentableTransformer { - override fun invoke(modules: List<DModule>) = modules.map { original -> - val sourceSet = original.sourceSets.single() - val packageOptions = sourceSet.perPackageOptions - DocumentableVisibilityFilter(packageOptions, sourceSet).processModule(original) + override fun invoke(modules: List<DModule>): List<DModule> { + return modules.map { original -> + val sourceSet = original.sourceSets.single() + val packageOptions = sourceSet.perPackageOptions + DocumentableVisibilityFilter(packageOptions, sourceSet).processModule(original) + } } private class DocumentableVisibilityFilter( diff --git a/plugins/base/src/main/kotlin/transformers/documentables/EmptyModulesFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/EmptyModulesFilterTransformer.kt index 0824db7e..7a2387dc 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/EmptyModulesFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/EmptyModulesFilterTransformer.kt @@ -7,7 +7,7 @@ package org.jetbrains.dokka.base.transformers.documentables import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer -class EmptyModulesFilterTransformer : PreMergeDocumentableTransformer { +public class EmptyModulesFilterTransformer : PreMergeDocumentableTransformer { override fun invoke(modules: List<DModule>): List<DModule> { return modules.filter { it.children.isNotEmpty() } } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/EmptyPackagesFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/EmptyPackagesFilterTransformer.kt index fc5a622d..30ac8f70 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/EmptyPackagesFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/EmptyPackagesFilterTransformer.kt @@ -9,7 +9,9 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer import org.jetbrains.dokka.transformers.documentation.sourceSet -class EmptyPackagesFilterTransformer(val context: DokkaContext) : PreMergeDocumentableTransformer { +public class EmptyPackagesFilterTransformer( + public val context: DokkaContext +) : PreMergeDocumentableTransformer { override fun invoke(modules: List<DModule>): List<DModule> { return modules.mapNotNull(::filterModule) } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ExtensionExtractorTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/ExtensionExtractorTransformer.kt index 79531dfb..e6102622 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ExtensionExtractorTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ExtensionExtractorTransformer.kt @@ -20,8 +20,7 @@ import org.jetbrains.dokka.utilities.parallelForEach import org.jetbrains.dokka.utilities.parallelMap import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin - -class ExtensionExtractorTransformer : DocumentableTransformer { +public class ExtensionExtractorTransformer : DocumentableTransformer { override fun invoke(original: DModule, context: DokkaContext): DModule = runBlocking(Dispatchers.Default) { val classGraph = async { if (!context.configuration.suppressInheritedMembers) @@ -151,11 +150,11 @@ class ExtensionExtractorTransformer : DocumentableTransformer { groupBy(Pair<T, *>::first, Pair<*, U>::second) } -data class CallableExtensions(val extensions: Set<Callable>) : ExtraProperty<Documentable> { - companion object Key : ExtraProperty.Key<Documentable, CallableExtensions> { - override fun mergeStrategyFor(left: CallableExtensions, right: CallableExtensions) = +public data class CallableExtensions(val extensions: Set<Callable>) : ExtraProperty<Documentable> { + public companion object Key : ExtraProperty.Key<Documentable, CallableExtensions> { + override fun mergeStrategyFor(left: CallableExtensions, right: CallableExtensions): MergeStrategy<Documentable> = MergeStrategy.Replace(CallableExtensions(left.extensions + right.extensions)) } - override val key = Key + override val key: Key = Key } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/InheritedEntriesDocumentableFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/InheritedEntriesDocumentableFilterTransformer.kt index 85457571..d9b7053a 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/InheritedEntriesDocumentableFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/InheritedEntriesDocumentableFilterTransformer.kt @@ -9,8 +9,9 @@ import org.jetbrains.dokka.model.InheritedMember import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.dokka.plugability.DokkaContext -class InheritedEntriesDocumentableFilterTransformer(context: DokkaContext) : - SuppressedByConditionDocumentableFilterTransformer(context) { +public class InheritedEntriesDocumentableFilterTransformer( + context: DokkaContext +) : SuppressedByConditionDocumentableFilterTransformer(context) { override fun shouldBeSuppressed(d: Documentable): Boolean { @Suppress("UNCHECKED_CAST") diff --git a/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt index dd660289..2c7d6b89 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt @@ -12,7 +12,7 @@ import org.jetbrains.dokka.model.properties.MergeStrategy import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer -class InheritorsExtractorTransformer : DocumentableTransformer { +public class InheritorsExtractorTransformer : DocumentableTransformer { override fun invoke(original: DModule, context: DokkaContext): DModule = original.generateInheritanceMap().let { inheritanceMap -> original.appendInheritors(inheritanceMap) as DModule } @@ -72,8 +72,10 @@ class InheritorsExtractorTransformer : DocumentableTransformer { } -class InheritorsInfo(val value: SourceSetDependent<List<DRI>>) : ExtraProperty<Documentable> { - companion object : ExtraProperty.Key<Documentable, InheritorsInfo> { +public class InheritorsInfo( + public val value: SourceSetDependent<List<DRI>> +) : ExtraProperty<Documentable> { + public companion object : ExtraProperty.Key<Documentable, InheritorsInfo> { override fun mergeStrategyFor(left: InheritorsInfo, right: InheritorsInfo): MergeStrategy<Documentable> = MergeStrategy.Replace( InheritorsInfo( diff --git a/plugins/base/src/main/kotlin/transformers/documentables/KotlinArrayDocumentableReplacerTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/KotlinArrayDocumentableReplacerTransformer.kt index 81504275..7a360cb8 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/KotlinArrayDocumentableReplacerTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/KotlinArrayDocumentableReplacerTransformer.kt @@ -9,8 +9,9 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.* import org.jetbrains.dokka.plugability.DokkaContext -class KotlinArrayDocumentableReplacerTransformer(context: DokkaContext): - DocumentableReplacerTransformer(context) { +public class KotlinArrayDocumentableReplacerTransformer( + context: DokkaContext +): DocumentableReplacerTransformer(context) { private fun Documentable.isJVM() = sourceSets.any{ it.analysisPlatform == Platform.jvm } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ObviousFunctionsDocumentableFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/ObviousFunctionsDocumentableFilterTransformer.kt index 725be0d8..09c6ac87 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ObviousFunctionsDocumentableFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ObviousFunctionsDocumentableFilterTransformer.kt @@ -9,7 +9,9 @@ import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.ObviousMember import org.jetbrains.dokka.plugability.DokkaContext -class ObviousFunctionsDocumentableFilterTransformer(context: DokkaContext) : SuppressedByConditionDocumentableFilterTransformer(context) { +public class ObviousFunctionsDocumentableFilterTransformer( + context: DokkaContext +) : SuppressedByConditionDocumentableFilterTransformer(context) { override fun shouldBeSuppressed(d: Documentable): Boolean = context.configuration.suppressObviousFunctions && d is DFunction && d.extra[ObviousMember] != null } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/SuppressTagDocumentableFilter.kt b/plugins/base/src/main/kotlin/transformers/documentables/SuppressTagDocumentableFilter.kt index 74069f99..1dbf1262 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/SuppressTagDocumentableFilter.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/SuppressTagDocumentableFilter.kt @@ -9,8 +9,9 @@ import org.jetbrains.dokka.model.dfs import org.jetbrains.dokka.model.doc.Suppress import org.jetbrains.dokka.plugability.DokkaContext -class SuppressTagDocumentableFilter(val dokkaContext: DokkaContext) : - SuppressedByConditionDocumentableFilterTransformer(dokkaContext) { +public class SuppressTagDocumentableFilter( + public val dokkaContext: DokkaContext +) : SuppressedByConditionDocumentableFilterTransformer(dokkaContext) { override fun shouldBeSuppressed(d: Documentable): Boolean = d.documentation.any { (_, docs) -> docs.dfs { it is Suppress } != null } } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/SuppressedByConditionDocumentableFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/SuppressedByConditionDocumentableFilterTransformer.kt index a3bcad3c..4631cece 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/SuppressedByConditionDocumentableFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/SuppressedByConditionDocumentableFilterTransformer.kt @@ -8,15 +8,16 @@ import org.jetbrains.dokka.model.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer -abstract class SuppressedByConditionDocumentableFilterTransformer(val context: DokkaContext) : - PreMergeDocumentableTransformer { +public abstract class SuppressedByConditionDocumentableFilterTransformer( + public val context: DokkaContext +) : PreMergeDocumentableTransformer { override fun invoke(modules: List<DModule>): List<DModule> = modules.map { module -> val (documentable, wasChanged) = processModule(module) documentable.takeIf { wasChanged } ?: module } - abstract fun shouldBeSuppressed(d: Documentable): Boolean + public abstract fun shouldBeSuppressed(d: Documentable): Boolean private fun processModule(module: DModule): DocumentableWithChanges<DModule> { val afterProcessing = module.packages.map { processPackage(it) } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/SuppressedByConfigurationDocumentableFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/SuppressedByConfigurationDocumentableFilterTransformer.kt index 470cfcc7..3195f88d 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/SuppressedByConfigurationDocumentableFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/SuppressedByConfigurationDocumentableFilterTransformer.kt @@ -12,7 +12,9 @@ import org.jetbrains.dokka.transformers.documentation.source import org.jetbrains.dokka.transformers.documentation.sourceSet import java.io.File -class SuppressedByConfigurationDocumentableFilterTransformer(val context: DokkaContext) : PreMergeDocumentableTransformer { +public class SuppressedByConfigurationDocumentableFilterTransformer( + public val context: DokkaContext +) : PreMergeDocumentableTransformer { override fun invoke(modules: List<DModule>): List<DModule> { return modules.mapNotNull(::filterModule) } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/utils.kt b/plugins/base/src/main/kotlin/transformers/documentables/utils.kt index 8f89dfe7..60a6396a 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/utils.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/utils.kt @@ -9,11 +9,11 @@ import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.ExceptionInSupertypes import org.jetbrains.dokka.model.properties.WithExtraProperties -val <T : Documentable> WithExtraProperties<T>.isException: Boolean +public val <T : Documentable> WithExtraProperties<T>.isException: Boolean get() = extra[ExceptionInSupertypes] != null -val <T : Documentable> WithExtraProperties<T>.deprecatedAnnotation +public val <T : Documentable> WithExtraProperties<T>.deprecatedAnnotation: Annotations.Annotation? get() = extra[Annotations]?.let { annotations -> annotations.directAnnotations.values.flatten().firstOrNull { it.isDeprecated() @@ -24,11 +24,12 @@ val <T : Documentable> WithExtraProperties<T>.deprecatedAnnotation * @return true if [T] has [kotlin.Deprecated] or [java.lang.Deprecated] * annotation for **any** source set */ -fun <T : Documentable> WithExtraProperties<T>.isDeprecated() = deprecatedAnnotation != null +public fun <T : Documentable> WithExtraProperties<T>.isDeprecated(): Boolean = deprecatedAnnotation != null /** * @return true for [kotlin.Deprecated] and [java.lang.Deprecated] */ -fun Annotations.Annotation.isDeprecated() = - (this.dri.packageName == "kotlin" && this.dri.classNames == "Deprecated") || +public fun Annotations.Annotation.isDeprecated(): Boolean { + return (this.dri.packageName == "kotlin" && this.dri.classNames == "Deprecated") || (this.dri.packageName == "java.lang" && this.dri.classNames == "Deprecated") +} diff --git a/plugins/base/src/main/kotlin/transformers/pages/annotations/SinceKotlinTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/annotations/SinceKotlinTransformer.kt index 4ef02ffd..9ff5960d 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/annotations/SinceKotlinTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/annotations/SinceKotlinTransformer.kt @@ -18,7 +18,7 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer import org.jetbrains.dokka.utilities.associateWithNotNull -class SinceKotlinVersion constructor(str: String) : Comparable<SinceKotlinVersion> { +public class SinceKotlinVersion(str: String) : Comparable<SinceKotlinVersion> { private val parts: List<Int> = str.split(".").map { it.toInt() } /** @@ -39,7 +39,9 @@ class SinceKotlinVersion constructor(str: String) : Comparable<SinceKotlinVersio override fun toString(): String = parts.joinToString(".") } -class SinceKotlinTransformer(val context: DokkaContext) : DocumentableTransformer { +public class SinceKotlinTransformer( + public val context: DokkaContext +) : DocumentableTransformer { private val minSinceKotlinVersionOfPlatform = mapOf( Platform.common to SinceKotlinVersion("1.0"), @@ -49,7 +51,7 @@ class SinceKotlinTransformer(val context: DokkaContext) : DocumentableTransforme Platform.wasm to SinceKotlinVersion("1.8"), ) - override fun invoke(original: DModule, context: DokkaContext) = original.transform() as DModule + override fun invoke(original: DModule, context: DokkaContext): DModule = original.transform() as DModule private fun <T : Documentable> T.transform(parent: SourceSetDependent<SinceKotlinVersion>? = null): Documentable { val versions = calculateVersions(parent) 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 f57da595..6ca3f8d0 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt @@ -11,8 +11,8 @@ import org.jetbrains.dokka.pages.ContentNode import org.jetbrains.dokka.pages.DCI import org.jetbrains.dokka.pages.Style -interface CommentsToContentConverter { - fun buildContent( +public interface CommentsToContentConverter { + public fun buildContent( docTag: DocTag, dci: DCI, sourceSets: Set<DokkaSourceSet>, 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 dde51cb9..e4e0f53f 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt @@ -14,7 +14,7 @@ import org.jetbrains.dokka.model.toDisplaySourceSets import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.utilities.firstIsInstanceOrNull -open class DocTagToContentConverter : CommentsToContentConverter { +public open class DocTagToContentConverter : CommentsToContentConverter { override fun buildContent( docTag: DocTag, dci: DCI, diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/FallbackPageMergerStrategy.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/FallbackPageMergerStrategy.kt index 4ebe7ae0..80886cc5 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/merger/FallbackPageMergerStrategy.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/merger/FallbackPageMergerStrategy.kt @@ -8,7 +8,9 @@ import org.jetbrains.dokka.pages.ContentPage import org.jetbrains.dokka.pages.PageNode import org.jetbrains.dokka.utilities.DokkaLogger -class FallbackPageMergerStrategy(private val logger: DokkaLogger) : PageMergerStrategy { +public class FallbackPageMergerStrategy( + private val logger: DokkaLogger +) : PageMergerStrategy { override fun tryMerge(pages: List<PageNode>, path: List<String>): List<PageNode> { pages.map { (it as? ContentPage) diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt index 26d97a47..e52c233c 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt @@ -12,7 +12,7 @@ import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.query import org.jetbrains.dokka.transformers.pages.PageTransformer -class PageMerger(context: DokkaContext) : PageTransformer { +public class PageMerger(context: DokkaContext) : PageTransformer { private val strategies: Iterable<PageMergerStrategy> = context.plugin<DokkaBase>().query { pageMergerStrategy } diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/PageMergerStrategy.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMergerStrategy.kt index e9fcc5bf..ea1b1f03 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/merger/PageMergerStrategy.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMergerStrategy.kt @@ -6,8 +6,8 @@ package org.jetbrains.dokka.base.transformers.pages.merger import org.jetbrains.dokka.pages.PageNode -fun interface PageMergerStrategy { +public fun interface PageMergerStrategy { - fun tryMerge(pages: List<PageNode>, path: List<String>): List<PageNode> + public fun tryMerge(pages: List<PageNode>, path: List<String>): List<PageNode> } diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt index c58dc345..864545e6 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt @@ -17,7 +17,9 @@ import org.jetbrains.dokka.utilities.DokkaLogger * Merges [MemberPage] elements that have the same name. * That includes **both** properties and functions. */ -class SameMethodNamePageMergerStrategy(val logger: DokkaLogger) : PageMergerStrategy { +public class SameMethodNamePageMergerStrategy( + public val logger: DokkaLogger +) : PageMergerStrategy { override fun tryMerge(pages: List<PageNode>, path: List<String>): List<PageNode> { val members = pages .filterIsInstance<MemberPageNode>() diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/SourceSetMergingPageTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/SourceSetMergingPageTransformer.kt index 3e16987e..8d52a39d 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/merger/SourceSetMergingPageTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/merger/SourceSetMergingPageTransformer.kt @@ -13,7 +13,7 @@ import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.pages.PageTransformer -class SourceSetMergingPageTransformer(context: DokkaContext) : PageTransformer { +public class SourceSetMergingPageTransformer(context: DokkaContext) : PageTransformer { private val mergedSourceSets = context.configuration.sourceSets.toDisplaySourceSets() .associateBy { sourceSet -> sourceSet.key } 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 cfb82ed2..80eeca7e 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt @@ -17,7 +17,9 @@ import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.transformers.pages.PageTransformer import java.io.File -class SourceLinksTransformer(val context: DokkaContext) : PageTransformer { +public class SourceLinksTransformer( + public val context: DokkaContext +) : PageTransformer { private val builder : PageContentBuilder = PageContentBuilder( context.plugin<DokkaBase>().querySingle { commentsToContentConverter }, @@ -120,8 +122,16 @@ class SourceLinksTransformer(val context: DokkaContext) : PageTransformer { } } -data class SourceLink(val path: String, val url: String, val lineSuffix: String?, val sourceSetData: DokkaSourceSet) { - constructor(sourceLinkDefinition: DokkaConfiguration.SourceLinkDefinition, sourceSetData: DokkaSourceSet) : this( +public data class SourceLink( + val path: String, + val url: String, + val lineSuffix: String?, + val sourceSetData: DokkaSourceSet +) { + public constructor( + sourceLinkDefinition: DokkaConfiguration.SourceLinkDefinition, + sourceSetData: DokkaSourceSet + ) : this( sourceLinkDefinition.localDirectory, sourceLinkDefinition.remoteUrl.toExternalForm(), sourceLinkDefinition.remoteLineSuffix, diff --git a/plugins/base/src/main/kotlin/transformers/pages/tags/CustomTagContentProvider.kt b/plugins/base/src/main/kotlin/transformers/pages/tags/CustomTagContentProvider.kt index 6baa0c15..fcec234f 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/tags/CustomTagContentProvider.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/tags/CustomTagContentProvider.kt @@ -23,21 +23,21 @@ import org.jetbrains.dokka.model.doc.DocTag * Using this provider, we can map custom tags (such as `@usesMathJax`) and generate content for it that * will be displayed on the pages. */ -interface CustomTagContentProvider { +public interface CustomTagContentProvider { /** * Whether this content provider supports given [CustomTagWrapper]. * * Tags can be filtered out either by name or by nested [DocTag] type */ - fun isApplicable(customTag: CustomTagWrapper): Boolean + public fun isApplicable(customTag: CustomTagWrapper): Boolean /** * Full blown content description, most likely to be on a separate page * dedicated to just one element (i.e one class/function), so any * amount of detail should be fine. */ - fun DocumentableContentBuilder.contentForDescription( + public fun DocumentableContentBuilder.contentForDescription( sourceSet: DokkaSourceSet, customTag: CustomTagWrapper ) {} @@ -56,7 +56,7 @@ interface CustomTagContentProvider { * sense to include `@usesMathjax` here, as this information seems * to be more specific and detailed than is needed for a brief. */ - fun DocumentableContentBuilder.contentForBrief( + public fun DocumentableContentBuilder.contentForBrief( sourceSet: DokkaSourceSet, customTag: CustomTagWrapper ) {} diff --git a/plugins/base/src/main/kotlin/transformers/pages/tags/SinceKotlinTagContentProvider.kt b/plugins/base/src/main/kotlin/transformers/pages/tags/SinceKotlinTagContentProvider.kt index e7e3ec0c..7c35f719 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/tags/SinceKotlinTagContentProvider.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/tags/SinceKotlinTagContentProvider.kt @@ -10,11 +10,11 @@ import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder.Doc import org.jetbrains.dokka.model.doc.CustomTagWrapper import org.jetbrains.dokka.pages.TextStyle -object SinceKotlinTagContentProvider : CustomTagContentProvider { +public object SinceKotlinTagContentProvider : CustomTagContentProvider { private const val SINCE_KOTLIN_TAG_NAME = "Since Kotlin" - override fun isApplicable(customTag: CustomTagWrapper) = customTag.name == SINCE_KOTLIN_TAG_NAME + override fun isApplicable(customTag: CustomTagWrapper): Boolean = customTag.name == SINCE_KOTLIN_TAG_NAME override fun DocumentableContentBuilder.contentForDescription( sourceSet: DokkaConfiguration.DokkaSourceSet, diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt index 57cd9522..0b2597d5 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt @@ -12,7 +12,7 @@ import org.jetbrains.dokka.plugability.* import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin -class DefaultDocumentableToPageTranslator( +public class DefaultDocumentableToPageTranslator( context: DokkaContext ) : DocumentableToPageTranslator { private val configuration = configuration<DokkaBase, DokkaBaseConfiguration>(context) diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index ec5fd193..58abee56 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -28,24 +28,26 @@ import kotlin.reflect.KClass internal typealias GroupedTags = Map<KClass<out TagWrapper>, List<Pair<DokkaSourceSet?, TagWrapper>>> -open class DefaultPageCreator( +public open class DefaultPageCreator( configuration: DokkaBaseConfiguration?, commentsToContentConverter: CommentsToContentConverter, signatureProvider: SignatureProvider, - val logger: DokkaLogger, - val customTagContentProviders: List<CustomTagContentProvider> = emptyList(), - val documentableAnalyzer: DocumentableSourceLanguageParser + public val logger: DokkaLogger, + public val customTagContentProviders: List<CustomTagContentProvider> = emptyList(), + public val documentableAnalyzer: DocumentableSourceLanguageParser ) { - protected open val contentBuilder = PageContentBuilder(commentsToContentConverter, signatureProvider, logger) + protected open val contentBuilder: PageContentBuilder = PageContentBuilder( + commentsToContentConverter, signatureProvider, logger + ) - protected val mergeImplicitExpectActualDeclarations = + protected val mergeImplicitExpectActualDeclarations: Boolean = configuration?.mergeImplicitExpectActualDeclarations ?: DokkaBaseConfiguration.mergeImplicitExpectActualDeclarationsDefault - protected val separateInheritedMembers = + protected val separateInheritedMembers: Boolean = configuration?.separateInheritedMembers ?: DokkaBaseConfiguration.separateInheritedMembersDefault - open fun pageForModule(m: DModule): ModulePageNode = + public open fun pageForModule(m: DModule): ModulePageNode = ModulePageNode(m.name.ifEmpty { "<root>" }, contentForModule(m), listOf(m), m.packages.map(::pageForPackage)) /** @@ -59,25 +61,32 @@ open class DefaultPageCreator( return this.filterNot { it is DTypeAlias && this.hasExpectClass(it.dri) } } - open fun pageForPackage(p: DPackage): PackagePageNode = PackagePageNode( - p.name, contentForPackage(p), setOf(p.dri), listOf(p), - if (mergeImplicitExpectActualDeclarations) + public open fun pageForPackage(p: DPackage): PackagePageNode { + val children = if (mergeImplicitExpectActualDeclarations) { (p.classlikes + p.typealiases).filterOutActualTypeAlias() .mergeClashingDocumentable().map(::pageForClasslikes) + p.functions.mergeClashingDocumentable().map(::pageForFunctions) + p.properties.mergeClashingDocumentable().map(::pageForProperties) - else + } else { (p.classlikes + p.typealiases).filterOutActualTypeAlias() .renameClashingDocumentable().map(::pageForClasslike) + p.functions.renameClashingDocumentable().map(::pageForFunction) + p.properties.mapNotNull(::pageForProperty) - ) + } + return PackagePageNode( + name = p.name, + content = contentForPackage(p), + dri = setOf(p.dri), + documentables = listOf(p), + children = children + ) + } - open fun pageForEnumEntry(e: DEnumEntry): ClasslikePageNode = pageForEnumEntries(listOf(e)) + public open fun pageForEnumEntry(e: DEnumEntry): ClasslikePageNode = pageForEnumEntries(listOf(e)) - open fun pageForClasslike(c: Documentable): ClasslikePageNode = pageForClasslikes(listOf(c)) + public open fun pageForClasslike(c: Documentable): ClasslikePageNode = pageForClasslikes(listOf(c)) - open fun pageForEnumEntries(documentables: List<DEnumEntry>): ClasslikePageNode { + public open fun pageForEnumEntries(documentables: List<DEnumEntry>): ClasslikePageNode { val dri = documentables.dri.also { if (it.size != 1) { logger.error("Documentable dri should have the same one ${it.first()} inside the one page!") @@ -105,7 +114,7 @@ open class DefaultPageCreator( /** * @param documentables a list of [DClasslike] and [DTypeAlias] with the same dri in different sourceSets */ - open fun pageForClasslikes(documentables: List<Documentable>): ClasslikePageNode { + public open fun pageForClasslikes(documentables: List<Documentable>): ClasslikePageNode { val dri = documentables.dri.also { if (it.size != 1) { logger.error("Documentable dri should have the same one ${it.first()} inside the one page!") @@ -171,10 +180,10 @@ open class DefaultPageCreator( private fun <T : Documentable> List<T>.mergeClashingDocumentable(): List<List<T>> = groupBy { it.dri }.values.toList() - open fun pageForFunction(f: DFunction) = + public open fun pageForFunction(f: DFunction): MemberPageNode = MemberPageNode(f.nameAfterClash(), contentForFunction(f), setOf(f.dri), listOf(f)) - open fun pageForFunctions(fs: List<DFunction>): MemberPageNode { + public open fun pageForFunctions(fs: List<DFunction>): MemberPageNode { val dri = fs.dri.also { if (it.size != 1) { logger.error("Function dri should have the same one ${it.first()} inside the one page!") @@ -183,10 +192,10 @@ open class DefaultPageCreator( return MemberPageNode(fs.first().nameAfterClash(), contentForMembers(fs), dri, fs) } - open fun pageForProperty(p: DProperty): MemberPageNode? = + public open fun pageForProperty(p: DProperty): MemberPageNode? = MemberPageNode(p.nameAfterClash(), contentForProperty(p), setOf(p.dri), listOf(p)) - open fun pageForProperties(ps: List<DProperty>): MemberPageNode { + public open fun pageForProperties(ps: List<DProperty>): MemberPageNode { val dri = ps.dri.also { if (it.size != 1) { logger.error("Property dri should have the same one ${it.first()} inside the one page!") @@ -223,61 +232,65 @@ open class DefaultPageCreator( private fun <T> Collection<T>.splitInherited(): Pair<List<T>, List<T>> where T : Documentable, T : WithExtraProperties<T> = partition { it.isInherited() } - protected open fun contentForModule(m: DModule) = contentBuilder.contentFor(m) { - group(kind = ContentKind.Cover) { - cover(m.name) - if (contentForDescription(m).isNotEmpty()) { - sourceSetDependentHint( - m.dri, - m.sourceSets.toSet(), - kind = ContentKind.SourceSetDependentHint, - styles = setOf(TextStyle.UnderCoverText) - ) { - +contentForDescription(m) + protected open fun contentForModule(m: DModule): ContentGroup { + return contentBuilder.contentFor(m) { + group(kind = ContentKind.Cover) { + cover(m.name) + if (contentForDescription(m).isNotEmpty()) { + sourceSetDependentHint( + m.dri, + m.sourceSets.toSet(), + kind = ContentKind.SourceSetDependentHint, + styles = setOf(TextStyle.UnderCoverText) + ) { + +contentForDescription(m) + } } } - } - block( - "Packages", - 2, - ContentKind.Packages, - m.packages, - m.sourceSets.toSet(), - needsAnchors = true, - headers = listOf( - headers("Name") - ) - ) { - val documentations = it.sourceSets.map { platform -> - it.descriptions[platform]?.also { it.root } - } - val haveSameContent = - documentations.all { it?.root == documentations.firstOrNull()?.root && it?.root != null } + block( + name = "Packages", + level = 2, + kind = ContentKind.Packages, + elements = m.packages, + sourceSets = m.sourceSets.toSet(), + needsAnchors = true, + headers = listOf( + headers("Name") + ) + ) { + val documentations = it.sourceSets.map { platform -> + it.descriptions[platform]?.also { it.root } + } + val haveSameContent = + documentations.all { it?.root == documentations.firstOrNull()?.root && it?.root != null } - link(it.name, it.dri) - if (it.sourceSets.size == 1 || (documentations.isNotEmpty() && haveSameContent)) { - documentations.first()?.let { firstParagraphComment(kind = ContentKind.Comment, content = it.root) } + link(it.name, it.dri) + if (it.sourceSets.size == 1 || (documentations.isNotEmpty() && haveSameContent)) { + documentations.first()?.let { firstParagraphComment(kind = ContentKind.Comment, content = it.root) } + } } } } - protected open fun contentForPackage(p: DPackage) = contentBuilder.contentFor(p) { - group(kind = ContentKind.Cover) { - cover("Package-level declarations") - if (contentForDescription(p).isNotEmpty()) { - sourceSetDependentHint( - p.dri, - p.sourceSets.toSet(), - kind = ContentKind.SourceSetDependentHint, - styles = setOf(TextStyle.UnderCoverText) - ) { - +contentForDescription(p) + protected open fun contentForPackage(p: DPackage): ContentGroup { + return contentBuilder.contentFor(p) { + group(kind = ContentKind.Cover) { + cover("Package-level declarations") + if (contentForDescription(p).isNotEmpty()) { + sourceSetDependentHint( + dri = p.dri, + sourcesetData = p.sourceSets.toSet(), + kind = ContentKind.SourceSetDependentHint, + styles = setOf(TextStyle.UnderCoverText) + ) { + +contentForDescription(p) + } } } - } - group(styles = setOf(ContentStyle.TabbedContent), extra = mainExtra) { - +contentForScope(p, p.dri, p.sourceSets) + group(styles = setOf(ContentStyle.TabbedContent), extra = mainExtra) { + +contentForScope(p, p.dri, p.sourceSets) + } } } @@ -400,31 +413,32 @@ open class DefaultPageCreator( constructorsToDocumented: List<DFunction>, dri: Set<DRI>, sourceSets: Set<DokkaSourceSet> - ) = contentBuilder.contentFor(dri, sourceSets) { - multiBlock( - "Constructors", - 2, - ContentKind.Constructors, - constructorsToDocumented.groupBy { it.name } - .map { (_, v) -> v.first().name to v }, - @Suppress("UNCHECKED_CAST") - (constructorsToDocumented as List<Documentable>).sourceSets, - needsAnchors = true, - extra = PropertyContainer.empty<ContentNode>() + TabbedContentTypeExtra( - BasicTabbedContentType.CONSTRUCTOR - ), - ) { key, ds -> - link(key, ds.first().dri, kind = ContentKind.Main, styles = setOf(ContentStyle.RowTitle)) - sourceSetDependentHint( - ds.dri, - ds.sourceSets, - kind = ContentKind.SourceSetDependentHint, - styles = emptySet(), - extra = PropertyContainer.empty<ContentNode>() - ) { - ds.forEach { - +buildSignature(it) - contentForBrief(it) + ): ContentGroup { + return contentBuilder.contentFor(dri, sourceSets) { + multiBlock( + name = "Constructors", + level = 2, + kind = ContentKind.Constructors, + groupedElements = constructorsToDocumented.groupBy { it.name } + .map { (_, v) -> v.first().name to v }, + sourceSets = (constructorsToDocumented as List<Documentable>).sourceSets, + needsAnchors = true, + extra = PropertyContainer.empty<ContentNode>() + TabbedContentTypeExtra( + BasicTabbedContentType.CONSTRUCTOR + ), + ) { key, ds -> + link(key, ds.first().dri, kind = ContentKind.Main, styles = setOf(ContentStyle.RowTitle)) + sourceSetDependentHint( + dri = ds.dri, + sourceSets = ds.sourceSets, + kind = ContentKind.SourceSetDependentHint, + styles = emptySet(), + extra = PropertyContainer.empty() + ) { + ds.forEach { + +buildSignature(it) + contentForBrief(it) + } } } } @@ -434,28 +448,30 @@ open class DefaultPageCreator( entries: List<DEnumEntry>, dri: Set<DRI>, sourceSets: Set<DokkaSourceSet> - ) = contentBuilder.contentFor(dri, sourceSets) { - multiBlock( - "Entries", - 2, - ContentKind.Classlikes, - entries.groupBy { it.name }.toList(), - entries.sourceSets, - needsSorting = false, - needsAnchors = true, - extra = mainExtra + TabbedContentTypeExtra(BasicTabbedContentType.ENTRY), - styles = emptySet() - ) { key, ds -> - link(key, ds.first().dri) - sourceSetDependentHint( - ds.dri, - ds.sourceSets, - kind = ContentKind.SourceSetDependentHint, - extra = PropertyContainer.empty<ContentNode>() - ) { - ds.forEach { - +buildSignature(it) - contentForBrief(it) + ): ContentGroup { + return contentBuilder.contentFor(dri, sourceSets) { + multiBlock( + name = "Entries", + level = 2, + kind = ContentKind.Classlikes, + groupedElements = entries.groupBy { it.name }.toList(), + sourceSets = entries.sourceSets, + needsSorting = false, + needsAnchors = true, + extra = mainExtra + TabbedContentTypeExtra(BasicTabbedContentType.ENTRY), + styles = emptySet() + ) { key, ds -> + link(key, ds.first().dri) + sourceSetDependentHint( + dri = ds.dri, + sourceSets = ds.sourceSets, + kind = ContentKind.SourceSetDependentHint, + extra = PropertyContainer.empty<ContentNode>() + ) { + ds.forEach { + +buildSignature(it) + contentForBrief(it) + } } } } @@ -520,13 +536,13 @@ open class DefaultPageCreator( } } - protected open fun contentForFunction(f: DFunction) = contentForMember(f) + protected open fun contentForFunction(f: DFunction): ContentGroup = contentForMember(f) - protected open fun contentForProperty(p: DProperty) = contentForMember(p) + protected open fun contentForProperty(p: DProperty): ContentGroup = contentForMember(p) - protected open fun contentForMember(d: Documentable) = contentForMembers(listOf(d)) + protected open fun contentForMember(d: Documentable): ContentGroup = contentForMembers(listOf(d)) - protected open fun contentForMembers(doumentables: List<Documentable>) = + protected open fun contentForMembers(doumentables: List<Documentable>): ContentGroup = contentBuilder.contentFor(doumentables.dri, doumentables.sourceSets) { group(kind = ContentKind.Cover) { cover(doumentables.first().name.orEmpty()) @@ -709,10 +725,9 @@ open class DefaultPageCreator( } } - protected open fun TagWrapper.toHeaderString() = this.javaClass.toGenericString().split('.').last() + protected open fun TagWrapper.toHeaderString(): String = this.javaClass.toGenericString().split('.').last() } - internal val List<Documentable>.sourceSets: Set<DokkaSourceSet> get() = flatMap { it.sourceSets }.toSet() diff --git a/plugins/base/src/main/kotlin/translators/documentables/DriClashAwareName.kt b/plugins/base/src/main/kotlin/translators/documentables/DriClashAwareName.kt index 99c47342..362bb9b9 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DriClashAwareName.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DriClashAwareName.kt @@ -7,7 +7,7 @@ package org.jetbrains.dokka.base.translators.documentables import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.properties.ExtraProperty -data class DriClashAwareName(val value: String?): ExtraProperty<Documentable> { - companion object : ExtraProperty.Key<Documentable, DriClashAwareName> +public data class DriClashAwareName(val value: String?): ExtraProperty<Documentable> { + public companion object : ExtraProperty.Key<Documentable, DriClashAwareName> override val key: ExtraProperty.Key<Documentable, *> = Companion } diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt index 1887e5ce..4ddda674 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt @@ -19,14 +19,14 @@ import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.utilities.DokkaLogger @DslMarker -annotation class ContentBuilderMarker +public annotation class ContentBuilderMarker -open class PageContentBuilder( - val commentsConverter: CommentsToContentConverter, - val signatureProvider: SignatureProvider, - val logger: DokkaLogger +public open class PageContentBuilder( + public val commentsConverter: CommentsToContentConverter, + public val signatureProvider: SignatureProvider, + public val logger: DokkaLogger ) { - fun contentFor( + public fun contentFor( dri: DRI, sourceSets: Set<DokkaSourceSet>, kind: Kind = ContentKind.Main, @@ -38,7 +38,7 @@ open class PageContentBuilder( .apply(block) .build(sourceSets, kind, styles, extra) - fun contentFor( + public fun contentFor( dri: Set<DRI>, sourceSets: Set<DokkaSourceSet>, kind: Kind = ContentKind.Main, @@ -50,7 +50,7 @@ open class PageContentBuilder( .apply(block) .build(sourceSets, kind, styles, extra) - fun contentFor( + public fun contentFor( d: Documentable, kind: Kind = ContentKind.Main, styles: Set<Style> = emptySet(), @@ -63,36 +63,38 @@ open class PageContentBuilder( .build(sourceSets, kind, styles, extra) @ContentBuilderMarker - open inner class DocumentableContentBuilder( - val mainDRI: Set<DRI>, - val mainSourcesetData: Set<DokkaSourceSet>, - val mainStyles: Set<Style>, - val mainExtra: PropertyContainer<ContentNode> + public open inner class DocumentableContentBuilder( + public val mainDRI: Set<DRI>, + public val mainSourcesetData: Set<DokkaSourceSet>, + public val mainStyles: Set<Style>, + public val mainExtra: PropertyContainer<ContentNode> ) { - protected val contents = mutableListOf<ContentNode>() + protected val contents: MutableList<ContentNode> = mutableListOf<ContentNode>() - fun build( + public fun build( sourceSets: Set<DokkaSourceSet>, kind: Kind, styles: Set<Style>, extra: PropertyContainer<ContentNode> - ) = ContentGroup( - contents.toList(), - DCI(mainDRI, kind), - sourceSets.toDisplaySourceSets(), - styles, - extra - ) - - operator fun ContentNode.unaryPlus() { + ): ContentGroup { + return ContentGroup( + children = contents.toList(), + dci = DCI(mainDRI, kind), + sourceSets = sourceSets.toDisplaySourceSets(), + style = styles, + extra = extra + ) + } + + public operator fun ContentNode.unaryPlus() { contents += this } - operator fun Collection<ContentNode>.unaryPlus() { + public operator fun Collection<ContentNode>.unaryPlus() { contents += this } - fun header( + public fun header( level: Int, text: String, kind: Kind = ContentKind.Main, @@ -116,7 +118,7 @@ open class PageContentBuilder( ) } - fun cover( + public fun cover( text: String, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, styles: Set<Style> = mainStyles + TextStyle.Cover, @@ -126,14 +128,31 @@ open class PageContentBuilder( header(1, text, sourceSets = sourceSets, styles = styles, extra = extra, block = block) } - fun constant(text: String) = text(text, styles = mainStyles + TokenStyle.Constant) - fun keyword(text: String) = text(text, styles = mainStyles + TokenStyle.Keyword) - fun stringLiteral(text: String) = text(text, styles = mainStyles + TokenStyle.String) - fun booleanLiteral(value: Boolean) = text(value.toString(), styles = mainStyles + TokenStyle.Boolean) - fun punctuation(text: String) = text(text, styles = mainStyles + TokenStyle.Punctuation) - fun operator(text: String) = text(text, styles = mainStyles + TokenStyle.Operator) + public fun constant(text: String) { + text(text, styles = mainStyles + TokenStyle.Constant) + } + + public fun keyword(text: String) { + text(text, styles = mainStyles + TokenStyle.Keyword) + } + + public fun stringLiteral(text: String) { + text(text, styles = mainStyles + TokenStyle.String) + } + + public fun booleanLiteral(value: Boolean) { + text(value.toString(), styles = mainStyles + TokenStyle.Boolean) + } + + public fun punctuation(text: String) { + text(text, styles = mainStyles + TokenStyle.Punctuation) + } - fun text( + public fun operator(text: String) { + text(text, styles = mainStyles + TokenStyle.Operator) + } + + public fun text( text: String, kind: Kind = ContentKind.Main, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, @@ -143,13 +162,13 @@ open class PageContentBuilder( contents += createText(text, kind, sourceSets, styles, extra) } - fun breakLine(sourceSets: Set<DokkaSourceSet> = mainSourcesetData) { + public fun breakLine(sourceSets: Set<DokkaSourceSet> = mainSourcesetData) { contents += ContentBreakLine(sourceSets.toDisplaySourceSets()) } - fun buildSignature(d: Documentable) = signatureProvider.signature(d) + public fun buildSignature(d: Documentable): List<ContentNode> = signatureProvider.signature(d) - fun table( + public fun table( kind: Kind = ContentKind.Main, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, styles: Set<Style> = mainStyles, @@ -161,7 +180,7 @@ open class PageContentBuilder( }.build() } - fun unorderedList( + public fun unorderedList( kind: Kind = ContentKind.Main, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, styles: Set<Style> = mainStyles, @@ -171,7 +190,7 @@ open class PageContentBuilder( contents += ListBuilder(false, mainDRI, sourceSets, kind, styles, extra).apply(operation).build() } - fun orderedList( + public fun orderedList( kind: Kind = ContentKind.Main, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, styles: Set<Style> = mainStyles, @@ -181,7 +200,7 @@ open class PageContentBuilder( contents += ListBuilder(true, mainDRI, sourceSets, kind, styles, extra).apply(operation).build() } - fun descriptionList( + public fun descriptionList( kind: Kind = ContentKind.Main, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, styles: Set<Style> = mainStyles, @@ -197,7 +216,7 @@ open class PageContentBuilder( label.forEach { text(it) } } - fun <T : Documentable> block( + public fun <T : Documentable> block( name: String, level: Int, kind: Kind = ContentKind.Main, @@ -235,7 +254,7 @@ open class PageContentBuilder( } } - fun <T : Pair<String, List<Documentable>>> multiBlock( + public fun <T : Pair<String, List<Documentable>>> multiBlock( name: String, level: Int, kind: Kind = ContentKind.Main, @@ -286,7 +305,7 @@ open class PageContentBuilder( } } - fun <T> list( + public fun <T> list( elements: List<T>, prefix: String = "", suffix: String = "", @@ -307,7 +326,7 @@ open class PageContentBuilder( } } - fun link( + public fun link( text: String, address: DRI, kind: Kind = ContentKind.Main, @@ -318,22 +337,24 @@ open class PageContentBuilder( contents += linkNode(text, address, DCI(mainDRI, kind), sourceSets, styles, extra) } - fun linkNode( + public fun linkNode( text: String, address: DRI, dci: DCI = DCI(mainDRI, ContentKind.Main), sourceSets: Set<DokkaSourceSet> = mainSourcesetData, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra - ) = ContentDRILink( - listOf(createText(text, dci.kind, sourceSets, styles, extra)), - address, - dci, - sourceSets.toDisplaySourceSets(), - extra = extra - ) - - fun link( + ): ContentLink { + return ContentDRILink( + listOf(createText(text, dci.kind, sourceSets, styles, extra)), + address, + dci, + sourceSets.toDisplaySourceSets(), + extra = extra + ) + } + + public fun link( text: String, address: String, kind: Kind = ContentKind.Main, @@ -351,7 +372,7 @@ open class PageContentBuilder( ) } - fun link( + public fun link( address: DRI, kind: Kind = ContentKind.Main, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, @@ -368,7 +389,7 @@ open class PageContentBuilder( ) } - fun comment( + public fun comment( docTag: DocTag, kind: Kind = ContentKind.Comment, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, @@ -383,7 +404,7 @@ open class PageContentBuilder( contents += ContentGroup(content, DCI(mainDRI, kind), sourceSets.toDisplaySourceSets(), styles, extra) } - fun codeBlock( + public fun codeBlock( language: String = "", kind: Kind = ContentKind.Main, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, @@ -401,7 +422,7 @@ open class PageContentBuilder( ) } - fun codeInline( + public fun codeInline( language: String = "", kind: Kind = ContentKind.Main, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, @@ -419,7 +440,7 @@ open class PageContentBuilder( ) } - fun firstParagraphComment( + public fun firstParagraphComment( content: DocTag, kind: Kind = ContentKind.Comment, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, @@ -443,7 +464,7 @@ open class PageContentBuilder( } } - fun firstSentenceComment( + public fun firstSentenceComment( content: DocTag, kind: Kind = ContentKind.Comment, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, @@ -465,7 +486,7 @@ open class PageContentBuilder( ) } - fun group( + public fun group( dri: Set<DRI> = mainDRI, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, kind: Kind = ContentKind.Main, @@ -476,7 +497,7 @@ open class PageContentBuilder( contents += buildGroup(dri, sourceSets, kind, styles, extra, block) } - fun divergentGroup( + public fun divergentGroup( groupID: ContentDivergentGroup.GroupID, dri: Set<DRI> = mainDRI, kind: Kind = ContentKind.Main, @@ -491,7 +512,7 @@ open class PageContentBuilder( .build(groupID = groupID, implicitlySourceSetHinted = implicitlySourceSetHinted) } - fun buildGroup( + public fun buildGroup( dri: Set<DRI> = mainDRI, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, kind: Kind = ContentKind.Main, @@ -500,7 +521,7 @@ open class PageContentBuilder( block: DocumentableContentBuilder.() -> Unit ): ContentGroup = contentFor(dri, sourceSets, kind, styles, extra, block) - fun sourceSetDependentHint( + public fun sourceSetDependentHint( dri: Set<DRI> = mainDRI, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, kind: Kind = ContentKind.Main, @@ -514,7 +535,7 @@ open class PageContentBuilder( ) } - fun sourceSetDependentHint( + public fun sourceSetDependentHint( dri: DRI, sourcesetData: Set<DokkaSourceSet> = mainSourcesetData, kind: Kind = ContentKind.Main, @@ -534,23 +555,26 @@ open class PageContentBuilder( sourceSets: Set<DokkaSourceSet>, styles: Set<Style>, extra: PropertyContainer<ContentNode> - ) = - ContentText(text, DCI(mainDRI, kind), sourceSets.toDisplaySourceSets(), styles, extra) + ): ContentText { + return ContentText(text, DCI(mainDRI, kind), sourceSets.toDisplaySourceSets(), styles, extra) + } - fun <T> sourceSetDependentText( + public fun <T> sourceSetDependentText( value: SourceSetDependent<T>, sourceSets: Set<DokkaSourceSet> = value.keys, styles: Set<Style> = mainStyles, transform: (T) -> String - ) = value.entries.filter { it.key in sourceSets }.mapNotNull { (p, v) -> - transform(v).takeIf { it.isNotBlank() }?.let { it to p } - }.groupBy({ it.first }) { it.second }.forEach { - text(it.key, sourceSets = it.value.toSet(), styles = styles) + ) { + value.entries + .filter { it.key in sourceSets } + .mapNotNull { (p, v) -> transform(v).takeIf { it.isNotBlank() }?.let { it to p } } + .groupBy({ it.first }) { it.second } + .forEach { text(it.key, sourceSets = it.value.toSet(), styles = styles) } } } @ContentBuilderMarker - open inner class TableBuilder( + public open inner class TableBuilder( private val mainDRI: Set<DRI>, private val mainSourceSets: Set<DokkaSourceSet>, private val mainKind: Kind, @@ -561,7 +585,7 @@ open class PageContentBuilder( private val rows: MutableList<ContentGroup> = mutableListOf() private var caption: ContentGroup? = null - fun header( + public fun header( dri: Set<DRI> = mainDRI, sourceSets: Set<DokkaSourceSet> = mainSourceSets, kind: Kind = mainKind, @@ -572,7 +596,7 @@ open class PageContentBuilder( headerRows += contentFor(dri, sourceSets, kind, styles, extra, block) } - fun row( + public fun row( dri: Set<DRI> = mainDRI, sourceSets: Set<DokkaSourceSet> = mainSourceSets, kind: Kind = mainKind, @@ -583,7 +607,7 @@ open class PageContentBuilder( rows += contentFor(dri, sourceSets, kind, styles, extra, block) } - fun caption( + public fun caption( dri: Set<DRI> = mainDRI, sourceSets: Set<DokkaSourceSet> = mainSourceSets, kind: Kind = mainKind, @@ -594,30 +618,33 @@ open class PageContentBuilder( caption = contentFor(dri, sourceSets, kind, styles, extra, block) } - fun build( + public fun build( sourceSets: Set<DokkaSourceSet> = mainSourceSets, kind: Kind = mainKind, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra - ) = ContentTable( - headerRows, - caption, - rows, - DCI(mainDRI, kind), - sourceSets.toDisplaySourceSets(), - styles, extra - ) + ): ContentTable { + return ContentTable( + headerRows, + caption, + rows, + DCI(mainDRI, kind), + sourceSets.toDisplaySourceSets(), + styles, extra + ) + } } @ContentBuilderMarker - open inner class DivergentBuilder( + public open inner class DivergentBuilder( private val mainDRI: Set<DRI>, private val mainKind: Kind, private val mainStyles: Set<Style>, private val mainExtra: PropertyContainer<ContentNode> ) { private val instances: MutableList<ContentDivergentInstance> = mutableListOf() - fun instance( + + public fun instance( dri: Set<DRI>, sourceSets: Set<DokkaSourceSet>, // Having correct sourcesetData is crucial here, that's why there's no default kind: Kind = mainKind, @@ -630,24 +657,26 @@ open class PageContentBuilder( .build(kind) } - fun build( + public fun build( groupID: ContentDivergentGroup.GroupID, implicitlySourceSetHinted: Boolean, kind: Kind = mainKind, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra - ) = ContentDivergentGroup( - instances.toList(), - DCI(mainDRI, kind), - styles, - extra, - groupID, - implicitlySourceSetHinted - ) + ): ContentDivergentGroup { + return ContentDivergentGroup( + children = instances.toList(), + dci = DCI(mainDRI, kind), + style = styles, + extra = extra, + groupID = groupID, + implicitlySourceSetHinted = implicitlySourceSetHinted + ) + } } @ContentBuilderMarker - open inner class DivergentInstanceBuilder( + public open inner class DivergentInstanceBuilder( private val mainDRI: Set<DRI>, private val mainSourceSets: Set<DokkaSourceSet>, private val mainStyles: Set<Style>, @@ -657,7 +686,7 @@ open class PageContentBuilder( private var divergent: ContentNode? = null private var after: ContentNode? = null - fun before( + public fun before( dri: Set<DRI> = mainDRI, sourceSets: Set<DokkaSourceSet> = mainSourceSets, kind: Kind = ContentKind.Main, @@ -670,7 +699,7 @@ open class PageContentBuilder( .also { before = it } } - fun divergent( + public fun divergent( dri: Set<DRI> = mainDRI, sourceSets: Set<DokkaSourceSet> = mainSourceSets, kind: Kind = ContentKind.Main, @@ -681,7 +710,7 @@ open class PageContentBuilder( divergent = contentFor(dri, sourceSets, kind, styles, extra, block) } - fun after( + public fun after( dri: Set<DRI> = mainDRI, sourceSets: Set<DokkaSourceSet> = mainSourceSets, kind: Kind = ContentKind.Main, @@ -694,14 +723,13 @@ open class PageContentBuilder( .also { after = it } } - - fun build( + public fun build( kind: Kind, sourceSets: Set<DokkaSourceSet> = mainSourceSets, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra - ) = - ContentDivergentInstance( + ): ContentDivergentInstance { + return ContentDivergentInstance( before, divergent ?: throw IllegalStateException("Divergent block needs divergent part"), after, @@ -710,11 +738,12 @@ open class PageContentBuilder( styles, extra ) + } } @ContentBuilderMarker - open inner class ListBuilder( - val ordered: Boolean, + public open inner class ListBuilder( + public val ordered: Boolean, private val mainDRI: Set<DRI>, private val mainSourceSets: Set<DokkaSourceSet>, private val mainKind: Kind, @@ -723,7 +752,7 @@ open class PageContentBuilder( ) { private val contentNodes: MutableList<ContentNode> = mutableListOf() - fun item( + public fun item( dri: Set<DRI> = mainDRI, sourceSets: Set<DokkaSourceSet> = mainSourceSets, kind: Kind = mainKind, @@ -734,17 +763,19 @@ open class PageContentBuilder( contentNodes += contentFor(dri, sourceSets, kind, styles, extra, block) } - fun build( + public fun build( sourceSets: Set<DokkaSourceSet> = mainSourceSets, kind: Kind = mainKind, styles: Set<Style> = mainStyles, extra: PropertyContainer<ContentNode> = mainExtra - ) = ContentList( - contentNodes, - ordered, - DCI(mainDRI, kind), - sourceSets.toDisplaySourceSets(), - styles, extra - ) + ): ContentList { + return ContentList( + contentNodes, + ordered, + DCI(mainDRI, kind), + sourceSets.toDisplaySourceSets(), + styles, extra + ) + } } } diff --git a/plugins/base/src/main/kotlin/translators/documentables/briefFromContentNodes.kt b/plugins/base/src/main/kotlin/translators/documentables/briefFromContentNodes.kt index c5b1f738..a073f73a 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/briefFromContentNodes.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/briefFromContentNodes.kt @@ -12,7 +12,7 @@ import org.jetbrains.dokka.model.doc.Text import org.jetbrains.dokka.model.withDescendants import org.jetbrains.dokka.pages.* -fun firstParagraphBrief(docTag: DocTag): DocTag? = +public fun firstParagraphBrief(docTag: DocTag): DocTag? = when(docTag){ is P -> docTag is CustomDocTag -> docTag.children.firstNotNullOfOrNull { firstParagraphBrief(it) } @@ -20,7 +20,7 @@ fun firstParagraphBrief(docTag: DocTag): DocTag? = else -> null } -fun firstSentenceBriefFromContentNodes(description: List<ContentNode>): List<ContentNode> { +public fun firstSentenceBriefFromContentNodes(description: List<ContentNode>): List<ContentNode> { val firstSentenceRegex = """^((?:[^.?!]|[.!?](?!\s))*[.!?])""".toRegex() //Description that is entirely based on html content. In html it is hard to define a brief so we render all of it diff --git a/plugins/base/src/main/kotlin/translators/psi/parsers/InheritDocResolver.kt b/plugins/base/src/main/kotlin/translators/psi/parsers/InheritDocResolver.kt deleted file mode 100644 index 4dd61777..00000000 --- a/plugins/base/src/main/kotlin/translators/psi/parsers/InheritDocResolver.kt +++ /dev/null @@ -1,4 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - diff --git a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt deleted file mode 100644 index 4dd61777..00000000 --- a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt +++ /dev/null @@ -1,4 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - diff --git a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocTag.kt b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocTag.kt deleted file mode 100644 index 4dd61777..00000000 --- a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocTag.kt +++ /dev/null @@ -1,4 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - diff --git a/plugins/gfm/api/gfm.api b/plugins/gfm/api/gfm.api index b6970211..f77c9b68 100644 --- a/plugins/gfm/api/gfm.api +++ b/plugins/gfm/api/gfm.api @@ -30,8 +30,7 @@ public final class org/jetbrains/dokka/gfm/location/MarkdownLocationProvider : o public final class org/jetbrains/dokka/gfm/location/MarkdownLocationProvider$Factory : org/jetbrains/dokka/base/resolvers/local/LocationProviderFactory { public fun <init> (Lorg/jetbrains/dokka/plugability/DokkaContext;)V - public synthetic fun getLocationProvider (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/base/resolvers/local/LocationProvider; - public fun getLocationProvider (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/gfm/location/MarkdownLocationProvider; + public fun getLocationProvider (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/base/resolvers/local/LocationProvider; } public final class org/jetbrains/dokka/gfm/renderer/BriefCommentPreprocessor : org/jetbrains/dokka/transformers/pages/PageTransformer { diff --git a/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingPlugin.kt b/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingPlugin.kt index 4bb9cf63..fd2af274 100644 --- a/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingPlugin.kt +++ b/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingPlugin.kt @@ -7,33 +7,34 @@ package org.jetbrains.dokka.gfm.templateProcessing import org.jetbrains.dokka.allModulesPage.AllModulesPagePlugin import org.jetbrains.dokka.allModulesPage.MultimoduleLocationProvider import org.jetbrains.dokka.base.DokkaBase +import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory import org.jetbrains.dokka.gfm.GfmPlugin import org.jetbrains.dokka.gfm.location.MarkdownLocationProvider import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.plugability.DokkaPluginApiPreview +import org.jetbrains.dokka.plugability.Extension import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement +import org.jetbrains.dokka.templates.TemplateProcessingStrategy import org.jetbrains.dokka.templates.TemplatingPlugin -class GfmTemplateProcessingPlugin : DokkaPlugin() { +public class GfmTemplateProcessingPlugin : DokkaPlugin() { private val allModulesPagePlugin by lazy { plugin<AllModulesPagePlugin>() } private val templateProcessingPlugin by lazy { plugin<TemplatingPlugin>() } - private val gfmPlugin by lazy { plugin<GfmPlugin>() } - private val dokkaBase by lazy { plugin<DokkaBase>()} - val gfmTemplateProcessingStrategy by extending { + public val gfmTemplateProcessingStrategy: Extension<TemplateProcessingStrategy, *, *> by extending { (templateProcessingPlugin.templateProcessingStrategy providing ::GfmTemplateProcessingStrategy order { before(templateProcessingPlugin.fallbackProcessingStrategy) }) } - val gfmLocationProvider by extending { + public val gfmLocationProvider: Extension<LocationProviderFactory, *, *> by extending { dokkaBase.locationProviderFactory providing MultimoduleLocationProvider::Factory override listOf(gfmPlugin.locationProvider, allModulesPagePlugin.multimoduleLocationProvider) } - val gfmPartialLocationProvider by extending { + public val gfmPartialLocationProvider: Extension<LocationProviderFactory, *, *> by extending { allModulesPagePlugin.partialLocationProviderFactory providing MarkdownLocationProvider::Factory override allModulesPagePlugin.baseLocationProviderFactory } diff --git a/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingStrategy.kt b/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingStrategy.kt index 306412e3..8f23e8e9 100644 --- a/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingStrategy.kt +++ b/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingStrategy.kt @@ -20,7 +20,9 @@ import org.jetbrains.dokka.templates.TemplateProcessingStrategy import java.io.BufferedWriter import java.io.File -class GfmTemplateProcessingStrategy(val context: DokkaContext) : TemplateProcessingStrategy { +public class GfmTemplateProcessingStrategy( + public val context: DokkaContext +) : TemplateProcessingStrategy { private val externalModuleLinkResolver = context.plugin<AllModulesPagePlugin>().querySingle { externalModuleLinkResolver } diff --git a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt index 5ffa883a..3fd7b514 100644 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt @@ -8,39 +8,39 @@ 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.RecognizedLinkFormat import org.jetbrains.dokka.gfm.location.MarkdownLocationProvider import org.jetbrains.dokka.gfm.renderer.BriefCommentPreprocessor import org.jetbrains.dokka.gfm.renderer.CommonmarkRenderer -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.pages.PageTransformer -class GfmPlugin : DokkaPlugin() { +public class GfmPlugin : DokkaPlugin() { - val gfmPreprocessors by extensionPoint<PageTransformer>() + public val gfmPreprocessors: ExtensionPoint<PageTransformer> by extensionPoint<PageTransformer>() private val dokkaBase by lazy { plugin<DokkaBase>() } - val renderer by extending { + public val renderer: Extension<Renderer, *, *> by extending { CoreExtensions.renderer providing ::CommonmarkRenderer override dokkaBase.htmlRenderer } - val locationProvider by extending { + public val locationProvider: Extension<LocationProviderFactory, *, *> by extending { dokkaBase.locationProviderFactory providing MarkdownLocationProvider::Factory override dokkaBase.locationProvider } - val rootCreator by extending { + public val rootCreator: Extension<PageTransformer, *, *> by extending { gfmPreprocessors with RootCreator } - val briefCommentPreprocessor by extending { + public val briefCommentPreprocessor: Extension<PageTransformer, *, *> by extending { gfmPreprocessors with BriefCommentPreprocessor() } - val packageListCreator by extending { + public val packageListCreator: Extension<PageTransformer, *, *> by extending { (gfmPreprocessors providing { PackageListCreator(it, RecognizedLinkFormat.DokkaGFM) } order { after(rootCreator) }) diff --git a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/gfmTemplating.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/gfmTemplating.kt index f30c5929..194127df 100644 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/gfmTemplating.kt +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/gfmTemplating.kt @@ -10,16 +10,21 @@ import org.jetbrains.dokka.base.templating.toJsonString import org.jetbrains.dokka.links.DRI @JsonTypeInfo(use = CLASS) -sealed class GfmCommand { - companion object { +public sealed class GfmCommand { + + public companion object { private const val delimiter = "\u1680" - val templateCommandRegex: Regex = + + public val templateCommandRegex: Regex = Regex("<!---$delimiter GfmCommand ([^$delimiter ]*)$delimiter--->(.+?)(?=<!---$delimiter)<!---$delimiter--->") - val MatchResult.command + + public val MatchResult.command: String get() = groupValues[1] - val MatchResult.label + + public val MatchResult.label: String get() = groupValues[2] - fun Appendable.templateCommand(command: GfmCommand, content: Appendable.() -> Unit) { + + public fun Appendable.templateCommand(command: GfmCommand, content: Appendable.() -> Unit) { append("<!---$delimiter GfmCommand ${toJsonString(command)}$delimiter--->") content() append("<!---$delimiter--->") @@ -27,6 +32,8 @@ sealed class GfmCommand { } } -class ResolveLinkGfmCommand(val dri: DRI) : GfmCommand() +public class ResolveLinkGfmCommand( + public val dri: DRI +) : GfmCommand() diff --git a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/location/MarkdownLocationProvider.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/location/MarkdownLocationProvider.kt index 03025863..f331a6d9 100644 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/location/MarkdownLocationProvider.kt +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/location/MarkdownLocationProvider.kt @@ -5,17 +5,18 @@ package org.jetbrains.dokka.gfm.location import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider +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 MarkdownLocationProvider( +public class MarkdownLocationProvider( pageGraphRoot: RootPageNode, dokkaContext: DokkaContext ) : DokkaLocationProvider(pageGraphRoot, dokkaContext, ".md") { - class Factory(private val context: DokkaContext) : LocationProviderFactory { - override fun getLocationProvider(pageNode: RootPageNode) = + public class Factory(private val context: DokkaContext) : LocationProviderFactory { + override fun getLocationProvider(pageNode: RootPageNode): LocationProvider = MarkdownLocationProvider(pageNode, context) } } diff --git a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/BriefCommentPreprocessor.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/BriefCommentPreprocessor.kt index 56d75fd2..6023cca1 100644 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/BriefCommentPreprocessor.kt +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/BriefCommentPreprocessor.kt @@ -7,14 +7,16 @@ package org.jetbrains.dokka.gfm.renderer import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.transformers.pages.PageTransformer -class BriefCommentPreprocessor : PageTransformer { - override fun invoke(input: RootPageNode) = input.transformContentPagesTree { contentPage -> - contentPage.modified(content = contentPage.content.recursiveMapTransform<ContentGroup, ContentNode> { - if (it.dci.kind == ContentKind.BriefComment) { - it.copy(style = it.style + setOf(TextStyle.Block)) - } else { - it - } - }) +public class BriefCommentPreprocessor : PageTransformer { + override fun invoke(input: RootPageNode): RootPageNode { + return input.transformContentPagesTree { contentPage -> + contentPage.modified(content = contentPage.content.recursiveMapTransform<ContentGroup, ContentNode> { + if (it.dci.kind == ContentKind.BriefComment) { + it.copy(style = it.style + setOf(TextStyle.Block)) + } else { + it + } + }) + } } } diff --git a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt index 3cfd17ef..3bc420ac 100644 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt @@ -15,13 +15,14 @@ import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.query +import org.jetbrains.dokka.transformers.pages.PageTransformer import org.jetbrains.dokka.utilities.htmlEscape -open class CommonmarkRenderer( +public open class CommonmarkRenderer( context: DokkaContext ) : DefaultRenderer<StringBuilder>(context) { - override val preprocessors = context.plugin<GfmPlugin>().query { gfmPreprocessors } + override val preprocessors: List<PageTransformer> = context.plugin<GfmPlugin>().query { gfmPreprocessors } private val isPartial = context.configuration.delayTemplateSubstitution diff --git a/plugins/javadoc/api/javadoc.api b/plugins/javadoc/api/javadoc.api index 32d71dfb..a6b686d7 100644 --- a/plugins/javadoc/api/javadoc.api +++ b/plugins/javadoc/api/javadoc.api @@ -16,14 +16,12 @@ public final class org/jetbrains/dokka/javadoc/JavadocPlugin : org/jetbrains/dok public final fun getAllClassessPageInstaller ()Lorg/jetbrains/dokka/plugability/Extension; public final fun getDeprecatedPageCreator ()Lorg/jetbrains/dokka/plugability/Extension; public final fun getDocumentableSourceSetFilter ()Lorg/jetbrains/dokka/plugability/Extension; - public final fun getDokkaBasePlugin ()Lorg/jetbrains/dokka/base/DokkaBase; public final fun getDokkaJavadocPlugin ()Lorg/jetbrains/dokka/plugability/Extension; public final fun getIndexGenerator ()Lorg/jetbrains/dokka/plugability/Extension; public final fun getJavadocLocationProviderFactory ()Lorg/jetbrains/dokka/plugability/Extension; public final fun getJavadocMultiplatformCheck ()Lorg/jetbrains/dokka/plugability/Extension; public final fun getJavadocPreprocessors ()Lorg/jetbrains/dokka/plugability/ExtensionPoint; public final fun getJavadocSignatureProvider ()Lorg/jetbrains/dokka/plugability/Extension; - public final fun getKotinAsJavaPlugin ()Lorg/jetbrains/dokka/kotlinAsJava/KotlinAsJavaPlugin; public final fun getLocationProviderFactory ()Lorg/jetbrains/dokka/plugability/ExtensionPoint; public final fun getPackageListCreator ()Lorg/jetbrains/dokka/plugability/Extension; public final fun getPageTranslator ()Lorg/jetbrains/dokka/plugability/Extension; @@ -45,8 +43,7 @@ public final class org/jetbrains/dokka/javadoc/location/JavadocLocationProvider public final class org/jetbrains/dokka/javadoc/location/JavadocLocationProviderFactory : org/jetbrains/dokka/base/resolvers/local/LocationProviderFactory { public fun <init> (Lorg/jetbrains/dokka/plugability/DokkaContext;)V - public synthetic fun getLocationProvider (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/base/resolvers/local/LocationProvider; - public fun getLocationProvider (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/javadoc/location/JavadocLocationProvider; + public fun getLocationProvider (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/base/resolvers/local/LocationProvider; } public final class org/jetbrains/dokka/javadoc/pages/AllClassesPage : org/jetbrains/dokka/javadoc/pages/JavadocPageNode { 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<DokkaBase>().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<DModule>)?.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<Documentable>)?.extra ?: PropertyContainer.empty()) @@ -209,9 +211,10 @@ open class JavadocPageCreator(context: DokkaContext) { ) } - fun List<ContentNode>.nodeForJvm(jvm: DokkaSourceSet): ContentNode = - firstOrNull { jvm.sourceSetID in it.sourceSets.computeSourceSetIds() } + public fun List<ContentNode>.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<ContentNode> = 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<DokkaBase>() } - val kotinAsJavaPlugin by lazy { plugin<KotlinAsJavaPlugin>() } - val locationProviderFactory by lazy { dokkaBasePlugin.locationProviderFactory } - val javadocPreprocessors by extensionPoint<PageTransformer>() + private val dokkaBasePlugin: DokkaBase by lazy { plugin<DokkaBase>() } + private val kotinAsJavaPlugin: KotlinAsJavaPlugin by lazy { plugin<KotlinAsJavaPlugin>() } - val dokkaJavadocPlugin by extending { + public val locationProviderFactory: ExtensionPoint<LocationProviderFactory> by lazy { dokkaBasePlugin.locationProviderFactory } + public val javadocPreprocessors: ExtensionPoint<PageTransformer> by extensionPoint<PageTransformer>() + + public val dokkaJavadocPlugin: Extension<Renderer, *, *> by extending { CoreExtensions.renderer providing { ctx -> KorteJavadocRenderer(ctx, "views") } override dokkaBasePlugin.htmlRenderer } - val javadocMultiplatformCheck by extending { + public val javadocMultiplatformCheck: Extension<PreGenerationChecker, *, *> by extending { CoreExtensions.preGenerationCheck providing ::MultiplatformConfiguredChecker } - val pageTranslator by extending { + public val pageTranslator: Extension<DocumentableToPageTranslator, *, *> by extending { CoreExtensions.documentableToPageTranslator providing ::JavadocDocumentableToPageTranslator override kotinAsJavaPlugin.kotlinAsJavaDocumentableToPageTranslator } - val documentableSourceSetFilter by extending { + public val documentableSourceSetFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending { dokkaBasePlugin.preMergeDocumentableTransformer providing ::JavadocDocumentableJVMSourceSetFilter } - val javadocLocationProviderFactory by extending { + public val javadocLocationProviderFactory: Extension<LocationProviderFactory, *, *> by extending { dokkaBasePlugin.locationProviderFactory providing ::JavadocLocationProviderFactory override dokkaBasePlugin.locationProvider } - val javadocSignatureProvider by extending { + public val javadocSignatureProvider: Extension<SignatureProvider, *, *> by extending { dokkaBasePlugin.signatureProvider providing ::JavadocSignatureProvider override kotinAsJavaPlugin.javaSignatureProvider } - val rootCreator by extending { + public val rootCreator: Extension<PageTransformer, *, *> by extending { javadocPreprocessors with RootCreator } - val packageListCreator by extending { + public val packageListCreator: Extension<PageTransformer, *, *> 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<PageTransformer, *, *> by extending { javadocPreprocessors with ResourcesInstaller order { after(rootCreator) } } - val treeViewInstaller by extending { + public val treeViewInstaller: Extension<PageTransformer, *, *> by extending { javadocPreprocessors providing ::TreeViewInstaller order { after(rootCreator) } } - val allClassessPageInstaller by extending { + public val allClassessPageInstaller: Extension<PageTransformer, *, *> by extending { javadocPreprocessors with AllClassesPageInstaller order { before(rootCreator) } } - val indexGenerator by extending { + public val indexGenerator: Extension<PageTransformer, *, *> by extending { javadocPreprocessors with IndexGenerator order { before(rootCreator) } } - val deprecatedPageCreator by extending { + public val deprecatedPageCreator: Extension<PageTransformer, *, *> 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<PageNode, List<String>>().apply { fun registerPath(page: PageNode, prefix: List<String> = 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<DRI>, kind: Kind, override val sourceSets: Set<DisplaySourceSet> @@ -24,17 +24,17 @@ abstract class JavadocContentNode( override fun withNewExtras(newExtras: PropertyContainer<ContentNode>): ContentNode = this } -interface JavadocList { - val tabTitle: String - val colTitle: String - val children: List<JavadocListEntry> +public interface JavadocList { + public val tabTitle: String + public val colTitle: String + public val children: List<JavadocListEntry> } -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<DisplaySourceSet>, @@ -51,15 +51,15 @@ data class EmptyNode( override fun hasAnyContent(): Boolean = false } -data class JavadocContentGroup( +public data class JavadocContentGroup( val dri: Set<DRI>, val kind: Kind, override val sourceSets: Set<DisplaySourceSet>, override val children: List<JavadocContentNode> ) : JavadocContentNode(dri, kind, sourceSets) { - companion object { - operator fun invoke( + public companion object { + public operator fun invoke( dri: Set<DRI>, kind: Kind, sourceSets: Set<DisplaySourceSet>, @@ -76,11 +76,13 @@ data class JavadocContentGroup( copy(sourceSets = sourceSets) } -class JavaContentGroupBuilder(val sourceSets: Set<DisplaySourceSet>) { - val list = mutableListOf<JavadocContentNode>() +public class JavaContentGroupBuilder( + public val sourceSets: Set<DisplaySourceSet> +) { + public val list: MutableList<JavadocContentNode> = mutableListOf<JavadocContentNode>() } -data class TitleNode( +public data class TitleNode( val title: String, val subtitle: List<ContentNode>, val version: String?, @@ -97,7 +99,7 @@ data class TitleNode( copy(sourceSets = sourceSets) } -fun JavaContentGroupBuilder.title( +public fun JavaContentGroupBuilder.title( title: String, subtitle: List<ContentNode>, 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<LeafListNode>, val dri: Set<DRI>, 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<JavadocListEntry>, @@ -135,7 +137,7 @@ data class LeafListNode( } -fun JavaContentGroupBuilder.rootList( +public fun JavaContentGroupBuilder.rootList( dri: Set<DRI>, kind: Kind, rootList: List<JavadocList> @@ -146,7 +148,7 @@ fun JavaContentGroupBuilder.rootList( list.add(RootListNode(children, dri, kind, sourceSets)) } -fun JavaContentGroupBuilder.leafList( +public fun JavaContentGroupBuilder.leafList( dri: Set<DRI>, 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<JavadocListEntry>) = object : JavadocList { - override val tabTitle = tabTitle - override val colTitle = colTitle - override val children = children +public fun JavadocList(tabTitle: String, colTitle: String, children: List<JavadocListEntry>): JavadocList { + return object : JavadocList { + override val tabTitle = tabTitle + override val colTitle = colTitle + override val children = children + } } -class LinkJavadocListEntry( - val name: String, - val dri: Set<DRI>, - val kind: Kind = ContentKind.Symbol, - val sourceSets: Set<DisplaySourceSet> -) : - JavadocListEntry { +public class LinkJavadocListEntry( + public val name: String, + public val dri: Set<DRI>, + public val kind: Kind = ContentKind.Symbol, + public val sourceSets: Set<DisplaySourceSet> +) : 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<DRI>, Kind, List<DisplaySourceSet>) -> String) { + public fun build(body: (String, Set<DRI>, Kind, List<DisplaySourceSet>) -> String) { builtString = body(name, dri, kind, sourceSets.toList()) } } -data class RowJavadocListEntry(val link: LinkJavadocListEntry, val doc: List<ContentNode>) : JavadocListEntry { +public data class RowJavadocListEntry(val link: LinkJavadocListEntry, val doc: List<ContentNode>) : 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<ContentNode>) : ExtraProperty<Documentable> { +public data class JavadocIndexExtra(val index: List<ContentNode>) : ExtraProperty<Documentable> { override val key: ExtraProperty.Key<Documentable, *> = JavadocIndexExtra - companion object : ExtraProperty.Key<Documentable, JavadocIndexExtra> + public companion object : ExtraProperty.Key<Documentable, JavadocIndexExtra> } 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<T : Documentable> : WithExtraProperties<T> { +public interface WithJavadocExtra<T : Documentable> : WithExtraProperties<T> { override fun withNewExtras(newExtras: PropertyContainer<T>): T = throw IllegalStateException("Merging extras is not applicable for javadoc") } -fun interface WithNavigable { - fun getAllNavigables(): List<NavigableJavadocNode> +public fun interface WithNavigable { + public fun getAllNavigables(): List<NavigableJavadocNode> } -interface WithBrief { - val brief: List<ContentNode> +public interface WithBrief { + public val brief: List<ContentNode> } -class JavadocModulePageNode( +public class JavadocModulePageNode( override val name: String, override val content: JavadocContentNode, override val children: List<PageNode>, @@ -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<DRI>, @@ -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<DEnumEntry> = PropertyContainer.empty() ) : AnchorableJavadocNode(name, dri), WithJavadocExtra<DEnumEntry>, 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<DParameter> = PropertyContainer.empty() ) : AnchorableJavadocNode(name, dri), WithJavadocExtra<DParameter> -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<DProperty> = PropertyContainer.empty() ) : AnchorableJavadocNode(name, dri), WithJavadocExtra<DProperty>, WithBrief -data class JavadocFunctionNode( +public data class JavadocFunctionNode( val signature: JavadocSignatureContentNode, override val brief: List<ContentNode>, val description: List<ContentNode>, @@ -174,21 +177,21 @@ data class JavadocFunctionNode( } } -class JavadocClasslikePageNode( +public class JavadocClasslikePageNode( override val name: String, override val content: JavadocContentNode, override val dri: Set<DRI>, - val signature: JavadocSignatureContentNode, - val description: List<ContentNode>, - val constructors: List<JavadocFunctionNode>, - val methods: List<JavadocFunctionNode>, - val entries: List<JavadocEntryNode>, - val classlikes: List<JavadocClasslikePageNode>, - val properties: List<JavadocPropertyNode>, + public val signature: JavadocSignatureContentNode, + public val description: List<ContentNode>, + public val constructors: List<JavadocFunctionNode>, + public val methods: List<JavadocFunctionNode>, + public val entries: List<JavadocEntryNode>, + public val classlikes: List<JavadocClasslikePageNode>, + public val properties: List<JavadocPropertyNode>, override val brief: List<ContentNode>, - val sinceTagContent: List<List<ContentNode>>, - val authorTagContent: List<List<ContentNode>>, + public val sinceTagContent: List<List<ContentNode>>, + public val authorTagContent: List<List<ContentNode>>, override val documentables: List<Documentable> = emptyList(), override val children: List<PageNode> = emptyList(), @@ -199,11 +202,11 @@ class JavadocClasslikePageNode( override fun getAllNavigables(): List<NavigableJavadocNode> = methods + entries + classlikes.map { it.getAllNavigables() }.flatten() + this - fun getAnchorables(): List<AnchorableJavadocNode> = + public fun getAnchorables(): List<AnchorableJavadocNode> = 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<JavadocClasslikePageNode>) : JavadocPageNode { - val classEntries = +public class AllClassesPage( + public val classes: List<JavadocClasslikePageNode> +) : JavadocPageNode { + public val classEntries: List<LinkJavadocListEntry> = 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<JavadocClasslikePageNode>) : JavadocPageN } -class DeprecatedPage( - val elements: Map<DeprecatedPageSection, Set<DeprecatedNode>>, +public class DeprecatedPage( + public val elements: Map<DeprecatedPageSection, Set<DeprecatedNode>>, sourceSet: Set<DisplaySourceSet> ) : JavadocPageNode { override val name: String = "deprecated" @@ -322,14 +327,22 @@ class DeprecatedPage( } -class DeprecatedNode(val name: String, val address: DRI, val description: List<ContentNode>) { +public class DeprecatedNode( + public val name: String, + public val address: DRI, + public val description: List<ContentNode> +) { 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<NavigableJavadocNode>, - val keys: List<Char>, +public class IndexPage( + public val id: Int, + public val elements: List<NavigableJavadocNode>, + public val keys: List<Char>, + sourceSet: Set<DisplaySourceSet> ) : JavadocPageNode { @@ -356,7 +370,7 @@ class IndexPage( override val documentables: List<Documentable> = emptyList() override val children: List<PageNode> = emptyList() override val embeddedResources: List<String> = 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<JavadocPackagePageNode>?, - val classes: List<JavadocClasslikePageNode>?, + public val packages: List<JavadocPackagePageNode>?, + public val classes: List<JavadocClasslikePageNode>?, override val dri: Set<DRI>, override val documentables: List<Documentable> = 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<PageNode> = 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<JavadocPackagePageNode>().flatMap { it.children.filterIsInstance<JavadocClasslikePageNode>() @@ -83,7 +88,8 @@ object AllClassesPageInstaller : PageTransformer { } } -object IndexGenerator : PageTransformer { +public object IndexGenerator : PageTransformer { + override fun invoke(input: RootPageNode): RootPageNode { val elements = HashMap<Char, MutableSet<NavigableJavadocNode>>() (input as JavadocModulePageNode).children.filterIsInstance<JavadocPackagePageNode>().forEach { @@ -125,7 +131,8 @@ object IndexGenerator : PageTransformer { } } -object DeprecatedPageCreator : PageTransformer { +public object DeprecatedPageCreator : PageTransformer { + override fun invoke(input: RootPageNode): RootPageNode { val elements = HashMap<DeprecatedPageSection, MutableSet<DeprecatedNode>>().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) -> """<em><a id="$escapedText" class="searchTagResult">${escapedText}</a></em>""" 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<String, Any?> +public typealias TemplateMap = Map<String, Any?> -class KorteJavadocRenderer(val context: DokkaContext, resourceDir: String) : - Renderer { +public class KorteJavadocRenderer( + public val context: DokkaContext, resourceDir: String +) : Renderer { private val outputWriter: OutputWriter = context.plugin<DokkaBase>().querySingle { outputWriter } private lateinit var locationProvider: JavadocLocationProvider private val registeredPreprocessors = context.plugin<JavadocPlugin>().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<JavadocPlugin>().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<JavadocPlugin>().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<RendererSpecificPage> { + public fun invoke(input: RootPageNode): List<RendererSpecificPage> { val data = when (input) { is JavadocModulePageNode -> processModules(listOf(input)) else -> processModules(input.children.filterIsInstance<JavadocModulePageNode>()) 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<DokkaBase>().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<DokkaConfiguration.DokkaSourceSet> = mainSourcesetData, extra: PropertyContainer<ContentNode> = 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<ContentNode>, private val mainSourceSet: Set<DokkaConfiguration.DokkaSourceSet>, ) { - 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" } } diff --git a/plugins/jekyll/jekyll-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/JekyllTemplateProcessingPlugin.kt b/plugins/jekyll/jekyll-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/JekyllTemplateProcessingPlugin.kt index 81293ef2..c5bcd67b 100644 --- a/plugins/jekyll/jekyll-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/JekyllTemplateProcessingPlugin.kt +++ b/plugins/jekyll/jekyll-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/JekyllTemplateProcessingPlugin.kt @@ -8,12 +8,14 @@ import org.jetbrains.dokka.allModulesPage.AllModulesPagePlugin import org.jetbrains.dokka.allModulesPage.MultimoduleLocationProvider import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProviderFactory +import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory import org.jetbrains.dokka.jekyll.JekyllPlugin import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.plugability.DokkaPluginApiPreview +import org.jetbrains.dokka.plugability.Extension import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement -class JekyllTemplateProcessingPlugin : DokkaPlugin() { +public class JekyllTemplateProcessingPlugin : DokkaPlugin() { private val allModulesPagePlugin by lazy { plugin<AllModulesPagePlugin>() } @@ -22,14 +24,14 @@ class JekyllTemplateProcessingPlugin : DokkaPlugin() { private val dokkaBase by lazy { plugin<DokkaBase>() } - val jekyllLocationProvider by extending { + public val jekyllLocationProvider: Extension<LocationProviderFactory, *, *> by extending { dokkaBase.locationProviderFactory providing MultimoduleLocationProvider::Factory override listOf( jekyllPlugin.locationProvider, gfmTemplatingPlugin.gfmLocationProvider ) } - val jekyllPartialLocationProvider by extending { + public val jekyllPartialLocationProvider: Extension<LocationProviderFactory, *, *> by extending { allModulesPagePlugin.partialLocationProviderFactory providing ::DokkaLocationProviderFactory override listOf( allModulesPagePlugin.baseLocationProviderFactory, gfmTemplatingPlugin.gfmPartialLocationProvider diff --git a/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt b/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt index 0fe43a48..733c81bb 100644 --- a/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt +++ b/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt @@ -9,6 +9,7 @@ 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.DokkaLocationProviderFactory +import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat import org.jetbrains.dokka.gfm.GfmPlugin import org.jetbrains.dokka.gfm.renderer.BriefCommentPreprocessor @@ -16,37 +17,38 @@ import org.jetbrains.dokka.gfm.renderer.CommonmarkRenderer import org.jetbrains.dokka.pages.ContentPage import org.jetbrains.dokka.plugability.* import org.jetbrains.dokka.renderers.PostAction +import org.jetbrains.dokka.renderers.Renderer import org.jetbrains.dokka.transformers.pages.PageTransformer -class JekyllPlugin : DokkaPlugin() { +public class JekyllPlugin : DokkaPlugin() { - val jekyllPreprocessors by extensionPoint<PageTransformer>() + public val jekyllPreprocessors: ExtensionPoint<PageTransformer> by extensionPoint<PageTransformer>() private val dokkaBase by lazy { plugin<DokkaBase>() } private val gfmPlugin by lazy { plugin<GfmPlugin>() } - val renderer by extending { + public val renderer: Extension<Renderer, *, *> by extending { (CoreExtensions.renderer providing { JekyllRenderer(it) } override plugin<GfmPlugin>().renderer) } - val rootCreator by extending { + public val rootCreator: Extension<PageTransformer, *, *> by extending { jekyllPreprocessors with RootCreator } - val briefCommentPreprocessor by extending { + public val briefCommentPreprocessor: Extension<PageTransformer, *, *> by extending { jekyllPreprocessors with BriefCommentPreprocessor() } - val packageListCreator by extending { + public val packageListCreator: Extension<PageTransformer, *, *> by extending { jekyllPreprocessors providing { PackageListCreator(it, RecognizedLinkFormat.DokkaJekyll) } order { after(rootCreator) } } - val locationProvider by extending { + public val locationProvider: Extension<LocationProviderFactory, *, *> by extending { dokkaBase.locationProviderFactory providing ::DokkaLocationProviderFactory override listOf(gfmPlugin.locationProvider) } @@ -66,11 +68,11 @@ class JekyllPlugin : DokkaPlugin() { PluginApiPreviewAcknowledgement } -class JekyllRenderer( +public class JekyllRenderer( context: DokkaContext ) : CommonmarkRenderer(context) { - override val preprocessors = context.plugin<JekyllPlugin>().query { jekyllPreprocessors } + override val preprocessors: List<PageTransformer> = context.plugin<JekyllPlugin>().query { jekyllPreprocessors } override fun buildPage(page: ContentPage, content: (StringBuilder, ContentPage) -> Unit): String { val builder = StringBuilder() diff --git a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt index 2ed021fb..36da34dc 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt @@ -6,33 +6,37 @@ package org.jetbrains.dokka.kotlinAsJava import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.base.DokkaBase +import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.kotlinAsJava.signatures.JavaSignatureProvider import org.jetbrains.dokka.kotlinAsJava.transformers.JvmNameDocumentableTransformer import org.jetbrains.dokka.kotlinAsJava.transformers.KotlinAsJavaDocumentableTransformer import org.jetbrains.dokka.kotlinAsJava.translators.KotlinAsJavaDocumentableToPageTranslator import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.plugability.DokkaPluginApiPreview +import org.jetbrains.dokka.plugability.Extension import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement import org.jetbrains.dokka.renderers.PostAction +import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator +import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer -class KotlinAsJavaPlugin : DokkaPlugin() { - val kotlinAsJavaDocumentableTransformer by extending { +public class KotlinAsJavaPlugin : DokkaPlugin() { + public val kotlinAsJavaDocumentableTransformer: Extension<DocumentableTransformer, *, *> by extending { CoreExtensions.documentableTransformer with KotlinAsJavaDocumentableTransformer() } - val jvmNameTransformer by extending { + public val jvmNameTransformer: Extension<DocumentableTransformer, *, *> by extending { CoreExtensions.documentableTransformer with JvmNameDocumentableTransformer() order { after(kotlinAsJavaDocumentableTransformer) } } - val javaSignatureProvider by extending { + public val javaSignatureProvider: Extension<SignatureProvider, *, *> by extending { with(plugin<DokkaBase>()) { signatureProvider providing ::JavaSignatureProvider override kotlinSignatureProvider } } - val kotlinAsJavaDocumentableToPageTranslator by extending { + public val kotlinAsJavaDocumentableToPageTranslator: Extension<DocumentableToPageTranslator, *, *> by extending { CoreExtensions.documentableToPageTranslator providing ::KotlinAsJavaDocumentableToPageTranslator override plugin<DokkaBase>().documentableToPageTranslator } diff --git a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt index 4a8979b0..a8b3a86c 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt @@ -17,7 +17,7 @@ import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin -val jvmNameProvider = JvmNameProvider() +public val jvmNameProvider: JvmNameProvider = JvmNameProvider() internal const val OBJECT_INSTANCE_NAME = "INSTANCE" internal val DProperty.isConst: Boolean @@ -37,7 +37,7 @@ private fun DProperty.hasModifier(modifier: ExtraModifiers.KotlinOnlyModifiers): ?.content ?.any { (_, modifiers) -> modifier in modifiers } == true -class KotlinToJavaConverter( +public class KotlinToJavaConverter( private val context: DokkaContext ) { private val kotlinToJavaMapper by lazy { diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt index 20f7e941..e4c9d5dd 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt @@ -22,12 +22,16 @@ import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.utilities.DokkaLogger import kotlin.text.Typography.nbsp -class JavaSignatureProvider internal constructor(ctcc: CommentsToContentConverter, logger: DokkaLogger) : SignatureProvider, - JvmSignatureUtils by JavaSignatureUtils { - constructor(context: DokkaContext) : this( +public class JavaSignatureProvider internal constructor( + ctcc: CommentsToContentConverter, + logger: DokkaLogger +) : SignatureProvider, JvmSignatureUtils by JavaSignatureUtils { + + public constructor(context: DokkaContext) : this( context.plugin<DokkaBase>().querySingle { commentsToContentConverter }, context.logger ) + private val contentBuilder = PageContentBuilder(ctcc, this, logger) private val ignoredVisibilities = setOf(JavaVisibility.Default) diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt index 864e4db8..1738d40d 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt @@ -4,6 +4,7 @@ package org.jetbrains.dokka.kotlinAsJava.signatures +import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.base.signatures.All import org.jetbrains.dokka.base.signatures.JvmSignatureUtils import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder @@ -12,7 +13,7 @@ import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.AnnotationTarget import org.jetbrains.dokka.model.properties.WithExtraProperties -object JavaSignatureUtils : JvmSignatureUtils { +public object JavaSignatureUtils : JvmSignatureUtils { private val ignoredAnnotations = setOf( Annotations.Annotation(DRI("kotlin.jvm", "Transient"), emptyMap()), @@ -26,15 +27,18 @@ object JavaSignatureUtils : JvmSignatureUtils { private val listBrackets = Pair('{', '}') private val classExtension = ".class" - override fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: AnnotationTarget) = + override fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: AnnotationTarget) { annotationsBlockWithIgnored(d, ignoredAnnotations, strategy, listBrackets, classExtension) + } - override fun PageContentBuilder.DocumentableContentBuilder.annotationsInline(d: AnnotationTarget) = + override fun PageContentBuilder.DocumentableContentBuilder.annotationsInline(d: AnnotationTarget) { annotationsInlineWithIgnored(d, ignoredAnnotations, strategy, listBrackets, classExtension) + } - override fun <T : Documentable> WithExtraProperties<T>.modifiers() = - extra[AdditionalModifiers]?.content?.entries?.associate { + override fun <T : Documentable> WithExtraProperties<T>.modifiers(): Map<DokkaConfiguration.DokkaSourceSet, Set<ExtraModifiers.JavaOnlyModifiers>> { + return extra[AdditionalModifiers]?.content?.entries?.associate { it.key to it.value.filterIsInstance<ExtraModifiers.JavaOnlyModifiers>().toSet() } ?: emptyMap() + } } diff --git a/plugins/kotlin-as-java/src/main/kotlin/transformToJava.kt b/plugins/kotlin-as-java/src/main/kotlin/transformToJava.kt index 477a3a6d..32344dd9 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/transformToJava.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/transformToJava.kt @@ -16,26 +16,26 @@ private val JVM_NAME_DOCUMENTABLE_TRANSFORMER by lazy { JvmNameDocumentableTransformer() } -fun DPackage.transformToJava(context: DokkaContext): DPackage { +public fun DPackage.transformToJava(context: DokkaContext): DPackage { with(KotlinToJavaConverter(context)) { return JVM_NAME_DOCUMENTABLE_TRANSFORMER.transform(this@transformToJava.asJava(), context) } } -fun DClasslike.transformToJava(context: DokkaContext): DClasslike { +public fun DClasslike.transformToJava(context: DokkaContext): DClasslike { with(KotlinToJavaConverter(context)) { return JVM_NAME_DOCUMENTABLE_TRANSFORMER.transform(this@transformToJava.asJava(), context) } } -fun DFunction.transformToJava(context: DokkaContext, containingClassName: String, isTopLevel: Boolean = false): List<DFunction> { +public fun DFunction.transformToJava(context: DokkaContext, containingClassName: String, isTopLevel: Boolean = false): List<DFunction> { with(KotlinToJavaConverter(context)) { return this@transformToJava.asJava(containingClassName, isTopLevel) .map { JVM_NAME_DOCUMENTABLE_TRANSFORMER.transform(it, context) } } } -fun DProperty.transformToJava(context: DokkaContext, isTopLevel: Boolean = false, relocateToClass: String? = null): DProperty { +public fun DProperty.transformToJava(context: DokkaContext, isTopLevel: Boolean = false, relocateToClass: String? = null): DProperty { with(KotlinToJavaConverter(context)) { return JVM_NAME_DOCUMENTABLE_TRANSFORMER.transform(this@transformToJava.asJava(isTopLevel, relocateToClass), context) } diff --git a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameDocumentableTransformer.kt b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameDocumentableTransformer.kt index dbfbf8ae..fe625e1c 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameDocumentableTransformer.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameDocumentableTransformer.kt @@ -9,7 +9,7 @@ import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer -class JvmNameDocumentableTransformer : DocumentableTransformer { +public class JvmNameDocumentableTransformer : DocumentableTransformer { private val jvmNameProvider = JvmNameProvider() override fun invoke(original: DModule, context: DokkaContext): DModule { diff --git a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt index 83576278..caf76b68 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt @@ -10,26 +10,26 @@ import org.jetbrains.dokka.kotlinAsJava.jvmNameAsString import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.properties.WithExtraProperties -data class Name(val fqName: String) { - val name = fqName.substringAfterLast(".") +public data class Name(val fqName: String) { + val name: String = fqName.substringAfterLast(".") } -class JvmNameProvider { - fun <T> nameFor(entry: T): String where T : Documentable, T : WithExtraProperties<T> = +public class JvmNameProvider { + public fun <T> nameFor(entry: T): String where T : Documentable, T : WithExtraProperties<T> = entry.directlyAnnotatedJvmName()?.jvmNameAsString() ?: entry.name ?: throw IllegalStateException("Failed to provide a name for ${entry.javaClass.canonicalName}") - fun <T> nameForSyntheticClass(entry: T): Name where T : WithSources, T : WithExtraProperties<T>, T : Documentable { + public fun <T> nameForSyntheticClass(entry: T): Name where T : WithSources, T : WithExtraProperties<T>, T : Documentable { val name: String = (entry.fileLevelJvmName()?.params?.get("name") as? StringValue)?.value ?: (entry.sources.entries.first().value.path.split("/").last().split(".").first().capitalize() + "Kt") return Name("${entry.dri.packageName}.$name") } - fun nameForGetter(entry: DProperty): String? = + public fun nameForGetter(entry: DProperty): String? = entry.getter?.directlyAnnotatedJvmName()?.jvmNameAsString() - fun nameForSetter(entry: DProperty): String? = + public fun nameForSetter(entry: DProperty): String? = entry.setter?.directlyAnnotatedJvmName()?.jvmNameAsString() private fun List<Annotations.Annotation>.jvmNameAnnotation(): Annotations.Annotation? = diff --git a/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt b/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt index 11dfae9b..45682ea4 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt @@ -9,7 +9,7 @@ import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer -class KotlinAsJavaDocumentableTransformer : DocumentableTransformer { +public class KotlinAsJavaDocumentableTransformer : DocumentableTransformer { override fun invoke(original: DModule, context: DokkaContext): DModule = original.copy(packages = original.packages.map { with(KotlinToJavaConverter(context)) { diff --git a/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt b/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt index 6b8249d9..a0ed24d4 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt @@ -13,7 +13,9 @@ import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslat import org.jetbrains.dokka.utilities.DokkaLogger import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin -class KotlinAsJavaDocumentableToPageTranslator(context: DokkaContext) : DocumentableToPageTranslator { +public class KotlinAsJavaDocumentableToPageTranslator( + context: DokkaContext +) : DocumentableToPageTranslator { private val configuration = configuration<DokkaBase, DokkaBaseConfiguration>(context) private val commentsToContentConverter = context.plugin<DokkaBase>().querySingle { commentsToContentConverter } private val signatureProvider = context.plugin<DokkaBase>().querySingle { signatureProvider } diff --git a/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaPageCreator.kt b/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaPageCreator.kt index af6670a3..fcdc1d83 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaPageCreator.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaPageCreator.kt @@ -14,7 +14,7 @@ import org.jetbrains.dokka.pages.MemberPageNode import org.jetbrains.dokka.utilities.DokkaLogger import org.jetbrains.dokka.analysis.kotlin.internal.DocumentableSourceLanguageParser -class KotlinAsJavaPageCreator( +public class KotlinAsJavaPageCreator( configuration: DokkaBaseConfiguration?, commentsToContentConverter: CommentsToContentConverter, signatureProvider: SignatureProvider, diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index 0af9606c..2a7ed6a4 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -16,15 +16,17 @@ import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.pages.WithDocumentables import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.plugability.DokkaPluginApiPreview +import org.jetbrains.dokka.plugability.Extension import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement import org.jetbrains.dokka.transformers.pages.PageTransformer -class MathjaxPlugin : DokkaPlugin() { - val transformer by extending { +public class MathjaxPlugin : DokkaPlugin() { + + public val transformer: Extension<PageTransformer, *, *> by extending { CoreExtensions.pageTransformer with MathjaxTransformer } - val mathjaxTagContentProvider by extending { + public val mathjaxTagContentProvider: Extension<CustomTagContentProvider, *, *> by extending { plugin<DokkaBase>().customTagContentProvider with MathjaxTagContentProvider order { before(plugin<DokkaBase>().sinceKotlinTagContentProvider) } @@ -38,8 +40,9 @@ class MathjaxPlugin : DokkaPlugin() { private const val ANNOTATION = "usesMathJax" internal const val LIB_PATH = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS_SVG&latest" -object MathjaxTransformer : PageTransformer { - override fun invoke(input: RootPageNode) = input.transformContentPagesTree { +public object MathjaxTransformer : PageTransformer { + + override fun invoke(input: RootPageNode): RootPageNode = input.transformContentPagesTree { it.modified( embeddedResources = it.embeddedResources + if (it.isNeedingMathjax) listOf(LIB_PATH) else emptyList() ) @@ -50,9 +53,10 @@ object MathjaxTransformer : PageTransformer { .flatMap { it.children } .any { (it as? CustomTagWrapper)?.name == ANNOTATION } } } -object MathjaxTagContentProvider : CustomTagContentProvider { - override fun isApplicable(customTag: CustomTagWrapper) = customTag.name == ANNOTATION +public object MathjaxTagContentProvider : CustomTagContentProvider { + + override fun isApplicable(customTag: CustomTagWrapper): Boolean = customTag.name == ANNOTATION override fun DocumentableContentBuilder.contentForDescription( sourceSet: DokkaConfiguration.DokkaSourceSet, diff --git a/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt b/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt index de4e3637..78c6c684 100644 --- a/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt +++ b/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt @@ -14,7 +14,9 @@ import java.io.File import java.nio.file.Files import java.util.concurrent.ConcurrentHashMap -class AddToNavigationCommandHandler(val context: DokkaContext) : CommandHandler { +public class AddToNavigationCommandHandler( + public val context: DokkaContext +) : CommandHandler { private val navigationFragments = ConcurrentHashMap<String, Element>() override fun handleCommandAsTag(command: Command, body: Element, input: File, output: File) { @@ -25,7 +27,7 @@ class AddToNavigationCommandHandler(val context: DokkaContext) : CommandHandler ?.let { key -> navigationFragments[key.toString()] = body } } - override fun canHandle(command: Command) = command is AddToNavigationCommand + override fun canHandle(command: Command): Boolean = command is AddToNavigationCommand override fun finish(output: File) { if (navigationFragments.isNotEmpty()) { diff --git a/plugins/templating/src/main/kotlin/templates/CommandHandler.kt b/plugins/templating/src/main/kotlin/templates/CommandHandler.kt index 1aeda1ca..c06d52c3 100644 --- a/plugins/templating/src/main/kotlin/templates/CommandHandler.kt +++ b/plugins/templating/src/main/kotlin/templates/CommandHandler.kt @@ -10,14 +10,16 @@ import org.jsoup.nodes.Node import java.io.File -interface CommandHandler { +public interface CommandHandler { @Deprecated("This was renamed to handleCommandAsTag", ReplaceWith("handleCommandAsTag(command, element, input, output)")) - fun handleCommand(element: Element, command: Command, input: File, output: File) { } + public fun handleCommand(element: Element, command: Command, input: File, output: File) { } @Suppress("DEPRECATION") - fun handleCommandAsTag(command: Command, body: Element, input: File, output: File) = + public fun handleCommandAsTag(command: Command, body: Element, input: File, output: File) { handleCommand(body, command, input, output) - fun handleCommandAsComment(command: Command, body: List<Node>, input: File, output: File) { } - fun canHandle(command: Command): Boolean - fun finish(output: File) {} + } + public fun handleCommandAsComment(command: Command, body: List<Node>, input: File, output: File) { } + public fun canHandle(command: Command): Boolean + public fun finish(output: File) {} } + diff --git a/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt b/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt index 5828884b..c36f2834 100644 --- a/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt +++ b/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt @@ -21,7 +21,7 @@ import org.jsoup.nodes.TextNode import java.io.File import java.nio.file.Files -class DirectiveBasedHtmlTemplateProcessingStrategy(private val context: DokkaContext) : TemplateProcessingStrategy { +public class DirectiveBasedHtmlTemplateProcessingStrategy(private val context: DokkaContext) : TemplateProcessingStrategy { private val directiveBasedCommandHandlers = context.plugin<TemplatingPlugin>().query { directiveBasedCommandHandlers } @@ -45,11 +45,11 @@ class DirectiveBasedHtmlTemplateProcessingStrategy(private val context: DokkaCon true } else false - fun handleCommandAsTag(element: Element, command: Command, input: File, output: File) { + public fun handleCommandAsTag(element: Element, command: Command, input: File, output: File) { traverseHandlers(command) { handleCommandAsTag(command, element, input, output) } } - fun handleCommandAsComment(command: Command, body: List<Node>, input: File, output: File) { + public fun handleCommandAsComment(command: Command, body: List<Node>, input: File, output: File) { traverseHandlers(command) { handleCommandAsComment(command, body, input, output) } } diff --git a/plugins/templating/src/main/kotlin/templates/FallbackTemplateProcessingStrategy.kt b/plugins/templating/src/main/kotlin/templates/FallbackTemplateProcessingStrategy.kt index 60333445..a76d8eae 100644 --- a/plugins/templating/src/main/kotlin/templates/FallbackTemplateProcessingStrategy.kt +++ b/plugins/templating/src/main/kotlin/templates/FallbackTemplateProcessingStrategy.kt @@ -7,7 +7,7 @@ package org.jetbrains.dokka.templates import org.jetbrains.dokka.DokkaConfiguration import java.io.File -class FallbackTemplateProcessingStrategy : TemplateProcessingStrategy { +public class FallbackTemplateProcessingStrategy : TemplateProcessingStrategy { override fun process(input: File, output: File, moduleContext: DokkaConfiguration.DokkaModuleDescription?): Boolean { if (input != output) input.copyTo(output, overwrite = true) diff --git a/plugins/templating/src/main/kotlin/templates/JsonElementBasedTemplateProcessingStrategy.kt b/plugins/templating/src/main/kotlin/templates/JsonElementBasedTemplateProcessingStrategy.kt index 59432f0b..8c6cee03 100644 --- a/plugins/templating/src/main/kotlin/templates/JsonElementBasedTemplateProcessingStrategy.kt +++ b/plugins/templating/src/main/kotlin/templates/JsonElementBasedTemplateProcessingStrategy.kt @@ -14,13 +14,15 @@ import org.jetbrains.dokka.templates.TemplateProcessingStrategy import java.io.File import java.util.concurrent.ConcurrentHashMap -abstract class BaseJsonNavigationTemplateProcessingStrategy(val context: DokkaContext) : TemplateProcessingStrategy { - abstract val navigationFileNameWithoutExtension: String - abstract val path: String +public abstract class BaseJsonNavigationTemplateProcessingStrategy( + public val context: DokkaContext +) : TemplateProcessingStrategy { + public abstract val navigationFileNameWithoutExtension: String + public abstract val path: String private val fragments = ConcurrentHashMap<String, List<SearchRecord>>() - open fun canProcess(file: File): Boolean = + public open fun canProcess(file: File): Boolean = file.extension == "json" && file.nameWithoutExtension == navigationFileNameWithoutExtension override fun process(input: File, output: File, moduleContext: DokkaModuleDescription?): Boolean { @@ -57,8 +59,9 @@ abstract class BaseJsonNavigationTemplateProcessingStrategy(val context: DokkaCo } -class PagesSearchTemplateStrategy(val dokkaContext: DokkaContext) : - BaseJsonNavigationTemplateProcessingStrategy(dokkaContext) { +public class PagesSearchTemplateStrategy( + public val dokkaContext: DokkaContext +) : BaseJsonNavigationTemplateProcessingStrategy(dokkaContext) { override val navigationFileNameWithoutExtension: String = "pages" override val path: String = "scripts" } diff --git a/plugins/templating/src/main/kotlin/templates/PackageListProcessingStrategy.kt b/plugins/templating/src/main/kotlin/templates/PackageListProcessingStrategy.kt index bbee8280..4da45e3f 100644 --- a/plugins/templating/src/main/kotlin/templates/PackageListProcessingStrategy.kt +++ b/plugins/templating/src/main/kotlin/templates/PackageListProcessingStrategy.kt @@ -12,7 +12,9 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.templates.TemplateProcessingStrategy import java.io.File -class PackageListProcessingStrategy(val context: DokkaContext) : TemplateProcessingStrategy { +public class PackageListProcessingStrategy( + public val context: DokkaContext +) : TemplateProcessingStrategy { private val fragments = mutableSetOf<PackageList>() private fun canProcess(file: File, moduleContext: DokkaModuleDescription?): Boolean = diff --git a/plugins/templating/src/main/kotlin/templates/PathToRootSubstitutor.kt b/plugins/templating/src/main/kotlin/templates/PathToRootSubstitutor.kt index 883568ef..2ba290cf 100644 --- a/plugins/templating/src/main/kotlin/templates/PathToRootSubstitutor.kt +++ b/plugins/templating/src/main/kotlin/templates/PathToRootSubstitutor.kt @@ -9,7 +9,9 @@ import org.jetbrains.dokka.base.templating.SubstitutionCommand import org.jetbrains.dokka.plugability.DokkaContext import java.io.File -class PathToRootSubstitutor(private val dokkaContext: DokkaContext) : Substitutor { +public class PathToRootSubstitutor( + private val dokkaContext: DokkaContext +) : Substitutor { override fun trySubstitute(context: TemplatingContext<SubstitutionCommand>, match: MatchResult): String? = if (context.command is PathToRootSubstitutionCommand) { diff --git a/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt b/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt index 52d980fb..9b22f31b 100644 --- a/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt +++ b/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt @@ -10,7 +10,9 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.templates.Substitutor import org.jetbrains.dokka.templates.TemplatingContext -class ProjectNameSubstitutor(private val dokkaContext: DokkaContext) : Substitutor { +public class ProjectNameSubstitutor( + private val dokkaContext: DokkaContext +) : Substitutor { override fun trySubstitute(context: TemplatingContext<SubstitutionCommand>, match: MatchResult): String? = dokkaContext.configuration.moduleName.takeIf { context.command is ProjectNameSubstitutionCommand } diff --git a/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt b/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt index ec441226..28820278 100644 --- a/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt +++ b/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt @@ -12,7 +12,9 @@ import org.jsoup.nodes.Element import org.jsoup.nodes.TextNode import java.io.File -class ReplaceVersionCommandHandler(private val context: DokkaContext) : CommandHandler { +public class ReplaceVersionCommandHandler( + private val context: DokkaContext +) : CommandHandler { override fun canHandle(command: Command): Boolean = command is ReplaceVersionsCommand diff --git a/plugins/templating/src/main/kotlin/templates/SourcesetDependencyProcessingStrategy.kt b/plugins/templating/src/main/kotlin/templates/SourcesetDependencyProcessingStrategy.kt index 2a70c520..38a08eea 100644 --- a/plugins/templating/src/main/kotlin/templates/SourcesetDependencyProcessingStrategy.kt +++ b/plugins/templating/src/main/kotlin/templates/SourcesetDependencyProcessingStrategy.kt @@ -15,7 +15,9 @@ import java.util.concurrent.ConcurrentHashMap private typealias Entry = Map<String, List<String>> -class SourcesetDependencyProcessingStrategy(val context: DokkaContext) : TemplateProcessingStrategy { +public class SourcesetDependencyProcessingStrategy( + public val context: DokkaContext +) : TemplateProcessingStrategy { private val fileName = "sourceset_dependencies.js" private val fragments = ConcurrentHashMap<String, Entry>() diff --git a/plugins/templating/src/main/kotlin/templates/SubstitutionCommandHandler.kt b/plugins/templating/src/main/kotlin/templates/SubstitutionCommandHandler.kt index 3ca2568b..0c030439 100644 --- a/plugins/templating/src/main/kotlin/templates/SubstitutionCommandHandler.kt +++ b/plugins/templating/src/main/kotlin/templates/SubstitutionCommandHandler.kt @@ -15,7 +15,7 @@ import org.jsoup.nodes.Node import org.jsoup.nodes.TextNode import java.io.File -class SubstitutionCommandHandler(context: DokkaContext) : CommandHandler { +public class SubstitutionCommandHandler(context: DokkaContext) : CommandHandler { override fun handleCommandAsTag(command: Command, body: Element, input: File, output: File) { command as SubstitutionCommand diff --git a/plugins/templating/src/main/kotlin/templates/Substitutor.kt b/plugins/templating/src/main/kotlin/templates/Substitutor.kt index b33f585d..4dc4d353 100644 --- a/plugins/templating/src/main/kotlin/templates/Substitutor.kt +++ b/plugins/templating/src/main/kotlin/templates/Substitutor.kt @@ -6,6 +6,6 @@ package org.jetbrains.dokka.templates import org.jetbrains.dokka.base.templating.SubstitutionCommand -fun interface Substitutor { - fun trySubstitute(context: TemplatingContext<SubstitutionCommand>, match: MatchResult): String? +public fun interface Substitutor { + public fun trySubstitute(context: TemplatingContext<SubstitutionCommand>, match: MatchResult): String? } diff --git a/plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt b/plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt index 2cbbc215..762e3c8b 100644 --- a/plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt +++ b/plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt @@ -19,22 +19,22 @@ import org.jetbrains.dokka.plugability.querySingle import org.jsoup.nodes.Node import java.io.File -interface TemplateProcessor +public interface TemplateProcessor -interface SubmoduleTemplateProcessor : TemplateProcessor { - fun process(modules: List<DokkaModuleDescription>): TemplatingResult +public interface SubmoduleTemplateProcessor : TemplateProcessor { + public fun process(modules: List<DokkaModuleDescription>): TemplatingResult } -interface MultiModuleTemplateProcessor : TemplateProcessor { - fun process(generatedPagesTree: RootPageNode) +public interface MultiModuleTemplateProcessor : TemplateProcessor { + public fun process(generatedPagesTree: RootPageNode) } -interface TemplateProcessingStrategy { - fun process(input: File, output: File, moduleContext: DokkaModuleDescription?): Boolean - fun finish(output: File) {} +public interface TemplateProcessingStrategy { + public fun process(input: File, output: File, moduleContext: DokkaModuleDescription?): Boolean + public fun finish(output: File) {} } -class DefaultSubmoduleTemplateProcessor( +public class DefaultSubmoduleTemplateProcessor( private val context: DokkaContext, ) : SubmoduleTemplateProcessor { @@ -44,14 +44,15 @@ class DefaultSubmoduleTemplateProcessor( private val configuredModulesPaths = context.configuration.modules.associate { it.sourceOutputDirectory.absolutePath to it.name } - override fun process(modules: List<DokkaModuleDescription>) = - runBlocking(Dispatchers.Default) { + override fun process(modules: List<DokkaModuleDescription>): TemplatingResult { + return runBlocking(Dispatchers.Default) { coroutineScope { modules.fold(TemplatingResult()) { acc, module -> acc + module.sourceOutputDirectory.visit(context.configuration.outputDir.resolve(module.relativePathToOutputDirectory), module) } } } + } private suspend fun File.visit(target: File, module: DokkaModuleDescription, acc: TemplatingResult = TemplatingResult()): TemplatingResult = coroutineScope { @@ -74,8 +75,8 @@ class DefaultSubmoduleTemplateProcessor( } } -class DefaultMultiModuleTemplateProcessor( - val context: DokkaContext, +public class DefaultMultiModuleTemplateProcessor( + public val context: DokkaContext, ) : MultiModuleTemplateProcessor { private val strategies: List<TemplateProcessingStrategy> = context.plugin<TemplatingPlugin>().query { templateProcessingStrategy } @@ -89,13 +90,15 @@ class DefaultMultiModuleTemplateProcessor( } } -data class TemplatingContext<out T : Command>( +public data class TemplatingContext<out T : Command>( val input: File, val output: File, val body: List<Node>, val command: T, ) -data class TemplatingResult(val modules: List<String> = emptyList()) { - operator fun plus(rhs: TemplatingResult): TemplatingResult = TemplatingResult((modules + rhs.modules).distinct()) +public data class TemplatingResult(val modules: List<String> = emptyList()) { + public operator fun plus(rhs: TemplatingResult): TemplatingResult { + return TemplatingResult((modules + rhs.modules).distinct()) + } } diff --git a/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt b/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt index a8d126d0..8a2e5a2a 100644 --- a/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt +++ b/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt @@ -6,74 +6,71 @@ package org.jetbrains.dokka.templates import org.jetbrains.dokka.allModulesPage.templates.PackageListProcessingStrategy import org.jetbrains.dokka.allModulesPage.templates.PagesSearchTemplateStrategy -import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.plugability.DokkaPluginApiPreview -import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement +import org.jetbrains.dokka.plugability.* import templates.ProjectNameSubstitutor import templates.ReplaceVersionCommandHandler import templates.SourcesetDependencyProcessingStrategy @Suppress("unused") -class TemplatingPlugin : DokkaPlugin() { +public class TemplatingPlugin : DokkaPlugin() { - val submoduleTemplateProcessor by extensionPoint<SubmoduleTemplateProcessor>() - val multimoduleTemplateProcessor by extensionPoint<MultiModuleTemplateProcessor>() - val templateProcessingStrategy by extensionPoint<TemplateProcessingStrategy>() - val directiveBasedCommandHandlers by extensionPoint<CommandHandler>() + public val submoduleTemplateProcessor: ExtensionPoint<SubmoduleTemplateProcessor> by extensionPoint() + public val multimoduleTemplateProcessor: ExtensionPoint<MultiModuleTemplateProcessor> by extensionPoint() + public val templateProcessingStrategy: ExtensionPoint<TemplateProcessingStrategy> by extensionPoint() + public val directiveBasedCommandHandlers: ExtensionPoint<CommandHandler> by extensionPoint() + public val substitutor: ExtensionPoint<Substitutor> by extensionPoint() - val substitutor by extensionPoint<Substitutor>() - - val defaultSubmoduleTemplateProcessor by extending { + public val defaultSubmoduleTemplateProcessor: Extension<SubmoduleTemplateProcessor, *, *> by extending { submoduleTemplateProcessor providing ::DefaultSubmoduleTemplateProcessor } - val defaultMultiModuleTemplateProcessor by extending { + public val defaultMultiModuleTemplateProcessor: Extension<MultiModuleTemplateProcessor, *, *> by extending { multimoduleTemplateProcessor providing ::DefaultMultiModuleTemplateProcessor } - val directiveBasedHtmlTemplateProcessingStrategy by extending { + public val directiveBasedHtmlTemplateProcessingStrategy: Extension<TemplateProcessingStrategy, *, *> by extending { templateProcessingStrategy providing ::DirectiveBasedHtmlTemplateProcessingStrategy order { before(fallbackProcessingStrategy) } } - val sourcesetDependencyProcessingStrategy by extending { + public val sourcesetDependencyProcessingStrategy: Extension<TemplateProcessingStrategy, *, *> by extending { templateProcessingStrategy providing ::SourcesetDependencyProcessingStrategy order { before(fallbackProcessingStrategy) } } - val pagesSearchTemplateStrategy by extending { + public val pagesSearchTemplateStrategy: Extension<TemplateProcessingStrategy, *, *> by extending { templateProcessingStrategy providing ::PagesSearchTemplateStrategy order { before(fallbackProcessingStrategy) } } - val packageListProcessingStrategy by extending { + public val packageListProcessingStrategy: Extension<TemplateProcessingStrategy, *, *> by extending { templateProcessingStrategy providing ::PackageListProcessingStrategy order { before(fallbackProcessingStrategy) } } - val fallbackProcessingStrategy by extending { + public val fallbackProcessingStrategy: Extension<TemplateProcessingStrategy, *, *> by extending { templateProcessingStrategy with FallbackTemplateProcessingStrategy() } - val pathToRootSubstitutor by extending { + public val pathToRootSubstitutor: Extension<Substitutor, *, *> by extending { substitutor providing ::PathToRootSubstitutor } - val projectNameSubstitutor by extending { + public val projectNameSubstitutor: Extension<Substitutor, *, *> by extending { substitutor providing ::ProjectNameSubstitutor } - val addToNavigationCommandHandler by extending { + public val addToNavigationCommandHandler: Extension<CommandHandler, *, *> by extending { directiveBasedCommandHandlers providing ::AddToNavigationCommandHandler } - val substitutionCommandHandler by extending { + public val substitutionCommandHandler: Extension<CommandHandler, *, *> by extending { directiveBasedCommandHandlers providing ::SubstitutionCommandHandler } - val replaceVersionCommandHandler by extending { + public val replaceVersionCommandHandler: Extension<CommandHandler, *, *> by extending { directiveBasedCommandHandlers providing ::ReplaceVersionCommandHandler } diff --git a/plugins/versioning/api/versioning.api b/plugins/versioning/api/versioning.api index b163fd4a..6ba2c822 100644 --- a/plugins/versioning/api/versioning.api +++ b/plugins/versioning/api/versioning.api @@ -114,7 +114,7 @@ public final class org/jetbrains/dokka/versioning/VersioningConfiguration$Compan public final fun getDefaultOlderVersions ()Ljava/util/List; public final fun getDefaultOlderVersionsDir ()Ljava/io/File; public final fun getDefaultRenderVersionsNavigationOnAllPages ()Z - public final fun getDefaultVersion ()Ljava/lang/Void; + public final fun getDefaultVersion ()Ljava/lang/String; public final fun getDefaultVersionsOrdering ()Ljava/util/List; } diff --git a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/DefaultPreviousDocumentationCopyPostAction.kt b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/DefaultPreviousDocumentationCopyPostAction.kt index 037e0e47..7e03f59c 100644 --- a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/DefaultPreviousDocumentationCopyPostAction.kt +++ b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/DefaultPreviousDocumentationCopyPostAction.kt @@ -17,7 +17,9 @@ import org.jetbrains.dokka.templates.TemplateProcessingStrategy import org.jetbrains.dokka.templates.TemplatingPlugin import java.io.File -class DefaultPreviousDocumentationCopyPostAction(private val context: DokkaContext) : PostAction { +public class DefaultPreviousDocumentationCopyPostAction( + private val context: DokkaContext +) : PostAction { private val versioningStorage by lazy { context.plugin<VersioningPlugin>().querySingle { versioningStorage } } private val processingStrategies: List<TemplateProcessingStrategy> = context.plugin<TemplatingPlugin>().query { templateProcessingStrategy } diff --git a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/ReplaceVersionCommandConsumer.kt b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/ReplaceVersionCommandConsumer.kt index 39e089b8..b31afb9a 100644 --- a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/ReplaceVersionCommandConsumer.kt +++ b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/ReplaceVersionCommandConsumer.kt @@ -17,14 +17,14 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.querySingle -class ReplaceVersionCommandConsumer(context: DokkaContext) : ImmediateHtmlCommandConsumer { +public class ReplaceVersionCommandConsumer(context: DokkaContext) : ImmediateHtmlCommandConsumer { private val versionsNavigationCreator = context.plugin<VersioningPlugin>().querySingle { versionsNavigationCreator } private val versioningStorage = context.plugin<VersioningPlugin>().querySingle { versioningStorage } - override fun canProcess(command: Command) = command is ReplaceVersionsCommand + override fun canProcess(command: Command): Boolean = command is ReplaceVersionsCommand override fun <R> processCommand( command: Command, diff --git a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/ReplaceVersionsCommand.kt b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/ReplaceVersionsCommand.kt index 065bdc58..c9bc57b2 100644 --- a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/ReplaceVersionsCommand.kt +++ b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/ReplaceVersionsCommand.kt @@ -14,9 +14,9 @@ import org.jetbrains.dokka.templates.CommandHandler import org.jsoup.nodes.Element import java.io.File -class ReplaceVersionCommandHandler(context: DokkaContext) : CommandHandler { +public class ReplaceVersionCommandHandler(context: DokkaContext) : CommandHandler { - val versionsNavigationCreator by lazy { + public val versionsNavigationCreator: VersionsNavigationCreator by lazy { context.plugin<VersioningPlugin>().querySingle { versionsNavigationCreator } } diff --git a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersioningConfiguration.kt b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersioningConfiguration.kt index 2d8cc987..91b1117d 100644 --- a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersioningConfiguration.kt +++ b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersioningConfiguration.kt @@ -8,7 +8,7 @@ import org.jetbrains.dokka.plugability.ConfigurableBlock import org.jetbrains.dokka.plugability.DokkaContext import java.io.File -data class VersioningConfiguration( +public data class VersioningConfiguration( var olderVersionsDir: File? = defaultOlderVersionsDir, var olderVersions: List<File>? = defaultOlderVersions, var versionsOrdering: List<String>? = defaultVersionsOrdering, @@ -25,14 +25,14 @@ data class VersioningConfiguration( return olderVersionsDir?.listFiles()?.toList().orEmpty() + olderVersions.orEmpty() } - companion object { - val defaultOlderVersionsDir: File? = null - val defaultOlderVersions: List<File>? = null - val defaultVersionsOrdering: List<String>? = null - val defaultVersion = null - val defaultRenderVersionsNavigationOnAllPages = true + public companion object { + public val defaultOlderVersionsDir: File? = null + public val defaultOlderVersions: List<File>? = null + public val defaultVersionsOrdering: List<String>? = null + public val defaultVersion: String? = null + public val defaultRenderVersionsNavigationOnAllPages: Boolean = true - const val OLDER_VERSIONS_DIR = "older" - const val VERSIONS_FILE = "version.json" + public const val OLDER_VERSIONS_DIR: String = "older" + public const val VERSIONS_FILE: String = "version.json" } } diff --git a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersioningPlugin.kt b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersioningPlugin.kt index 652d5ff2..2e1fde8d 100644 --- a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersioningPlugin.kt +++ b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersioningPlugin.kt @@ -6,53 +6,61 @@ package org.jetbrains.dokka.versioning import org.jetbrains.dokka.CoreExtensions.postActions import org.jetbrains.dokka.base.DokkaBase -import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.plugability.DokkaPluginApiPreview -import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement -import org.jetbrains.dokka.plugability.configuration +import org.jetbrains.dokka.base.templating.ImmediateHtmlCommandConsumer +import org.jetbrains.dokka.plugability.* +import org.jetbrains.dokka.renderers.PostAction +import org.jetbrains.dokka.templates.CommandHandler import org.jetbrains.dokka.templates.TemplatingPlugin +import org.jetbrains.dokka.transformers.pages.PageTransformer -class VersioningPlugin : DokkaPlugin() { +public class VersioningPlugin : DokkaPlugin() { - val versioningStorage by extensionPoint<VersioningStorage>() - val versionsNavigationCreator by extensionPoint<VersionsNavigationCreator>() - val versionsOrdering by extensionPoint<VersionsOrdering>() + public val versioningStorage: ExtensionPoint<VersioningStorage> by extensionPoint() + public val versionsNavigationCreator: ExtensionPoint<VersionsNavigationCreator> by extensionPoint() + public val versionsOrdering: ExtensionPoint<VersionsOrdering> by extensionPoint() private val dokkaBase by lazy { plugin<DokkaBase>() } private val templatingPlugin by lazy { plugin<TemplatingPlugin>() } - val defaultVersioningStorage by extending { + public val defaultVersioningStorage: Extension<VersioningStorage, *, *> by extending { versioningStorage providing ::DefaultVersioningStorage } - val defaultVersioningNavigationCreator by extending { + + public val defaultVersioningNavigationCreator: Extension<VersionsNavigationCreator, *, *> by extending { versionsNavigationCreator providing ::HtmlVersionsNavigationCreator } - val replaceVersionCommandHandler by extending { + + public val replaceVersionCommandHandler: Extension<CommandHandler, *, *> by extending { templatingPlugin.directiveBasedCommandHandlers providing ::ReplaceVersionCommandHandler override templatingPlugin.replaceVersionCommandHandler } - val resolveLinkConsumer by extending { + + public val resolveLinkConsumer: Extension<ImmediateHtmlCommandConsumer, *, *> by extending { dokkaBase.immediateHtmlCommandConsumer providing ::ReplaceVersionCommandConsumer override dokkaBase.replaceVersionConsumer } - val cssStyleInstaller by extending { + + public val cssStyleInstaller: Extension<PageTransformer, *, *> by extending { dokkaBase.htmlPreprocessors providing ::MultiModuleStylesInstaller order { after(dokkaBase.assetsInstaller) before(dokkaBase.customResourceInstaller) } } - val notFoundPageInstaller by extending { + + public val notFoundPageInstaller: Extension<PageTransformer, *, *> by extending { dokkaBase.htmlPreprocessors providing ::NotFoundPageInstaller order { after(dokkaBase.assetsInstaller) before(dokkaBase.customResourceInstaller) } applyIf { !delayTemplateSubstitution } } - val versionsDefaultOrdering by extending { + + public val versionsDefaultOrdering: Extension<VersionsOrdering, *, *> by extending { versionsOrdering providing { ctx -> configuration<VersioningPlugin, VersioningConfiguration>(ctx)?.versionsOrdering?.let { ByConfigurationVersionOrdering(ctx) } ?: SemVerVersionOrdering() } } - val previousDocumentationCopyPostAction by extending { + + public val previousDocumentationCopyPostAction: Extension<PostAction, *, *> by extending { postActions providing ::DefaultPreviousDocumentationCopyPostAction applyIf { !delayTemplateSubstitution } } diff --git a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersioningStorage.kt b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersioningStorage.kt index d748ba9b..7c9d1da0 100644 --- a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersioningStorage.kt +++ b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersioningStorage.kt @@ -11,18 +11,21 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.configuration import java.io.File -data class VersionDirs(val src: File, val dst: File) -data class CurrentVersion(val name: String, val dir: File) +public data class VersionDirs(val src: File, val dst: File) +public data class CurrentVersion(val name: String, val dir: File) -interface VersioningStorage { - val previousVersions: Map<VersionId, VersionDirs> - val currentVersion: CurrentVersion - fun createVersionFile() +public interface VersioningStorage { + public val previousVersions: Map<VersionId, VersionDirs> + public val currentVersion: CurrentVersion + + public fun createVersionFile() } -typealias VersionId = String +public typealias VersionId = String -class DefaultVersioningStorage(val context: DokkaContext) : VersioningStorage { +public class DefaultVersioningStorage( + public val context: DokkaContext +) : VersioningStorage { private val mapper = ObjectMapper() private val configuration = configuration<VersioningPlugin, VersioningConfiguration>(context) diff --git a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersionsNavigationCreator.kt b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersionsNavigationCreator.kt index 95b58380..59ce93e2 100644 --- a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersionsNavigationCreator.kt +++ b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersionsNavigationCreator.kt @@ -14,11 +14,13 @@ import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.utilities.urlEncoded import java.io.File -fun interface VersionsNavigationCreator { - operator fun invoke(output: File): String +public fun interface VersionsNavigationCreator { + public operator fun invoke(output: File): String } -class HtmlVersionsNavigationCreator(private val context: DokkaContext) : VersionsNavigationCreator { +public class HtmlVersionsNavigationCreator( + private val context: DokkaContext +) : VersionsNavigationCreator { private val versioningStorage by lazy { context.plugin<VersioningPlugin>().querySingle { versioningStorage } } diff --git a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersionsOrdering.kt b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersionsOrdering.kt index a2cea789..3d1fbe3d 100644 --- a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersionsOrdering.kt +++ b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/VersionsOrdering.kt @@ -8,17 +8,19 @@ import org.apache.maven.artifact.versioning.ComparableVersion import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.configuration -fun interface VersionsOrdering { - fun order(records: List<VersionId>): List<VersionId> +public fun interface VersionsOrdering { + public fun order(records: List<VersionId>): List<VersionId> } -class ByConfigurationVersionOrdering(val dokkaContext: DokkaContext) : VersionsOrdering { +public class ByConfigurationVersionOrdering( + public val dokkaContext: DokkaContext +) : VersionsOrdering { override fun order(records: List<VersionId>): List<VersionId> = configuration<VersioningPlugin, VersioningConfiguration>(dokkaContext)?.versionsOrdering ?: throw IllegalStateException("Attempted to use a configuration ordering without providing configuration") } -class SemVerVersionOrdering : VersionsOrdering { +public class SemVerVersionOrdering : VersionsOrdering { override fun order(records: List<VersionId>): List<VersionId> = records.map { it to ComparableVersion(it) }.sortedByDescending { it.second }.map { it.first } } diff --git a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/htmlPreprocessors.kt b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/htmlPreprocessors.kt index c245d8bb..9bdaf7d5 100644 --- a/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/htmlPreprocessors.kt +++ b/plugins/versioning/src/main/kotlin/org/jetbrains/dokka/versioning/htmlPreprocessors.kt @@ -10,7 +10,9 @@ import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.pages.PageTransformer -class MultiModuleStylesInstaller(private val dokkaContext: DokkaContext) : PageTransformer { +public class MultiModuleStylesInstaller( + private val dokkaContext: DokkaContext +) : PageTransformer { private val stylesPages = listOf( "styles/multimodule.css", ) @@ -26,7 +28,9 @@ class MultiModuleStylesInstaller(private val dokkaContext: DokkaContext) : PageT } } -class NotFoundPageInstaller(private val dokkaContext: DokkaContext) : PageTransformer { +public class NotFoundPageInstaller( + private val dokkaContext: DokkaContext +) : PageTransformer { private val notFoundPage = listOf( "not-found-version.html", ) |