aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-08-25 14:28:44 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-31 15:10:04 +0200
commit29cc17ba80018e3e45a5fabcf2e370c735fd5674 (patch)
tree4845c0d56582c290c69427769a032e8a017c2773 /plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt
parent333091e5c5f896769c3371dd74c87a52ffa9562a (diff)
downloaddokka-29cc17ba80018e3e45a5fabcf2e370c735fd5674.tar.gz
dokka-29cc17ba80018e3e45a5fabcf2e370c735fd5674.tar.bz2
dokka-29cc17ba80018e3e45a5fabcf2e370c735fd5674.zip
Implement ModuleAndPackageDocumentationReader
Diffstat (limited to 'plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt')
-rw-r--r--plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt36
1 files changed, 36 insertions, 0 deletions
diff --git a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt
new file mode 100644
index 00000000..f11a5d13
--- /dev/null
+++ b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt
@@ -0,0 +1,36 @@
+@file:Suppress("FunctionName")
+
+package org.jetbrains.dokka.base.parsers.moduleAndPackage
+
+import org.jetbrains.dokka.analysis.DokkaResolutionFacade
+import org.jetbrains.dokka.base.parsers.MarkdownParser
+import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentation.Classifier.*
+import org.jetbrains.dokka.model.doc.DocumentationNode
+import org.jetbrains.dokka.utilities.DokkaLogger
+import org.jetbrains.kotlin.name.FqName
+import org.jetbrains.kotlin.name.Name
+
+internal fun interface ModuleAndPackageDocumentationParsingContext {
+ fun markdownParserFor(fragment: ModuleAndPackageDocumentationFragment): MarkdownParser
+}
+
+internal fun ModuleAndPackageDocumentationParsingContext.parse(
+ fragment: ModuleAndPackageDocumentationFragment
+): DocumentationNode {
+ return markdownParserFor(fragment).parse(fragment.documentation)
+}
+
+internal fun ModuleAndPackageDocumentationParsingContext(
+ logger: DokkaLogger,
+ facade: DokkaResolutionFacade? = null,
+) = ModuleAndPackageDocumentationParsingContext { fragment ->
+ val descriptor = when (fragment.classifier) {
+ Module -> facade?.moduleDescriptor?.getPackage(FqName.topLevel(Name.identifier("")))
+ Package -> facade?.moduleDescriptor?.getPackage(FqName(fragment.name))
+ }
+ MarkdownParser(
+ resolutionFacade = facade,
+ declarationDescriptor = descriptor,
+ logger = logger
+ )
+}