Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump dokka to v1.9.0 #344

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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" }
Expand Down
1 change: 1 addition & 0 deletions tools/mkdocs-dokka-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {

dependencies {
compileOnly(libs.dokkaCore)
compileOnly(libs.dokkaAnalysisKotlinApi)
implementation(libs.dokkaBase)
implementation(libs.dokkaGfm)
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<KClass<out TagWrapper>, List<Pair<DokkaConfiguration.DokkaSourceSet?, TagWrapper>>>


class MkdocsDocumentableToPageTranslator(
context: DokkaContext
) : DocumentableToPageTranslator {
private val configuration = configuration<DokkaBase, DokkaBaseConfiguration>(context)
private val commentsToContentConverter = context.plugin<DokkaBase>().querySingle { commentsToContentConverter }
private val signatureProvider = context.plugin<DokkaBase>().querySingle { signatureProvider }
private val customTagContentProviders = context.plugin<DokkaBase>().query { customTagContentProvider }
private val documentableSourceLanguageParser =
context.plugin<InternalKotlinAnalysisPlugin>().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<CustomTagContentProvider> = emptyList(),
documentableAnalyzer: DocumentableSourceLanguageParser
) : DefaultPageCreator(
configuration,
commentsToContentConverter,
signatureProvider,
logger,
customTagContentProviders,
documentableAnalyzer
) {

override fun contentForModule(m: DModule) = contentBuilder.contentFor(m) {
group(kind = ContentKind.Cover) {
Expand Down
14 changes: 13 additions & 1 deletion tools/mkdocs-dokka-plugin/src/main/kotlin/MkdocsRenderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ class MkdocsRenderer(
inlineCodeBlock { childrenCallback() }
buildParagraph()
}

node.hasStyle(TextStyle.Block) -> {
childrenCallback()
buildParagraph()
}

node.hasStyle(TextStyle.Paragraph) -> {
childrenCallback()
buildParagraph()
}

else -> childrenCallback()
}
}
Expand Down Expand Up @@ -377,15 +380,18 @@ class MkdocsRenderer(
},
""
)

is RenderingStrategy.PageLocationResolvableWrite -> outputWriter.write(
path,
strategy.contentToResolve { pageToLocate, context ->
locationProvider.resolve(pageToLocate, context)
},
""
)

RenderingStrategy.DoNothing -> Unit
}

else -> throw AssertionError(
"Page ${page.name} cannot be rendered by renderer as it is not renderer specific nor contains content"
)
Expand All @@ -403,13 +409,19 @@ class MkdocsRenderer(
private fun MarkdownContent.buildSourceSetTags(sourceSets: Set<DisplaySourceSet>) {
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 -> ""
}

Expand Down