aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r--plugins/base/src/main/kotlin/DokkaBase.kt7
-rw-r--r--plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt100
-rw-r--r--plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentation.kt2
-rw-r--r--plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationFragment.kt2
-rw-r--r--plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt4
-rw-r--r--plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationSource.kt2
-rw-r--r--plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentation.kt2
-rw-r--r--plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt4
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt4
9 files changed, 10 insertions, 117 deletions
diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt
index e92759ff..de7e1e5e 100644
--- a/plugins/base/src/main/kotlin/DokkaBase.kt
+++ b/plugins/base/src/main/kotlin/DokkaBase.kt
@@ -4,7 +4,6 @@ package org.jetbrains.dokka.base
import org.jetbrains.dokka.CoreExtensions
import org.jetbrains.dokka.analysis.KotlinAnalysis
-import org.jetbrains.dokka.base.allModulePage.MultimodulePageCreator
import org.jetbrains.dokka.base.renderers.*
import org.jetbrains.dokka.base.renderers.html.*
import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProviderFactory
@@ -205,12 +204,6 @@ class DokkaBase : DokkaPlugin() {
htmlPreprocessors providing ::SourcesetDependencyAppender order { after(rootCreator) }
}
- val allModulePageCreators by extending {
- CoreExtensions.allModulePageCreator providing {
- MultimodulePageCreator(it)
- }
- }
-
val baseSearchbarDataInstaller by extending {
htmlPreprocessors providing ::SearchbarDataInstaller order { after(sourceLinksTransformer) }
}
diff --git a/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt b/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt
deleted file mode 100644
index 3c4f1dea..00000000
--- a/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.jetbrains.dokka.base.allModulePage
-
-import org.jetbrains.dokka.DokkaConfiguration.DokkaModuleDescription
-import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
-import org.jetbrains.dokka.base.DokkaBase
-import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentation.Classifier.Module
-import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentationParsingContext
-import org.jetbrains.dokka.base.parsers.moduleAndPackage.parseModuleAndPackageDocumentation
-import org.jetbrains.dokka.base.parsers.moduleAndPackage.parseModuleAndPackageDocumentationFragments
-import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint
-import org.jetbrains.dokka.base.resolvers.local.MultimoduleLocationProvider.Companion.MULTIMODULE_PACKAGE_PLACEHOLDER
-import org.jetbrains.dokka.base.transformers.pages.comments.DocTagToContentConverter
-import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
-import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.model.doc.DocTag
-import org.jetbrains.dokka.model.doc.DocumentationNode
-import org.jetbrains.dokka.model.doc.P
-import org.jetbrains.dokka.model.properties.PropertyContainer
-import org.jetbrains.dokka.pages.*
-import org.jetbrains.dokka.plugability.DokkaContext
-import org.jetbrains.dokka.plugability.querySingle
-import org.jetbrains.dokka.transformers.pages.PageCreator
-import org.jetbrains.dokka.utilities.DokkaLogger
-
-class MultimodulePageCreator(
- private val context: DokkaContext,
-) : PageCreator {
- private val logger: DokkaLogger = context.logger
-
- override fun invoke(): RootPageNode {
- val modules = context.configuration.modules
-
- val commentsConverter = context.plugin(DokkaBase::class)?.querySingle { commentsToContentConverter }
- val signatureProvider = context.plugin(DokkaBase::class)?.querySingle { signatureProvider }
- if (commentsConverter == null || signatureProvider == null)
- throw IllegalStateException("Both comments converter and signature provider must not be null")
-
- val sourceSetData = emptySet<DokkaSourceSet>()
- val builder = PageContentBuilder(commentsConverter, signatureProvider, context.logger)
- val contentNode = builder.contentFor(
- dri = DRI(MULTIMODULE_PACKAGE_PLACEHOLDER),
- kind = ContentKind.Cover,
- sourceSets = sourceSetData
- ) {
- header(2, "All modules:")
- table(styles = setOf(MultimoduleTable)) {
- modules.map { module ->
- val displayedModuleDocumentation = getDisplayedModuleDocumentation(module)
- val dri = DRI(packageName = MULTIMODULE_PACKAGE_PLACEHOLDER, classNames = module.name)
- val dci = DCI(setOf(dri), ContentKind.Comment)
- val extraWithAnchor = PropertyContainer.withAll(SymbolAnchorHint(module.name, ContentKind.Main))
- val header = linkNode(module.name, dri, DCI(setOf(dri), ContentKind.Main), extra = extraWithAnchor)
- val content = ContentGroup(
- children =
- if (displayedModuleDocumentation != null)
- DocTagToContentConverter().buildContent(displayedModuleDocumentation, dci, emptySet())
- else emptyList(),
- dci = dci,
- sourceSets = emptySet(),
- style = emptySet()
- )
- ContentGroup(listOf(header, content), dci, emptySet(), emptySet(), extraWithAnchor)
- }
- }
- }
- return MultimoduleRootPageNode(
- "Modules",
- setOf(DRI(packageName = MULTIMODULE_PACKAGE_PLACEHOLDER, classNames = "allModules")),
- contentNode
- )
- }
-
- private fun getDisplayedModuleDocumentation(module: DokkaModuleDescription): P? {
- val parsingContext = ModuleAndPackageDocumentationParsingContext(logger)
-
- val documentationFragment = module.includes
- .flatMap { include -> parseModuleAndPackageDocumentationFragments(include) }
- .firstOrNull { fragment -> fragment.classifier == Module && fragment.name == module.name }
- ?: return null
-
- val moduleDocumentation = parseModuleAndPackageDocumentation(parsingContext, documentationFragment)
- return moduleDocumentation.documentation.firstParagraph()
- }
-
- private fun DocumentationNode.firstParagraph(): P? =
- this.children
- .map { it.root }
- .mapNotNull { it.firstParagraph() }
- .firstOrNull()
-
- /**
- * @return The very first, most inner paragraph. If any [P] is wrapped inside another [P], the inner one
- * is preferred.
- */
- private fun DocTag.firstParagraph(): P? {
- val firstChildParagraph = children.mapNotNull { it.firstParagraph() }.firstOrNull()
- return if (firstChildParagraph == null && this is P) this
- else firstChildParagraph
- }
-}
diff --git a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentation.kt b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentation.kt
index 5139c872..ee67fad1 100644
--- a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentation.kt
+++ b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentation.kt
@@ -2,7 +2,7 @@ package org.jetbrains.dokka.base.parsers.moduleAndPackage
import org.jetbrains.dokka.model.doc.DocumentationNode
-internal data class ModuleAndPackageDocumentation(
+data class ModuleAndPackageDocumentation(
val name: String,
val classifier: Classifier,
val documentation: DocumentationNode
diff --git a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationFragment.kt b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationFragment.kt
index fa99a8e2..06fef72c 100644
--- a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationFragment.kt
+++ b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationFragment.kt
@@ -2,7 +2,7 @@ package org.jetbrains.dokka.base.parsers.moduleAndPackage
import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentation.*
-internal data class ModuleAndPackageDocumentationFragment(
+data class ModuleAndPackageDocumentationFragment(
val name: String,
val classifier: Classifier,
val documentation: String,
diff --git a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt
index 64441447..afdcc43f 100644
--- a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt
+++ b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
-internal fun interface ModuleAndPackageDocumentationParsingContext {
+fun interface ModuleAndPackageDocumentationParsingContext {
fun markdownParserFor(fragment: ModuleAndPackageDocumentationFragment): MarkdownParser
}
@@ -27,7 +27,7 @@ internal fun ModuleAndPackageDocumentationParsingContext.parse(
return markdownParserFor(fragment).parse(fragment.documentation)
}
-internal fun ModuleAndPackageDocumentationParsingContext(
+fun ModuleAndPackageDocumentationParsingContext(
logger: DokkaLogger,
facade: DokkaResolutionFacade? = null
) = ModuleAndPackageDocumentationParsingContext { fragment ->
diff --git a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationSource.kt b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationSource.kt
index 90dc9ca8..9514adb4 100644
--- a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationSource.kt
+++ b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationSource.kt
@@ -2,7 +2,7 @@ package org.jetbrains.dokka.base.parsers.moduleAndPackage
import java.io.File
-internal abstract class ModuleAndPackageDocumentationSource {
+abstract class ModuleAndPackageDocumentationSource {
abstract val sourceDescription: String
abstract val documentation: String
override fun toString(): String = sourceDescription
diff --git a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentation.kt b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentation.kt
index a2876308..5ef9d7ef 100644
--- a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentation.kt
+++ b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentation.kt
@@ -2,7 +2,7 @@
package org.jetbrains.dokka.base.parsers.moduleAndPackage
-internal fun parseModuleAndPackageDocumentation(
+fun parseModuleAndPackageDocumentation(
context: ModuleAndPackageDocumentationParsingContext,
fragment: ModuleAndPackageDocumentationFragment
): ModuleAndPackageDocumentation {
diff --git a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt
index 7dcaccfa..d193ec0a 100644
--- a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt
+++ b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt
@@ -4,11 +4,11 @@ import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumen
import java.io.File
-internal fun parseModuleAndPackageDocumentationFragments(source: File): List<ModuleAndPackageDocumentationFragment> {
+fun parseModuleAndPackageDocumentationFragments(source: File): List<ModuleAndPackageDocumentationFragment> {
return parseModuleAndPackageDocumentationFragments(ModuleAndPackageDocumentationFile(source))
}
-internal fun parseModuleAndPackageDocumentationFragments(
+fun parseModuleAndPackageDocumentationFragments(
source: ModuleAndPackageDocumentationSource
): List<ModuleAndPackageDocumentationFragment> {
val fragmentStrings = source.documentation.split(Regex("(|^)#\\s*(?=(Module|Package))"))
diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
index 3ef8bcce..030197a5 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
@@ -129,12 +129,12 @@ open class DokkaLocationProvider(
protected data class PageWithKind(val page: ContentPage, val kind: Kind)
companion object {
- internal val reservedFilenames = setOf("index", "con", "aux", "lst", "prn", "nul", "eof", "inp", "out")
+ val reservedFilenames = setOf("index", "con", "aux", "lst", "prn", "nul", "eof", "inp", "out")
//Taken from: https://stackoverflow.com/questions/1976007/what-characters-are-forbidden-in-windows-and-linux-directory-names
internal val reservedCharacters = setOf('|', '>', '<', '*', ':', '"', '?', '%')
- internal fun identifierToFilename(name: String): String {
+ fun identifierToFilename(name: String): String {
if (name.isEmpty()) return "--root--"
return sanitizeFileName(name, reservedFilenames, reservedCharacters)
}