From 02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Thu, 31 Aug 2023 20:16:01 +0200 Subject: Enable explicit API mode (#3139) --- plugins/base/src/main/kotlin/DokkaBase.kt | 150 ++++++------ .../base/src/main/kotlin/DokkaBaseConfiguration.kt | 16 +- .../deprecated/AnalysisApiDeprecatedError.kt | 2 +- .../deprecated/KotlinAnalysisDeprecatedApi.kt | 28 +-- .../main/kotlin/deprecated/ParsersDeprecatedAPI.kt | 14 +- .../deprecated/ParsersFactoriesDeprecatedAPI.kt | 4 +- .../TranslatorDescriptorsDeprecatedAPI.kt | 12 +- .../deprecated/TranslatorPsiDeprecatedAPI.kt | 2 +- .../kotlin/generation/SingleModuleGeneration.kt | 28 ++- .../src/main/kotlin/renderers/DefaultRenderer.kt | 79 ++++--- .../base/src/main/kotlin/renderers/FileWriter.kt | 7 +- .../base/src/main/kotlin/renderers/OutputWriter.kt | 6 +- .../main/kotlin/renderers/PackageListService.kt | 23 +- .../main/kotlin/renderers/TabSortingStrategy.kt | 4 +- .../main/kotlin/renderers/contentTypeChecking.kt | 11 +- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 103 ++++---- .../renderers/html/NavigationDataProvider.kt | 6 +- .../main/kotlin/renderers/html/NavigationPage.kt | 24 +- .../renderers/html/SearchbarDataInstaller.kt | 25 +- .../base/src/main/kotlin/renderers/html/Tags.kt | 34 +-- .../consumers/ImmediateResolutionTagConsumer.kt | 10 +- .../html/command/consumers/PathToRootConsumer.kt | 4 +- .../command/consumers/ReplaceVersionsConsumer.kt | 4 +- .../html/command/consumers/ResolveLinkConsumer.kt | 4 +- .../kotlin/renderers/html/htmlFormatingUtils.kt | 7 +- .../kotlin/renderers/html/htmlPreprocessors.kt | 20 +- .../innerTemplating/DefaultTemplateModelFactory.kt | 6 +- .../innerTemplating/DefaultTemplateModelMerger.kt | 2 +- .../html/innerTemplating/HtmlTemplater.kt | 12 +- .../html/innerTemplating/TemplateModelFactory.kt | 6 +- .../html/innerTemplating/TemplateModelMerger.kt | 4 +- .../src/main/kotlin/renderers/preprocessors.kt | 16 +- .../main/kotlin/resolvers/anchors/AnchorsHint.kt | 6 +- .../external/DefaultExternalLocationProvider.kt | 10 +- .../DefaultExternalLocationProviderFactory.kt | 31 ++- .../external/Dokka010ExternalLocationProvider.kt | 10 +- .../resolvers/external/ExternalLocationProvider.kt | 4 +- .../external/ExternalLocationProviderFactory.kt | 4 +- .../ExternalLocationProviderFactoryWithCache.kt | 5 +- .../javadoc/AndroidExternalLocationProvider.kt | 4 +- .../javadoc/JavadocExternalLocationProvider.kt | 17 +- .../JavadocExternalLocationProviderFactory.kt | 44 ++-- .../resolvers/local/DefaultLocationProvider.kt | 5 +- .../resolvers/local/DokkaBaseLocationProvider.kt | 4 +- .../resolvers/local/DokkaLocationProvider.kt | 14 +- .../local/DokkaLocationProviderFactory.kt | 10 +- .../kotlin/resolvers/local/LocationProvider.kt | 29 ++- .../resolvers/local/LocationProviderFactory.kt | 4 +- .../resolvers/shared/ExternalDocumentation.kt | 2 +- .../src/main/kotlin/resolvers/shared/LinkFormat.kt | 6 +- .../main/kotlin/resolvers/shared/PackageList.kt | 20 +- .../resolvers/shared/RecognizedLinkFormat.kt | 14 +- .../main/kotlin/signatures/JvmSignatureUtils.kt | 53 +++-- .../kotlin/signatures/KotlinSignatureProvider.kt | 9 +- .../main/kotlin/signatures/KotlinSignatureUtils.kt | 20 +- .../main/kotlin/signatures/SignatureProvider.kt | 4 +- .../kotlin/templating/AddToNavigationCommand.kt | 4 +- .../base/src/main/kotlin/templating/AddToSearch.kt | 5 +- .../templating/AddToSourcesetDependencies.kt | 5 +- plugins/base/src/main/kotlin/templating/Command.kt | 6 +- .../templating/ImmediateHtmlCommandConsumer.kt | 8 +- .../main/kotlin/templating/InsertTemplateExtra.kt | 4 +- .../templating/PathToRootSubstitutionCommand.kt | 5 +- .../templating/ProjectNameSubstitutionCommand.kt | 5 +- .../kotlin/templating/ReplaceVersionsCommand.kt | 2 +- .../main/kotlin/templating/ResolveLinkCommand.kt | 4 +- .../main/kotlin/templating/jsonMapperForPlugins.kt | 4 +- .../documentables/ActualTypealiasAdder.kt | 10 +- .../documentables/DefaultDocumentableMerger.kt | 4 +- .../DeprecatedDocumentableFilterTransformer.kt | 5 +- .../DocumentableReplacerTransformer.kt | 23 +- .../DocumentableVisibilityFilterTransformer.kt | 14 +- .../documentables/EmptyModulesFilterTransformer.kt | 2 +- .../EmptyPackagesFilterTransformer.kt | 4 +- .../documentables/ExtensionExtractorTransformer.kt | 11 +- ...nheritedEntriesDocumentableFilterTransformer.kt | 5 +- .../InheritorsExtractorTransformer.kt | 8 +- .../KotlinArrayDocumentableReplacerTransformer.kt | 5 +- ...bviousFunctionsDocumentableFilterTransformer.kt | 4 +- .../documentables/SuppressTagDocumentableFilter.kt | 5 +- ...ssedByConditionDocumentableFilterTransformer.kt | 7 +- ...ByConfigurationDocumentableFilterTransformer.kt | 4 +- .../kotlin/transformers/documentables/utils.kt | 11 +- .../pages/annotations/SinceKotlinTransformer.kt | 8 +- .../pages/comments/CommentsToContentConverter.kt | 4 +- .../pages/comments/DocTagToContentConverter.kt | 2 +- .../pages/merger/FallbackPageMergerStrategy.kt | 4 +- .../kotlin/transformers/pages/merger/PageMerger.kt | 2 +- .../pages/merger/PageMergerStrategy.kt | 4 +- .../merger/SameMethodNamePageMergerStrategy.kt | 4 +- .../merger/SourceSetMergingPageTransformer.kt | 2 +- .../pages/sourcelinks/SourceLinksTransformer.kt | 16 +- .../pages/tags/CustomTagContentProvider.kt | 8 +- .../pages/tags/SinceKotlinTagContentProvider.kt | 4 +- .../DefaultDocumentableToPageTranslator.kt | 2 +- .../documentables/DefaultPageCreator.kt | 253 ++++++++++---------- .../translators/documentables/DriClashAwareName.kt | 4 +- .../documentables/PageContentBuilder.kt | 261 ++++++++++++--------- .../documentables/briefFromContentNodes.kt | 4 +- .../translators/psi/parsers/InheritDocResolver.kt | 4 - .../translators/psi/parsers/JavadocParser.kt | 4 - .../kotlin/translators/psi/parsers/JavadocTag.kt | 4 - 102 files changed, 994 insertions(+), 776 deletions(-) delete mode 100644 plugins/base/src/main/kotlin/translators/psi/parsers/InheritDocResolver.kt delete mode 100644 plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt delete mode 100644 plugins/base/src/main/kotlin/translators/psi/parsers/JavadocTag.kt (limited to 'plugins/base/src') 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() - val pageMergerStrategy by extensionPoint() - val commentsToContentConverter by extensionPoint() - val customTagContentProvider by extensionPoint() - val signatureProvider by extensionPoint() - val locationProviderFactory by extensionPoint() - val externalLocationProviderFactory by extensionPoint() - val outputWriter by extensionPoint() - val htmlPreprocessors by extensionPoint() +public class DokkaBase : DokkaPlugin() { + + public val preMergeDocumentableTransformer: ExtensionPoint by extensionPoint() + public val pageMergerStrategy: ExtensionPoint by extensionPoint() + public val commentsToContentConverter: ExtensionPoint by extensionPoint() + public val customTagContentProvider: ExtensionPoint by extensionPoint() + public val signatureProvider: ExtensionPoint by extensionPoint() + public val locationProviderFactory: ExtensionPoint by extensionPoint() + public val externalLocationProviderFactory: ExtensionPoint by extensionPoint() + public val outputWriter: ExtensionPoint by extensionPoint() + public val htmlPreprocessors: ExtensionPoint by extensionPoint() @Deprecated("It is not used anymore") - val tabSortingStrategy by extensionPoint() - val immediateHtmlCommandConsumer by extensionPoint() + public val tabSortingStrategy: ExtensionPoint by extensionPoint() + public val immediateHtmlCommandConsumer: ExtensionPoint by extensionPoint() - val singleGeneration by extending { + public val singleGeneration: Extension by extending { CoreExtensions.generation providing ::SingleModuleGeneration } - val documentableMerger by extending { + public val documentableMerger: Extension by extending { CoreExtensions.documentableMerger providing ::DefaultDocumentableMerger } - val deprecatedDocumentableFilter by extending { + public val deprecatedDocumentableFilter: Extension by extending { preMergeDocumentableTransformer providing ::DeprecatedDocumentableFilterTransformer } - val suppressedDocumentableFilter by extending { + public val suppressedDocumentableFilter: Extension by extending { preMergeDocumentableTransformer providing ::SuppressedByConfigurationDocumentableFilterTransformer } - val suppressedBySuppressTagDocumentableFilter by extending { + public val suppressedBySuppressTagDocumentableFilter: Extension by extending { preMergeDocumentableTransformer providing ::SuppressTagDocumentableFilter } - val documentableVisibilityFilter by extending { + public val documentableVisibilityFilter: Extension by extending { preMergeDocumentableTransformer providing ::DocumentableVisibilityFilterTransformer } - val obviousFunctionsVisbilityFilter by extending { + public val obviousFunctionsVisbilityFilter: Extension by extending { preMergeDocumentableTransformer providing ::ObviousFunctionsDocumentableFilterTransformer } - val inheritedEntriesVisbilityFilter by extending { + public val inheritedEntriesVisbilityFilter: Extension by extending { preMergeDocumentableTransformer providing ::InheritedEntriesDocumentableFilterTransformer } - val kotlinArrayDocumentableReplacer by extending { + public val kotlinArrayDocumentableReplacer: Extension by extending { preMergeDocumentableTransformer providing ::KotlinArrayDocumentableReplacerTransformer } - val emptyPackagesFilter by extending { + public val emptyPackagesFilter: Extension by extending { preMergeDocumentableTransformer providing ::EmptyPackagesFilterTransformer order { after( deprecatedDocumentableFilter, @@ -103,124 +106,127 @@ class DokkaBase : DokkaPlugin() { } } - val emptyModulesFilter by extending { + public val emptyModulesFilter: Extension by extending { preMergeDocumentableTransformer with EmptyModulesFilterTransformer() order { after(emptyPackagesFilter) } } - val modulesAndPackagesDocumentation by extending { + public val modulesAndPackagesDocumentation: Extension by extending { preMergeDocumentableTransformer providing ::ModuleAndPackageDocumentationTransformer } - val actualTypealiasAdder by extending { + public val actualTypealiasAdder: Extension by extending { CoreExtensions.documentableTransformer with ActualTypealiasAdder() } - val kotlinSignatureProvider by extending { + public val kotlinSignatureProvider: Extension by extending { signatureProvider providing ::KotlinSignatureProvider } - val sinceKotlinTransformer by extending { - CoreExtensions.documentableTransformer providing ::SinceKotlinTransformer applyIf { SinceKotlinTransformer.shouldDisplaySinceKotlin() } order { + public val sinceKotlinTransformer: Extension by extending { + CoreExtensions.documentableTransformer providing ::SinceKotlinTransformer applyIf { + SinceKotlinTransformer.shouldDisplaySinceKotlin() + } order { before(extensionsExtractor) } } - val inheritorsExtractor by extending { + public val inheritorsExtractor: Extension by extending { CoreExtensions.documentableTransformer with InheritorsExtractorTransformer() } - val undocumentedCodeReporter by extending { + public val undocumentedCodeReporter: Extension by extending { CoreExtensions.documentableTransformer with ReportUndocumentedTransformer() } - val extensionsExtractor by extending { + public val extensionsExtractor: Extension by extending { CoreExtensions.documentableTransformer with ExtensionExtractorTransformer() } - val documentableToPageTranslator by extending { + public val documentableToPageTranslator: Extension by extending { CoreExtensions.documentableToPageTranslator providing ::DefaultDocumentableToPageTranslator } - val docTagToContentConverter by extending { + public val docTagToContentConverter: Extension by extending { commentsToContentConverter with DocTagToContentConverter() } - val sinceKotlinTagContentProvider by extending { - customTagContentProvider with SinceKotlinTagContentProvider applyIf { SinceKotlinTransformer.shouldDisplaySinceKotlin() } + public val sinceKotlinTagContentProvider: Extension by extending { + customTagContentProvider with SinceKotlinTagContentProvider applyIf { + SinceKotlinTransformer.shouldDisplaySinceKotlin() + } } - val pageMerger by extending { - CoreExtensions.pageTransformer providing ::PageMerger order { - } + public val pageMerger: Extension by extending { + CoreExtensions.pageTransformer providing ::PageMerger } - val sourceSetMerger by extending { + public val sourceSetMerger: Extension by extending { CoreExtensions.pageTransformer providing ::SourceSetMergingPageTransformer } - val fallbackMerger by extending { + public val fallbackMerger: Extension by extending { pageMergerStrategy providing { ctx -> FallbackPageMergerStrategy(ctx.logger) } } - val sameMethodNameMerger by extending { + public val sameMethodNameMerger: Extension by extending { pageMergerStrategy providing { ctx -> SameMethodNamePageMergerStrategy(ctx.logger) } order { before(fallbackMerger) } } - val htmlRenderer by extending { + public val htmlRenderer: Extension by extending { CoreExtensions.renderer providing ::HtmlRenderer } - val locationProvider by extending { + public val locationProvider: Extension by extending { locationProviderFactory providing ::DokkaLocationProviderFactory } - val javadocLocationProvider by extending { + public val javadocLocationProvider: Extension by extending { externalLocationProviderFactory providing ::JavadocExternalLocationProviderFactory } - val dokkaLocationProvider by extending { + public val dokkaLocationProvider: Extension by extending { externalLocationProviderFactory providing ::DefaultExternalLocationProviderFactory } - val fileWriter by extending { + public val fileWriter: Extension by extending { outputWriter providing ::FileWriter } - val rootCreator by extending { + public val rootCreator: Extension by extending { htmlPreprocessors with RootCreator applyIf { !delayTemplateSubstitution } } - val defaultSamplesTransformer by extending { + public val defaultSamplesTransformer: Extension by extending { CoreExtensions.pageTransformer providing ::DefaultSamplesTransformer order { before(pageMerger) } } - val sourceLinksTransformer by extending { + public val sourceLinksTransformer: Extension by extending { htmlPreprocessors providing ::SourceLinksTransformer order { after(rootCreator) } } - val navigationPageInstaller by extending { + public val navigationPageInstaller: Extension by extending { htmlPreprocessors providing ::NavigationPageInstaller order { after(rootCreator) } } - val scriptsInstaller by extending { + public val scriptsInstaller: Extension by extending { htmlPreprocessors providing ::ScriptsInstaller order { after(rootCreator) } } - val stylesInstaller by extending { + public val stylesInstaller: Extension by extending { htmlPreprocessors providing ::StylesInstaller order { after(rootCreator) } } - val assetsInstaller by extending { + public val assetsInstaller: Extension by extending { htmlPreprocessors with AssetsInstaller order { after(rootCreator) } applyIf { !delayTemplateSubstitution } } - val customResourceInstaller by extending { + public val customResourceInstaller: Extension 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 by extending { htmlPreprocessors providing { PackageListCreator(it, RecognizedLinkFormat.DokkaHtml) } order { after(rootCreator) } } - val sourcesetDependencyAppender by extending { + public val sourcesetDependencyAppender: Extension by extending { htmlPreprocessors providing ::SourcesetDependencyAppender order { after(rootCreator) } } - val resolveLinkConsumer by extending { + public val resolveLinkConsumer: Extension by extending { immediateHtmlCommandConsumer with ResolveLinkConsumer } - val replaceVersionConsumer by extending { + public val replaceVersionConsumer: Extension by extending { immediateHtmlCommandConsumer providing ::ReplaceVersionsConsumer } - val pathToRootConsumer by extending { + public val pathToRootConsumer: Extension by extending { immediateHtmlCommandConsumer with PathToRootConsumer } - val baseSearchbarDataInstaller by extending { + public val baseSearchbarDataInstaller: Extension by extending { htmlPreprocessors providing ::SearchbarDataInstaller order { after(sourceLinksTransformer) } } // @Suppress("DEPRECATION_ERROR") @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - val kotlinAnalysis by extensionPoint() + public val kotlinAnalysis: ExtensionPoint by extensionPoint() @Suppress("DEPRECATION_ERROR") @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - val externalDocumentablesProvider by extensionPoint() + public val externalDocumentablesProvider: ExtensionPoint by extensionPoint() @Suppress("DEPRECATION_ERROR") @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) - val externalClasslikesTranslator by extensionPoint() + public val externalClasslikesTranslator: ExtensionPoint 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 + public val descriptorToDocumentableTranslator: org.jetbrains.dokka.plugability.Extension 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 + public val psiToDocumentableTranslator: org.jetbrains.dokka.plugability.Extension 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 + public val defaultKotlinAnalysis: org.jetbrains.dokka.plugability.Extension 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 + public val defaultExternalDocumentablesProvider: org.jetbrains.dokka.plugability.Extension 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 + public val defaultExternalClasslikesTranslator: org.jetbrains.dokka.plugability.Extension get() = throw org.jetbrains.dokka.base.deprecated.AnalysisApiDeprecatedError() // 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 = defaultCustomStyleSheets, var customAssets: List = 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 = emptyList() - val defaultCustomAssets: List = 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 = emptyList() + public val defaultCustomAssets: List = 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, logger: DokkaLogger, analysisConfiguration: DokkaAnalysisConfiguration = DokkaAnalysisConfiguration() ): KotlinAnalysis = throw AnalysisApiDeprecatedError() @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -fun ProjectKotlinAnalysis( +public fun ProjectKotlinAnalysis( sourceSets: List, logger: DokkaLogger, analysisConfiguration: DokkaAnalysisConfiguration = DokkaAnalysisConfiguration() ): KotlinAnalysis = throw AnalysisApiDeprecatedError() @Deprecated(message = ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR) -fun SamplesKotlinAnalysis( +public fun SamplesKotlinAnalysis( sourceSets: List, 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 = emptyList(), @Suppress("UNUSED_PARAMETER") params: Map = 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 = runBlocking(Dispatchers.Default) { + public fun createDocumentationModels(): List = 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) = - context.plugin().query { preMergeDocumentableTransformer } + public fun transformDocumentationModelBeforeMerge(modulesFromPlatforms: List): List { + return context.plugin() + .query { preMergeDocumentableTransformer } .fold(modulesFromPlatforms) { acc, t -> t(acc) } + } - fun mergeDocumentationModels(modulesFromPlatforms: List) = + public fun mergeDocumentationModels(modulesFromPlatforms: List): 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()) ) { 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( +public abstract class DefaultRenderer( protected val context: DokkaContext ) : Renderer { - protected val outputWriter = context.plugin().querySingle { outputWriter } + protected val outputWriter: OutputWriter = context.plugin().querySingle { outputWriter } protected lateinit var locationProvider: LocationProvider private set protected open val preprocessors: Iterable = 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? = 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? = 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? - ) = buildContentNode(content.inner, pageContext) + ) { + buildContentNode(content.inner, pageContext) + } - open fun T.buildGroup( + public open fun T.buildGroup( node: ContentGroup, pageContext: ContentPage, sourceSetRestriction: Set? = 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, pageContext: ContentPage, sourceSetRestriction: Set? = null @@ -81,15 +88,15 @@ abstract class DefaultRenderer( 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? = null @@ -97,19 +104,23 @@ abstract class DefaultRenderer( 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? = 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? = null @@ -135,7 +146,7 @@ abstract class DefaultRenderer( } } - open fun T.buildDRILink( + public open fun T.buildDRILink( node: ContentDRILink, pageContext: ContentPage, sourceSetRestriction: Set? @@ -147,7 +158,7 @@ abstract class DefaultRenderer( } ?: buildText(node.children, pageContext, sourceSetRestriction) } - open fun T.buildResolvedLink( + public open fun T.buildResolvedLink( node: ContentResolvedLink, pageContext: ContentPage, sourceSetRestriction: Set? @@ -157,18 +168,18 @@ abstract class DefaultRenderer( } } - 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( internal typealias SerializedBeforeAndAfter = Pair internal typealias InstanceWithSource = Pair -fun ContentPage.sourceSets() = this.content.sourceSets +public fun ContentPage.sourceSets(): Set = 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 = 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() val nonStandardLocations = mutableMapOf() @@ -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, modules: Map>, format: String, linkExtension: String): String = buildString { + public companion object { + public fun renderPackageList( + nonStandardLocations: Map, + modules: Map>, + 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 sort(tabs: Collection) : List +public interface TabSortingStrategy { + public fun sort(tabs: Collection) : List } 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 = 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(context) { private val sourceSetDependencyMap: Map> = @@ -50,7 +51,7 @@ open class HtmlRenderer( private var shouldRenderSourceSetTabs: Boolean = false - override val preprocessors = context.plugin().query { htmlPreprocessors } + override val preprocessors: List = context.plugin().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? - ) = + ) { 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>, @@ -409,19 +411,21 @@ open class HtmlRenderer( node: ContentList, pageContext: ContentPage, sourceSetRestriction: Set? - ) = 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, pageContext: ContentPage, sourceSetRestriction: Set? = null @@ -434,7 +438,7 @@ open class HtmlRenderer( } } - open fun UL.buildListItems( + public open fun UL.buildListItems( items: List, pageContext: ContentPage, sourceSetRestriction: Set? = 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? @@ -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, 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? - ) = 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