From c09bde34ff729ef9b1f3bea602fb53cd4e6dca42 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Fri, 13 Mar 2020 10:46:33 +0100 Subject: Gradle Task supporting multimodular projects --- .../transformers/documentables/DefaultDocumentableMerger.kt | 12 ++++++------ .../documentables/DocumentableVisibilityFilter.kt | 1 + .../transformers/pages/comments/DocTagToContentConverter.kt | 7 ++++--- 3 files changed, 11 insertions(+), 9 deletions(-) (limited to 'plugins/base/src/main/kotlin/transformers') diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt index bb7dbaaf..48be8ae7 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt @@ -12,17 +12,17 @@ import org.jetbrains.dokka.transformers.documentation.DocumentableMerger import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult internal object DefaultDocumentableMerger : DocumentableMerger { + override fun invoke(modules: Collection, context: DokkaContext): DModule { - val name = modules.map { it.name }.distinct().singleOrNull() ?: run { - context.logger.error("All module names need to be the same") - modules.first().name - } + + val projectName = + modules.fold(modules.first().name) { acc, module -> acc.commonPrefixWith(module.name) }.takeIf { it.isNotEmpty() } + ?: "project" return modules.reduce { left, right -> val list = listOf(left, right) - DModule( - name = name, + name = projectName, packages = merge( list.flatMap { it.packages }, DPackage::mergeWith diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt index 150df302..9f86c82a 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt @@ -15,6 +15,7 @@ internal object DocumentableVisibilityFilter : PreMergeDocumentableTransformer { val packageOptions = context.configuration.passesConfigurations.first { original.platformData.contains(it.platformData) } .perPackageOptions + DocumentableFilter(packageOptions).processModule(original) } diff --git a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt index 885fbfee..2eb63504 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt @@ -30,14 +30,15 @@ object DocTagToContentConverter : CommentsToContentConverter { ) ) - fun buildList(ordered: Boolean) = + fun buildList(ordered: Boolean, start: Int = 1) = listOf( ContentList( buildChildren(docTag), ordered, dci, platforms, - styles + styles, + ((PropertyContainer.empty()) + SimpleAttr("start", start.toString())) ) ) @@ -53,7 +54,7 @@ object DocTagToContentConverter : CommentsToContentConverter { is H5 -> buildHeader(5) is H6 -> buildHeader(6) is Ul -> buildList(false) - is Ol -> buildList(true) + is Ol -> buildList(true, docTag.params["start"]?.toInt() ?: 1) is Li -> buildChildren(docTag) is Br -> buildNewLine() is B -> buildChildren(docTag, setOf(TextStyle.Strong)) -- cgit