From ba769f0695aaa9719b62ca32028fd3d24442f5ec Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Mon, 17 Feb 2020 11:27:37 +0100 Subject: Moves comments to content conversion to base plugin --- plugins/base/src/main/kotlin/DokkaBase.kt | 13 +- .../DefaultDocumentablesToPageTranslator.kt | 13 +- .../documentables/PageContentBuilder.kt | 1 + .../pages/comments/CommentsToContentConverter.kt | 14 +++ .../pages/comments/DocTagToContentConverter.kt | 132 +++++++++++++++++++++ 5 files changed, 167 insertions(+), 6 deletions(-) create mode 100644 plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt create mode 100644 plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt (limited to 'plugins/base') diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt index ed23d77e..9b6e9b1a 100644 --- a/plugins/base/src/main/kotlin/DokkaBase.kt +++ b/plugins/base/src/main/kotlin/DokkaBase.kt @@ -4,6 +4,8 @@ import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.base.transformers.descriptors.DefaultDescriptorToDocumentationTranslator import org.jetbrains.dokka.base.transformers.documentables.DefaultDocumentableMerger import org.jetbrains.dokka.base.transformers.documentables.DefaultDocumentablesToPageTranslator +import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter +import org.jetbrains.dokka.base.transformers.pages.comments.DocTagToContentConverter import org.jetbrains.dokka.base.transformers.pages.merger.FallbackPageMergerStrategy import org.jetbrains.dokka.base.transformers.pages.merger.PageMergerStrategy import org.jetbrains.dokka.base.transformers.pages.merger.PageNodeMerger @@ -12,8 +14,9 @@ import org.jetbrains.dokka.base.transformers.psi.DefaultPsiToDocumentationTransl import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.renderers.html.HtmlRenderer -class DokkaBase: DokkaPlugin() { +class DokkaBase : DokkaPlugin() { val pageMergerStrategy by extensionPoint() + val commentsToContentConverter by extensionPoint() val descriptorToDocumentationTranslator by extending(isFallback = true) { CoreExtensions.descriptorToDocumentationTranslator providing ::DefaultDescriptorToDocumentationTranslator @@ -28,7 +31,13 @@ class DokkaBase: DokkaPlugin() { } val documentablesToPageTranslator by extending(isFallback = true) { - CoreExtensions.documentablesToPageTranslator with DefaultDocumentablesToPageTranslator + CoreExtensions.documentablesToPageTranslator providing { ctx -> + DefaultDocumentablesToPageTranslator(ctx.single(commentsToContentConverter), ctx.logger) + } + } + + val docTagToContentConverter by extending(isFallback = true) { + commentsToContentConverter with DocTagToContentConverter } val pageMerger by extending { diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentablesToPageTranslator.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentablesToPageTranslator.kt index 90f8e2d7..d28791ab 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentablesToPageTranslator.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentablesToPageTranslator.kt @@ -1,21 +1,26 @@ package org.jetbrains.dokka.base.transformers.documentables import org.jetbrains.dokka.CoreExtensions +import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.model.Module import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.DocumentablesToPageTranslator +import org.jetbrains.dokka.utilities.DokkaLogger -object DefaultDocumentablesToPageTranslator : DocumentablesToPageTranslator { - override fun invoke(module: Module, context: DokkaContext): ModulePageNode = +class DefaultDocumentablesToPageTranslator( + private val commentsToContentConverter: CommentsToContentConverter, + private val logger: DokkaLogger +) : DocumentablesToPageTranslator { + override fun invoke(module: Module): ModulePageNode = DefaultPageBuilder { node, kind, operation -> DefaultPageContentBuilder.group( setOf(node.dri), node.platformData, kind, - context.single(CoreExtensions.commentsToContentConverter), - context.logger, + commentsToContentConverter, + logger, operation ) }.pageForModule(module) diff --git a/plugins/base/src/main/kotlin/transformers/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/transformers/documentables/PageContentBuilder.kt index 809b97a0..6ce883b1 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/PageContentBuilder.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/PageContentBuilder.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.base.transformers.documentables +import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.Function diff --git a/plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt b/plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt new file mode 100644 index 00000000..4d2f14a5 --- /dev/null +++ b/plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt @@ -0,0 +1,14 @@ +package org.jetbrains.dokka.base.transformers.pages.comments + +import org.jetbrains.dokka.model.doc.DocTag +import org.jetbrains.dokka.pages.* + +interface CommentsToContentConverter { + fun buildContent( + docTag: DocTag, + dci: DCI, + platforms: Set, + styles: Set