diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 01c36607f..0c75e27e6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] kotlin = "1.9.10" -dokka = "1.8.10" +dokka = "1.9.0" serialization = "1.6.0" atomicfu = "0.22.0" javamath2kmp = "1.0" @@ -32,6 +32,7 @@ dokkaCore = { module = "org.jetbrains.dokka:dokka-core", version.ref = "dokka" } dokkaBase = { module = "org.jetbrains.dokka:dokka-base", version.ref = "dokka" } dokkaGfm = { module = "org.jetbrains.dokka:gfm-plugin", version.ref = "dokka" } dokkaGfmTemplateProcessing = { module = "org.jetbrains.dokka:gfm-template-processing-plugin", version.ref = "dokka" } +dokkaAnalysisKotlinApi = { module = "org.jetbrains.dokka:analysis-kotlin-api", version.ref = "dokka" } javamath2kmp = { module = "dev.erikchristensen.javamath2kmp:javamath2kmp", version.ref = "javamath2kmp" } kotlinGradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } kotlinTest = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } diff --git a/tools/mkdocs-dokka-plugin/build.gradle.kts b/tools/mkdocs-dokka-plugin/build.gradle.kts index 98b289f70..2626f6e3f 100644 --- a/tools/mkdocs-dokka-plugin/build.gradle.kts +++ b/tools/mkdocs-dokka-plugin/build.gradle.kts @@ -4,6 +4,7 @@ plugins { dependencies { compileOnly(libs.dokkaCore) + compileOnly(libs.dokkaAnalysisKotlinApi) implementation(libs.dokkaBase) implementation(libs.dokkaGfm) } diff --git a/tools/mkdocs-dokka-plugin/src/main/kotlin/MkdocsDocumentableToPageTranslator.kt b/tools/mkdocs-dokka-plugin/src/main/kotlin/MkdocsDocumentableToPageTranslator.kt index 97fd8765a..18bbeda13 100644 --- a/tools/mkdocs-dokka-plugin/src/main/kotlin/MkdocsDocumentableToPageTranslator.kt +++ b/tools/mkdocs-dokka-plugin/src/main/kotlin/MkdocsDocumentableToPageTranslator.kt @@ -1,10 +1,16 @@ +@file:OptIn(InternalDokkaApi::class) + package io.islandtime.gradle import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.InternalDokkaApi +import org.jetbrains.dokka.analysis.kotlin.internal.DocumentableSourceLanguageParser +import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.DokkaBaseConfiguration import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter +import org.jetbrains.dokka.base.transformers.pages.tags.CustomTagContentProvider import org.jetbrains.dokka.base.translators.documentables.DefaultPageCreator import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.model.Documentable @@ -14,34 +20,51 @@ import org.jetbrains.dokka.model.doc.TagWrapper import org.jetbrains.dokka.pages.ContentKind import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.pages.TextStyle -import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.plugability.configuration -import org.jetbrains.dokka.plugability.plugin -import org.jetbrains.dokka.plugability.querySingle +import org.jetbrains.dokka.plugability.* import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator import org.jetbrains.dokka.utilities.DokkaLogger import kotlin.reflect.KClass private typealias GroupedTags = Map, List>> + class MkdocsDocumentableToPageTranslator( context: DokkaContext ) : DocumentableToPageTranslator { private val configuration = configuration(context) private val commentsToContentConverter = context.plugin().querySingle { commentsToContentConverter } private val signatureProvider = context.plugin().querySingle { signatureProvider } + private val customTagContentProviders = context.plugin().query { customTagContentProvider } + private val documentableSourceLanguageParser = + context.plugin().querySingle { documentableSourceLanguageParser } private val logger = context.logger override fun invoke(module: DModule): ModulePageNode = - MkdocsPageCreator(configuration, commentsToContentConverter, signatureProvider, logger).pageForModule(module) + MkdocsPageCreator( + configuration, + commentsToContentConverter, + signatureProvider, + logger, + customTagContentProviders, + documentableSourceLanguageParser + ).pageForModule(module) } class MkdocsPageCreator( configuration: DokkaBaseConfiguration?, commentsToContentConverter: CommentsToContentConverter, signatureProvider: SignatureProvider, - logger: DokkaLogger -) : DefaultPageCreator(configuration, commentsToContentConverter, signatureProvider, logger) { + logger: DokkaLogger, + customTagContentProviders: List = emptyList(), + documentableAnalyzer: DocumentableSourceLanguageParser +) : DefaultPageCreator( + configuration, + commentsToContentConverter, + signatureProvider, + logger, + customTagContentProviders, + documentableAnalyzer +) { override fun contentForModule(m: DModule) = contentBuilder.contentFor(m) { group(kind = ContentKind.Cover) { diff --git a/tools/mkdocs-dokka-plugin/src/main/kotlin/MkdocsRenderer.kt b/tools/mkdocs-dokka-plugin/src/main/kotlin/MkdocsRenderer.kt index c9839e286..c3a804dd3 100644 --- a/tools/mkdocs-dokka-plugin/src/main/kotlin/MkdocsRenderer.kt +++ b/tools/mkdocs-dokka-plugin/src/main/kotlin/MkdocsRenderer.kt @@ -31,14 +31,17 @@ class MkdocsRenderer( inlineCodeBlock { childrenCallback() } buildParagraph() } + node.hasStyle(TextStyle.Block) -> { childrenCallback() buildParagraph() } + node.hasStyle(TextStyle.Paragraph) -> { childrenCallback() buildParagraph() } + else -> childrenCallback() } } @@ -377,6 +380,7 @@ class MkdocsRenderer( }, "" ) + is RenderingStrategy.PageLocationResolvableWrite -> outputWriter.write( path, strategy.contentToResolve { pageToLocate, context -> @@ -384,8 +388,10 @@ class MkdocsRenderer( }, "" ) + RenderingStrategy.DoNothing -> Unit } + else -> throw AssertionError( "Page ${page.name} cannot be rendered by renderer as it is not renderer specific nor contains content" ) @@ -403,13 +409,19 @@ class MkdocsRenderer( private fun MarkdownContent.buildSourceSetTags(sourceSets: Set) { val tags = sourceSets.joinToString(separator = " ") { val cssStyle = when (it.platform) { - Platform.common -> "source-set-common" + Platform.common -> if (it.name.lowercase().contains("darwin")) { + "source-set-darwin" + } else { + "source-set-common" + } + Platform.native -> "source-set-darwin" Platform.jvm -> if (it.name.lowercase().contains("android")) { "source-set-android" } else { "source-set-jvm" } + else -> "" }