aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-08-26 14:49:31 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-31 15:10:04 +0200
commit855718815ff58660a965b29247137355e67160c9 (patch)
tree82884ed2efc89adf3e44a22f3b24813238bb9e39 /plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt
parent9bf535bf8c0b758fc0abf99b61208fa5430239d6 (diff)
downloaddokka-855718815ff58660a965b29247137355e67160c9.tar.gz
dokka-855718815ff58660a965b29247137355e67160c9.tar.bz2
dokka-855718815ff58660a965b29247137355e67160c9.zip
WIP
Diffstat (limited to 'plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt')
-rw-r--r--plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt14
1 files changed, 8 insertions, 6 deletions
diff --git a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt
index 2667681c..6155af52 100644
--- a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt
+++ b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka.base.parsers.moduleAndPackage
+import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentation.Classifier.*
import java.io.File
@@ -24,17 +25,18 @@ private fun parseModuleAndPackageDocFragment(
val firstLine = firstLineAndDocumentation[0]
val classifierAndName = firstLine.split(Regex("\\s+"), limit = 2)
- if (classifierAndName.size != 2) {
- throw IllegalModuleAndPackageDocumentation(source, "Missing ${classifierAndName.first()} name")
- }
val classifier = when (classifierAndName[0].trim()) {
- "Module" -> ModuleAndPackageDocumentation.Classifier.Module
- "Package" -> ModuleAndPackageDocumentation.Classifier.Package
+ "Module" -> Module
+ "Package" -> Package
else -> throw IllegalStateException("Unexpected classifier ${classifierAndName[0]}")
}
- val name = classifierAndName[1].trim()
+ if (classifierAndName.size != 2 && classifier == Module) {
+ throw IllegalModuleAndPackageDocumentation(source, "Missing Module name")
+ }
+
+ val name = classifierAndName.getOrNull(1)?.trim().orEmpty()
if (name.contains(Regex("\\s"))) {
throw IllegalModuleAndPackageDocumentation(
source, "Module/Package name cannot contain whitespace in '$firstLine'"