diff options
Diffstat (limited to 'core/src/main/kotlin')
7 files changed, 11 insertions, 122 deletions
diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt index 0f88b492..859e850e 100644 --- a/core/src/main/kotlin/CoreExtensions.kt +++ b/core/src/main/kotlin/CoreExtensions.kt @@ -1,6 +1,5 @@ package org.jetbrains.dokka -import org.jetbrains.dokka.pages.CommentsToContentConverter import org.jetbrains.dokka.plugability.ExtensionPoint import org.jetbrains.dokka.renderers.Renderer import org.jetbrains.dokka.renderers.OutputWriter @@ -27,7 +26,6 @@ object CoreExtensions { val pageTransformer by coreExtension<PageNodeTransformer>() val renderer by coreExtension<Renderer>() - val commentsToContentConverter by coreExtension<CommentsToContentConverter>() val locationProviderFactory by coreExtension<LocationProviderFactory>() val outputWriter by coreExtension<OutputWriter>() diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index 1ad93f4f..8897e68d 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -88,7 +88,7 @@ class DokkaGenerator( fun createPages( transformedDocumentation: Module, context: DokkaContext - ) = context.single(CoreExtensions.documentablesToPageTranslator).invoke(transformedDocumentation, context) + ) = context.single(CoreExtensions.documentablesToPageTranslator).invoke(transformedDocumentation) fun transformPages( pages: RootPageNode, diff --git a/core/src/main/kotlin/pages/CommentsToContentConverter.kt b/core/src/main/kotlin/pages/CommentsToContentConverter.kt deleted file mode 100644 index 78c7ff4c..00000000 --- a/core/src/main/kotlin/pages/CommentsToContentConverter.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.jetbrains.dokka.pages - -import org.jetbrains.dokka.model.doc.DocTag - -interface CommentsToContentConverter { - fun buildContent( - docTag: DocTag, - dci: DCI, - platforms: Set<PlatformData>, - styles: Set<Style> = emptySet(), - extras: Set<Extra> = emptySet() - ): List<ContentNode> -} diff --git a/core/src/main/kotlin/pages/DocTagToContentConverter.kt b/core/src/main/kotlin/pages/DocTagToContentConverter.kt deleted file mode 100644 index 08a579a8..00000000 --- a/core/src/main/kotlin/pages/DocTagToContentConverter.kt +++ /dev/null @@ -1,97 +0,0 @@ -package org.jetbrains.dokka.pages - -import org.jetbrains.dokka.model.doc.* -import org.jetbrains.dokka.plugability.DokkaContext - -class DocTagToContentConverter( - private val context: DokkaContext -) : CommentsToContentConverter { - override fun buildContent( - docTag: DocTag, - dci: DCI, - platforms: Set<PlatformData>, - styles: Set<Style>, - extras: Set<Extra> - - ): List<ContentNode> { - - fun buildChildren(docTag: DocTag, newStyles: Set<Style> = emptySet(), newExtras: Set<Extra> = emptySet()) = - docTag.children.flatMap { - buildContent(it, dci, platforms, styles + newStyles, extras + newExtras) - } - - fun buildHeader(level: Int) = - listOf(ContentHeader(buildChildren(docTag), level, dci, platforms, styles, extras)) - - fun buildList(ordered: Boolean) = - listOf(ContentList(buildChildren(docTag), ordered, dci, platforms, styles, extras)) - - return when (docTag) { - is H1 -> buildHeader(1) - is H2 -> buildHeader(2) - is H3 -> buildHeader(3) - is H4 -> buildHeader(4) - is H5 -> buildHeader(5) - is H6 -> buildHeader(6) - is Ul -> buildList(false) - is Ol -> buildList(true) - is Li -> buildChildren(docTag) - is B -> buildChildren(docTag, setOf(TextStyle.Strong)) - is I -> buildChildren(docTag, setOf(TextStyle.Italic)) - is P -> buildChildren(docTag, newStyles = setOf(TextStyle.Paragraph)) - is A -> listOf( - ContentResolvedLink( - buildChildren(docTag), - docTag.params.get("href")!!, - dci, - platforms, - styles, - extras - ) - ) - is DocumentationLink -> listOf( - ContentDRILink( - buildChildren(docTag), - docTag.dri, - DCI(setOf(docTag.dri), ContentKind.Symbol), - platforms, - styles, - extras - ) - ) - is BlockQuote -> listOf( - ContentCode( - buildChildren(docTag), - "", - dci, - platforms, - styles, - extras - ) - ) - is Code -> listOf( - ContentCode( - buildChildren(docTag), - "", - dci, - platforms, - styles, - extras - ) - ) - is Img -> listOf( - ContentEmbeddedResource( - address = docTag.params.get("href")!!, - altText = docTag.params.get("alt"), - dci = dci, - platforms = platforms, - style = styles, - extras = extras - ) - ) - is HorizontalRule -> listOf(ContentText("", dci, platforms, setOf())) - is Text -> listOf(ContentText(docTag.body, dci, platforms, styles, extras)) - else -> buildChildren(docTag) - } - } -} diff --git a/core/src/main/kotlin/plugability/DefaultExtensions.kt b/core/src/main/kotlin/plugability/DefaultExtensions.kt index 1a367d30..242eb6b8 100644 --- a/core/src/main/kotlin/plugability/DefaultExtensions.kt +++ b/core/src/main/kotlin/plugability/DefaultExtensions.kt @@ -1,23 +1,20 @@ package org.jetbrains.dokka.plugability import org.jetbrains.dokka.CoreExtensions -import org.jetbrains.dokka.pages.DocTagToContentConverter import org.jetbrains.dokka.renderers.FileWriter import org.jetbrains.dokka.renderers.OutputWriter import org.jetbrains.dokka.resolvers.DefaultLocationProviderFactory internal object DefaultExtensions { - private val converter: LazyEvaluated<DocTagToContentConverter> = LazyEvaluated.fromRecipe { DocTagToContentConverter(it) } private val providerFactory: LazyEvaluated<DefaultLocationProviderFactory> = LazyEvaluated.fromRecipe { DefaultLocationProviderFactory(it) } private val outputWriter: LazyEvaluated<OutputWriter> = LazyEvaluated.fromRecipe { FileWriter(it) } @Suppress("IMPLICIT_CAST_TO_ANY", "UNCHECKED_CAST") internal fun <T : Any, E : ExtensionPoint<T>> get(point: E, fullContext: DokkaContext): List<T> = when (point) { - CoreExtensions.commentsToContentConverter -> converter.get(fullContext) CoreExtensions.locationProviderFactory -> providerFactory.get(fullContext) - CoreExtensions.outputWriter -> outputWriter.get(fullContext) + CoreExtensions.outputWriter -> outputWriter.get(fullContext) else -> null }.let { listOfNotNull( it ) as List<T> } }
\ No newline at end of file diff --git a/core/src/main/kotlin/plugability/DokkaPlugin.kt b/core/src/main/kotlin/plugability/DokkaPlugin.kt index c00b0af3..d8fb7892 100644 --- a/core/src/main/kotlin/plugability/DokkaPlugin.kt +++ b/core/src/main/kotlin/plugability/DokkaPlugin.kt @@ -13,8 +13,7 @@ abstract class DokkaPlugin { @PublishedApi internal var context: DokkaContext? = null - protected inline fun <reified T : DokkaPlugin> plugin(): T = context?.plugin(T::class) - ?: throw IllegalStateException("Querying about plugins is only possible with dokka context initialised") + protected inline fun <reified T : DokkaPlugin> plugin(): T = context?.plugin(T::class) ?: throwIllegalQuery() protected fun <T : Any> extensionPoint() = object : ReadOnlyProperty<DokkaPlugin, ExtensionPoint<T>> { @@ -51,5 +50,10 @@ abstract class DokkaPlugin { } inline fun <reified P : DokkaPlugin, reified E : Any> P.query(extension: P.() -> ExtensionPoint<E>): List<E> = - context?.let { it[extension()] } - ?: throw IllegalStateException("Querying about plugins is only possible with dokka context initialised")
\ No newline at end of file + context?.let { it[extension()] } ?: throwIllegalQuery() + +inline fun <reified P : DokkaPlugin, reified E : Any> P.querySingle(extension: P.() -> ExtensionPoint<E>): E = + context?.single(extension()) ?: throwIllegalQuery() + +fun throwIllegalQuery(): Nothing = + throw IllegalStateException("Querying about plugins is only possible with dokka context initialised") diff --git a/core/src/main/kotlin/transformers/documentation/DocumentablesToPageTranslator.kt b/core/src/main/kotlin/transformers/documentation/DocumentablesToPageTranslator.kt index fa74d216..19698fa0 100644 --- a/core/src/main/kotlin/transformers/documentation/DocumentablesToPageTranslator.kt +++ b/core/src/main/kotlin/transformers/documentation/DocumentablesToPageTranslator.kt @@ -5,5 +5,5 @@ import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.plugability.DokkaContext interface DocumentablesToPageTranslator { - operator fun invoke(module: Module, context: DokkaContext): ModulePageNode + operator fun invoke(module: Module): ModulePageNode }
\ No newline at end of file |