diff options
10 files changed, 58 insertions, 60 deletions
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt b/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt index e02bdd61..715dde2f 100644 --- a/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt +++ b/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt @@ -30,12 +30,12 @@ open class CrossPlatformExec : AbstractExecTask<CrossPlatformExec>(CrossPlatform } private fun findCommand(command: String): String { - val command = normalizeCommandPaths(command) + val normalizedCommand = normalizeCommandPaths(command) val extensions = if (isWindows) windowsExtensions else unixExtensions return extensions.map { extension -> - resolveCommandFromFile(Paths.get("$command$extension")) - }.firstOrNull { it.isNotBlank() } ?: command + resolveCommandFromFile(Paths.get("$normalizedCommand$extension")) + }.firstOrNull { it.isNotBlank() } ?: normalizedCommand } private fun resolveCommandFromFile(commandFile: Path) = @@ -60,4 +60,4 @@ open class CrossPlatformExec : AbstractExecTask<CrossPlatformExec>(CrossPlatform // then replace all forward slashes with whatever the separator actually is .replace(forwardSlashSeparator, separator) } -}
\ No newline at end of file +} diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index 6d6d8698..67dee9ae 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -9,18 +9,18 @@ import java.util.function.BiConsumer fun parsePerPackageOptions(args: List<String>): List<PackageOptions> = args.map { it.split(",") }.map { val matchingRegex = it.first() - val args = it.subList(1, it.size) + val options = it.subList(1, it.size) - val deprecated = args.find { it.endsWith("skipDeprecated") }?.startsWith("+") + val deprecated = options.find { it.endsWith("skipDeprecated") }?.startsWith("+") ?: DokkaDefaults.skipDeprecated - val reportUndocumented = args.find { it.endsWith("reportUndocumented") }?.startsWith("+") + val reportUndocumented = options.find { it.endsWith("reportUndocumented") }?.startsWith("+") ?: DokkaDefaults.reportUndocumented - val privateApi = args.find { it.endsWith("includeNonPublic") }?.startsWith("+") + val privateApi = options.find { it.endsWith("includeNonPublic") }?.startsWith("+") ?: DokkaDefaults.includeNonPublic - val suppress = args.find { it.endsWith("suppress") }?.startsWith("+") + val suppress = options.find { it.endsWith("suppress") }?.startsWith("+") ?: DokkaDefaults.suppress PackageOptionsImpl( diff --git a/core/src/main/kotlin/pages/PageNodes.kt b/core/src/main/kotlin/pages/PageNodes.kt index 83468671..9fc4d6e8 100644 --- a/core/src/main/kotlin/pages/PageNodes.kt +++ b/core/src/main/kotlin/pages/PageNodes.kt @@ -142,7 +142,7 @@ class MemberPageNode( override val embeddedResources: List<String> = listOf() ) : MemberPage { override fun modified(name: String, children: List<PageNode>): MemberPageNode = - modified(name = name, content = this.content, children = children) as MemberPageNode + modified(name = name, content = this.content, children = children) override fun modified( name: String, diff --git a/core/src/main/kotlin/plugability/DokkaJavaPlugin.kt b/core/src/main/kotlin/plugability/DokkaJavaPlugin.kt index 1d8ea8aa..4c621703 100644 --- a/core/src/main/kotlin/plugability/DokkaJavaPlugin.kt +++ b/core/src/main/kotlin/plugability/DokkaJavaPlugin.kt @@ -28,8 +28,8 @@ data class ExtensionBuilder<T: Any> internal constructor( private val name: String, private val ext: ExtensionPoint<T>, private val action: LazyEvaluated<T>, - private val before: List<out Extension<*, *, *>>, - private val after: List<out Extension<*, *, *>>, + private val before: List<Extension<*, *, *>>, + private val after: List<Extension<*, *, *>>, private val override: OverrideKind = OverrideKind.None, private val conditions: List<(DokkaConfiguration) -> Boolean> ){ @@ -62,11 +62,11 @@ data class ExtensionBuilder<T: Any> internal constructor( abstract class DokkaJavaPlugin: DokkaPlugin() { - fun <T: DokkaPlugin> plugin(clazz: Class<T>): T? = + fun <T: DokkaPlugin> plugin(clazz: Class<T>): T = context?.plugin(clazz.kotlin) ?: throwIllegalQuery() fun <T: Any> extend(func: (ExtensionBuilderStart) -> ExtensionBuilder<T>): Lazy<Extension<T, *, *>> = lazy { func(ExtensionBuilderStart()).build() }.also { unsafeInstall(it) } -}
\ No newline at end of file +} diff --git a/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt b/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt index 7604521b..792754fb 100644 --- a/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt +++ b/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt @@ -86,7 +86,7 @@ class BaseTestBuilder : TestBuilder<BaseTestMethods>() { var documentablesTransformationStage: (DModule) -> Unit = {} var pagesGenerationStage: (RootPageNode) -> Unit = {} var pagesTransformationStage: (RootPageNode) -> Unit = {} - var renderingStage: (RootPageNode, DokkaContext) -> Unit = { a, b -> } + var renderingStage: (RootPageNode, DokkaContext) -> Unit = { _, _ -> } override fun build() = BaseTestMethods( pluginsSetupStage, @@ -105,4 +105,4 @@ abstract class BaseAbstractTest(logger: TestLogger = TestLogger(DokkaConsoleLogg ::BaseTestBuilder, ::BaseDokkaTestGenerator, logger, -)
\ No newline at end of file +) diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 2a0af90c..f0d86b97 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -52,7 +52,7 @@ open class HtmlRenderer( val sorted = strategy.sort(tabs) if (sorted.size != tabs.size) context.logger.warn("Tab sorting strategy has changed number of tabs from ${tabs.size} to ${sorted.size}") - return sorted; + return sorted } override fun FlowContent.wrapGroup( @@ -68,7 +68,7 @@ open class HtmlRenderer( val firstLevel = node.children.filterIsInstance<ContentHeader>().flatMap { it.children } .filterIsInstance<ContentText>() - val renderable = firstLevel.union(secondLevel).let { sortTabs(tabSortingStrategy, it) } + val renderable = sortTabs(tabSortingStrategy, firstLevel.union(secondLevel)) div(classes = "tabs-section") { attributes["tabs-section"] = "tabs-section" @@ -84,7 +84,7 @@ open class HtmlRenderer( childrenCallback() } } - node.hasStyle(ContentStyle.WithExtraAttributes) -> div() { + node.hasStyle(ContentStyle.WithExtraAttributes) -> div { node.extra.extraHtmlAttributes().forEach { attributes[it.extraKey] = it.extraValue } childrenCallback() } @@ -93,13 +93,13 @@ open class HtmlRenderer( if (node.hasStyle(TextStyle.Monospace)) copyButton() } node.hasStyle(TextStyle.BreakableAfter) -> { - span() { childrenCallback() } + span { childrenCallback() } wbr { } } node.hasStyle(TextStyle.Breakable) -> { span("breakable-word") { childrenCallback() } } - node.hasStyle(TextStyle.Span) -> span() { childrenCallback() } + node.hasStyle(TextStyle.Span) -> span { childrenCallback() } node.dci.kind == ContentKind.Symbol -> div("symbol $additionalClasses") { childrenCallback() } node.dci.kind == ContentKind.BriefComment -> div("brief $additionalClasses") { childrenCallback() } node.dci.kind == ContentKind.Cover -> div("cover $additionalClasses") { //TODO this can be removed @@ -152,11 +152,6 @@ open class HtmlRenderer( } } - fun FlowContent.withHtml(content: String): Unit = when (this) { - is HTMLTag -> unsafe { +content } - else -> div { unsafe { +content } } - } - override fun FlowContent.buildPlatformDependent( content: PlatformHintedContent, pageContext: ContentPage, @@ -245,22 +240,24 @@ open class HtmlRenderer( override fun FlowContent.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) { val distinct = - node.groupDivergentInstances(pageContext, { instance, contentPage, sourceSet -> - createHTML(prettyPrint = false).prepareForTemplates().div { - instance.before?.let { before -> - buildContentNode(before, pageContext, sourceSet) - } - }.stripDiv() - }, { instance, contentPage, sourceSet -> - createHTML(prettyPrint = false).prepareForTemplates().div { - instance.after?.let { after -> - buildContentNode(after, pageContext, sourceSet) - } - }.stripDiv() - }) + node.groupDivergentInstances(pageContext, + beforeTransformer = { instance, _, sourceSet -> + createHTML(prettyPrint = false).prepareForTemplates().div { + instance.before?.let { before -> + buildContentNode(before, pageContext, sourceSet) + } + }.stripDiv() + }, + afterTransformer = { instance, _, sourceSet -> + createHTML(prettyPrint = false).prepareForTemplates().div { + instance.after?.let { after -> + buildContentNode(after, pageContext, sourceSet) + } + }.stripDiv() + }) - distinct.forEach { - val groupedDivergent = it.value.groupBy { it.second } + distinct.forEach { distinctInstances -> + val groupedDivergent = distinctInstances.value.groupBy { it.second } consumer.onTagContentUnsafe { +createHTML().prepareForTemplates().div("divergent-group") { @@ -279,7 +276,7 @@ open class HtmlRenderer( consumer.onTagContentUnsafe { +createHTML().prepareForTemplates().div("with-platform-tags") { - consumer.onTagContentUnsafe { +it.key.first } + consumer.onTagContentUnsafe { +distinctInstances.key.first } consumer.onTagContentUnsafe { +createHTML().prepareForTemplates().span("pull-right") { @@ -296,12 +293,12 @@ open class HtmlRenderer( if (node.implicitlySourceSetHinted) { buildPlatformDependent(divergentForPlatformDependent, pageContext) } else { - it.value.forEach { + distinctInstances.value.forEach { buildContentNode(it.first.divergent, pageContext, setOf(it.second)) } } } - consumer.onTagContentUnsafe { +it.key.second } + consumer.onTagContentUnsafe { +distinctInstances.key.second } } } } @@ -492,7 +489,7 @@ open class HtmlRenderer( private fun FlowContent.createPlatformTagBubbles(sourceSets: List<DisplaySourceSet>, cssClasses: String = "") { if (shouldRenderSourceSetBubbles) { - div("platform-tags " + cssClasses) { + div("platform-tags $cssClasses") { sourceSets.sortedBy { it.name }.forEach { div("platform-tag") { when (it.platform.key) { diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt b/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt index 1fb7b960..a9b99840 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt @@ -8,8 +8,8 @@ import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer class ActualTypealiasAdder : DocumentableTransformer { - override fun invoke(modules: DModule, context: DokkaContext) = modules.generateTypealiasesMap().let { aliases -> - modules.copy(packages = modules.packages.map { it.copy(classlikes = addActualTypeAliasToClasslikes(it.classlikes, aliases)) }) + override fun invoke(original: DModule, context: DokkaContext) = 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/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 07e52851..c611927c 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -71,7 +71,8 @@ open class DefaultPageCreator( private fun <T> T.toClashedName() where T : Documentable, T : WithExtraProperties<T> = (extra[ClashingDriIdentifier]?.value?.joinToString(", ", "[", "]") { it.displayName } ?: "") + name.orEmpty() - private fun <T> List<T>.renameClashingDocumentable(): List<T> where T : Documentable = + @Suppress("UNCHECKED_CAST") + private fun <T : Documentable> List<T>.renameClashingDocumentable(): List<T> = groupBy { it.dri }.values.flatMap { elements -> if (elements.size == 1) elements else elements.mapNotNull { element -> when (element) { diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index 14d57df0..84510824 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -172,15 +172,15 @@ class DefaultPsiToDocumentableTranslator( methods.asIterable().parallelForEach { superMethodsKeys.add(it.hash) } fun parseSupertypes(superTypes: Array<PsiClassType>, level: Int = 0) { // TODO: Rewrite it if (superTypes.isEmpty()) return - val parsedClasses = superTypes.filter { !it.shouldBeIgnored }.mapNotNull { psi -> - psi.resolve()?.let { psiClass -> - val (dri, javaClassKind) = when { - psiClass.isInterface -> DRI.from(psiClass) to JavaClassKindTypes.INTERFACE - else -> DRI.from(psiClass) to JavaClassKindTypes.CLASS + val parsedClasses = superTypes.filter { !it.shouldBeIgnored }.mapNotNull { supertypePsi -> + supertypePsi.resolve()?.let { supertypePsiClass -> + val (supertypeDri, javaClassKind) = when { + supertypePsiClass.isInterface -> DRI.from(supertypePsiClass) to JavaClassKindTypes.INTERFACE + else -> DRI.from(supertypePsiClass) to JavaClassKindTypes.CLASS } GenericTypeConstructor( - dri, - psi.parameters.map(::getProjection) + supertypeDri, + supertypePsi.parameters.map(::getProjection) ) to javaClassKind } } diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt index fd40366f..f51a9edd 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt @@ -116,16 +116,16 @@ class JavaSignatureProvider internal constructor(ctcc: CommentsToContentConverte } private fun signature(f: DFunction) = - f.sourceSets.map { + f.sourceSets.map { sourceSet -> contentBuilder.contentFor( f, ContentKind.Symbol, - setOf(TextStyle.Monospace, TextStyle.Block) + f.stylesIfDeprecated(it), - sourceSets = setOf(it) + setOf(TextStyle.Monospace, TextStyle.Block) + f.stylesIfDeprecated(sourceSet), + sourceSets = setOf(sourceSet) ) { annotationsBlock(f) - text(f.modifier[it]?.takeIf { it !in ignoredModifiers }?.name?.plus(" ") ?: "") - text(f.modifiers()[it]?.toSignatureString() ?: "") + text(f.modifier[sourceSet]?.takeIf { it !in ignoredModifiers }?.name?.plus(" ") ?: "") + text(f.modifiers()[sourceSet]?.toSignatureString() ?: "") val returnType = f.type signatureForProjection(returnType) text(nbsp.toString()) |