aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-04-08 09:23:36 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-04-08 13:21:22 +0200
commitb856615cbd0595210007eec7c46bcae46a64c94f (patch)
tree630ac84e04f5a76ca866175d71a6e1887a060a01 /plugins/base/src
parent5013037c6bc555df2544f08ce25afd0307ee2cc1 (diff)
downloaddokka-b856615cbd0595210007eec7c46bcae46a64c94f.tar.gz
dokka-b856615cbd0595210007eec7c46bcae46a64c94f.tar.bz2
dokka-b856615cbd0595210007eec7c46bcae46a64c94f.zip
Applies requested changes
Diffstat (limited to 'plugins/base/src')
-rw-r--r--plugins/base/src/main/kotlin/DokkaBase.kt2
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt53
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt2
3 files changed, 34 insertions, 23 deletions
diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt
index 2be784ba..e8614507 100644
--- a/plugins/base/src/main/kotlin/DokkaBase.kt
+++ b/plugins/base/src/main/kotlin/DokkaBase.kt
@@ -131,7 +131,7 @@ class DokkaBase : DokkaPlugin() {
htmlPreprocessors with RootCreator
}
- val defaultSamplesTransformer by extending(isFallback = true) {
+ val defaultSamplesTransformer by extending {
samplesTransformer providing ::DefaultSamplesTransformer
}
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt
index 92fa8ce4..a2fb25a9 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt
@@ -18,20 +18,31 @@ internal object ModuleAndPackageDocumentationTransformer : PreMergeDocumentableT
context.configuration.passesConfigurations
.map {
Pair(it.moduleName, it.platformData) to
- it.includes.map { Paths.get(it) }
- .filter { Files.exists(it) }
- .flatMap {
- it.toFile()
- .readText()
- .split(Regex("(\n|^)# (?=(Module|Package))")) // Matches heading with Module/Package to split by
- .filter { it.isNotEmpty() }
- .map { it.split(Regex(" "), 2) } // Matches space between Module/Package and fully qualified name
- }.groupBy({ it[0] }, {
- it[1].split(Regex("\n"), 2) // Matches new line after fully qualified name
- .let { it[0] to it[1].trim() }
- }).mapValues {
- it.value.toMap()
- }
+ it.includes.map { Paths.get(it) }
+ .also {
+ it.forEach {
+ if (Files.notExists(it))
+ context.logger.warn("Not found file under this path ${it.toAbsolutePath()}")
+ }
+ }
+ .filter { Files.exists(it) }
+ .flatMap {
+ it.toFile()
+ .readText()
+ .split(Regex("(\n|^)# (?=(Module|Package))")) // Matches heading with Module/Package to split by
+ .filter { it.isNotEmpty() }
+ .map {
+ it.split(
+ Regex(" "),
+ 2
+ )
+ } // Matches space between Module/Package and fully qualified name
+ }.groupBy({ it[0] }, {
+ it[1].split(Regex("\n"), 2) // Matches new line after fully qualified name
+ .let { it[0] to it[1].trim() }
+ }).mapValues {
+ it.value.toMap()
+ }
}.toMap()
return original.map { module ->
@@ -39,8 +50,8 @@ internal object ModuleAndPackageDocumentationTransformer : PreMergeDocumentableT
val moduleDocumentation =
module.platformData.mapNotNull { pd ->
val doc = modulesAndPackagesDocumentation[Pair(module.name, pd)]
- val facade = context.platforms[pd]?.facade ?:
- return@mapNotNull null.also { context.logger.warn("Could not find platform data for ${pd.name}") }
+ val facade = context.platforms[pd]?.facade
+ ?: return@mapNotNull null.also { context.logger.warn("Could not find platform data for ${pd.name}") }
doc?.get("Module")?.get(module.name)?.run {
pd to MarkdownParser(
facade,
@@ -52,10 +63,10 @@ internal object ModuleAndPackageDocumentationTransformer : PreMergeDocumentableT
val packagesDocumentation = module.packages.map {
it.name to it.platformData.mapNotNull { pd ->
val doc = modulesAndPackagesDocumentation[Pair(module.name, pd)]
- val facade = context.platforms[pd]?.facade ?:
- return@mapNotNull null.also { context.logger.warn("Could not find platform data for ${pd.name}") }
- val descriptor = facade.resolveSession.getPackageFragment(FqName(it.name)) ?:
- return@mapNotNull null.also { context.logger.warn("Could not find descriptor for $") }
+ val facade = context.platforms[pd]?.facade
+ ?: return@mapNotNull null.also { context.logger.warn("Could not find platform data for ${pd.name}") }
+ val descriptor = facade.resolveSession.getPackageFragment(FqName(it.name))
+ ?: return@mapNotNull null.also { context.logger.warn("Could not find descriptor for $") }
doc?.get("Package")?.get(it.name)?.run {
pd to MarkdownParser(
facade,
@@ -68,7 +79,7 @@ internal object ModuleAndPackageDocumentationTransformer : PreMergeDocumentableT
module.copy(
documentation = module.documentation.let { PlatformDependent(it.map + moduleDocumentation) },
packages = module.packages.map {
- if(packagesDocumentation[it.name] != null)
+ if (packagesDocumentation[it.name] != null)
it.copy(documentation = it.documentation.let { value ->
PlatformDependent(value.map + packagesDocumentation[it.name]!!)
})
diff --git a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt
index a3a6b99c..bd10a923 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt
@@ -25,7 +25,7 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer {
abstract fun processBody(psiElement: PsiElement): String
abstract fun processImports(psiElement: PsiElement): String
- override fun invoke(input: RootPageNode): RootPageNode {
+ final override fun invoke(input: RootPageNode): RootPageNode {
val analysis = setUpAnalysis(context)