diff options
Diffstat (limited to 'plugins/base/src')
102 files changed, 994 insertions, 776 deletions
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. - */ - |