diff options
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r-- | core/src/main/kotlin/DokkaBootstrapImpl.kt | 7 | ||||
-rw-r--r-- | core/src/main/kotlin/Generation/DokkaGenerator.kt | 21 | ||||
-rw-r--r-- | core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 17 | ||||
-rw-r--r-- | core/src/main/kotlin/Utilities/DokkaModules.kt | 6 |
4 files changed, 41 insertions, 10 deletions
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index eb2b2a65..59139263 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -10,6 +10,11 @@ fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinition { urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#" + it }) } +fun parseSourceRoot(sourceRoot: String): SourceRoot { + val components = sourceRoot.split("::", limit = 2) + return SourceRoot(components.first(), components.getOrNull(1)?.split(',').orEmpty()) +} + class DokkaBootstrapImpl : DokkaBootstrap { class DokkaProxyLogger(val consumer: BiConsumer<String, String>) : DokkaLogger { @@ -46,7 +51,7 @@ class DokkaBootstrapImpl : DokkaBootstrap { generator = DokkaGenerator( DokkaProxyLogger(logger), classpath, - sources, + sources.map(::parseSourceRoot), samples, includes, moduleName, diff --git a/core/src/main/kotlin/Generation/DokkaGenerator.kt b/core/src/main/kotlin/Generation/DokkaGenerator.kt index aaf0deff..95066eec 100644 --- a/core/src/main/kotlin/Generation/DokkaGenerator.kt +++ b/core/src/main/kotlin/Generation/DokkaGenerator.kt @@ -22,9 +22,11 @@ import org.jetbrains.kotlin.utils.PathUtil import java.io.File import kotlin.system.measureTimeMillis +class SourceRoot(val path: String, val implicitPlatforms: List<String> = emptyList()) + class DokkaGenerator(val logger: DokkaLogger, val classpath: List<String>, - val sources: List<String>, + val sources: List<SourceRoot>, val samples: List<String>, val includes: List<String>, val moduleName: String, @@ -33,7 +35,10 @@ class DokkaGenerator(val logger: DokkaLogger, private val documentationModule = DocumentationModule(moduleName) fun generate() { - appendSourceModule() + val sourcesGroupedByPlatform = sources.groupBy { it.implicitPlatforms } + for ((platforms, roots) in sourcesGroupedByPlatform) { + appendSourceModule(platforms, roots.map { it.path }) + } val timeBuild = measureTimeMillis { logger.info("Generating pages... ") @@ -43,18 +48,18 @@ class DokkaGenerator(val logger: DokkaLogger, logger.info("done in ${timeBuild / 1000} secs") } - private fun appendSourceModule() { - val environment = createAnalysisEnvironment() + private fun appendSourceModule(implicitPlatforms: List<String>, sourcePaths: List<String>) { + val environment = createAnalysisEnvironment(sourcePaths) logger.info("Module: $moduleName") logger.info("Output: ${File(options.outputDir)}") - logger.info("Sources: ${environment.sources.joinToString()}") + logger.info("Sources: ${sourcePaths.joinToString()}") logger.info("Classpath: ${environment.classpath.joinToString()}") logger.info("Analysing sources and libraries... ") val startAnalyse = System.currentTimeMillis() - val injector = Guice.createInjector(DokkaAnalysisModule(environment, options, logger)) + val injector = Guice.createInjector(DokkaAnalysisModule(environment, options, implicitPlatforms, logger)) buildDocumentationModule(injector, documentationModule, { isSample(it) }, includes) @@ -64,7 +69,7 @@ class DokkaGenerator(val logger: DokkaLogger, Disposer.dispose(environment) } - fun createAnalysisEnvironment(): AnalysisEnvironment { + fun createAnalysisEnvironment(sourcePaths: List<String>): AnalysisEnvironment { val environment = AnalysisEnvironment(DokkaMessageCollector(logger)) environment.apply { @@ -74,7 +79,7 @@ class DokkaGenerator(val logger: DokkaLogger, addClasspath(File(element)) } - addSources(this@DokkaGenerator.sources) + addSources(sourcePaths) addSources(this@DokkaGenerator.samples) } diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index bcbdf5f4..e165a2b5 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.source.getPsi import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf import org.jetbrains.kotlin.types.typeUtil.supertypes +import com.google.inject.name.Named as GuiceNamed data class DocumentationOptions(val outputDir: String, val outputFormat: String, @@ -57,6 +58,8 @@ interface PackageDocumentationBuilder { allFqNames: Collection<FqName>) } +const val implicitPlatformName = "implicitPlatform" + class DocumentationBuilder @Inject constructor(val resolutionFacade: DokkaResolutionFacade, val descriptorDocumentationParser: DescriptorDocumentationParser, @@ -64,7 +67,8 @@ class DocumentationBuilder val refGraph: NodeReferenceGraph, val platformNodeRegistry: PlatformNodeRegistry, val logger: DokkaLogger, - val linkResolver: DeclarationLinkResolver) { + val linkResolver: DeclarationLinkResolver, + @GuiceNamed(implicitPlatformName) val implicitPlatforms: List<String>) { val boringBuiltinClasses = setOf( "kotlin.Unit", "kotlin.Byte", "kotlin.Short", "kotlin.Int", "kotlin.Long", "kotlin.Char", "kotlin.Boolean", "kotlin.Float", "kotlin.Double", "kotlin.String", "kotlin.Array", "kotlin.Any") @@ -237,6 +241,12 @@ class DocumentationBuilder } } + fun DocumentationNode.appendImplicitPlatforms() { + for (platform in implicitPlatforms) { + append(platformNodeRegistry[platform], RefKind.Platform) + } + } + fun DocumentationNode.isDeprecation() = name == "Deprecated" || name == "deprecated" fun DocumentationNode.isSinceKotlin() = name == "SinceKotlin" && kind == NodeKind.Annotation @@ -412,6 +422,7 @@ class DocumentationBuilder node.appendType(underlyingType, NodeKind.TypeAliasUnderlyingType) node.appendSourceLink(source) + node.appendImplicitPlatforms() register(this, node) return node @@ -453,6 +464,7 @@ class DocumentationBuilder node.appendAnnotations(this) node.appendModifiers(this) node.appendSourceLink(source) + node.appendImplicitPlatforms() register(this, node) return node } @@ -469,6 +481,7 @@ class DocumentationBuilder fun ConstructorDescriptor.build(): DocumentationNode { val node = nodeForDescriptor(this, NodeKind.Constructor) node.appendInPageChildren(valueParameters, RefKind.Detail) + node.appendImplicitPlatforms() register(this, node) return node } @@ -497,6 +510,7 @@ class DocumentationBuilder node.appendModifiers(this) node.appendSourceLink(source) node.appendSignature(this) + node.appendImplicitPlatforms() overriddenDescriptors.forEach { addOverrideLink(it, this) @@ -543,6 +557,7 @@ class DocumentationBuilder overriddenDescriptors.forEach { addOverrideLink(it, this) } + node.appendImplicitPlatforms() register(this, node) return node diff --git a/core/src/main/kotlin/Utilities/DokkaModules.kt b/core/src/main/kotlin/Utilities/DokkaModules.kt index 69facaa0..3352a846 100644 --- a/core/src/main/kotlin/Utilities/DokkaModules.kt +++ b/core/src/main/kotlin/Utilities/DokkaModules.kt @@ -3,6 +3,7 @@ package org.jetbrains.dokka.Utilities import com.google.inject.Binder import com.google.inject.Module import com.google.inject.Provider +import com.google.inject.TypeLiteral import com.google.inject.name.Names import org.jetbrains.dokka.* import org.jetbrains.dokka.Formats.FormatDescriptor @@ -12,6 +13,7 @@ import java.io.File class DokkaAnalysisModule(val environment: AnalysisEnvironment, val options: DocumentationOptions, + val implicitPlatforms: List<String>, val logger: DokkaLogger) : Module { override fun configure(binder: Binder) { val descriptor = ServiceLocator.lookup<FormatDescriptor>("format", options.outputFormat) @@ -29,9 +31,13 @@ class DokkaAnalysisModule(val environment: AnalysisEnvironment, binder.bind<DocumentationOptions>().toInstance(options) binder.bind<DokkaLogger>().toInstance(logger) + + binder.bind(StringListType).annotatedWith(Names.named(implicitPlatformName)).toInstance(implicitPlatforms) } } +object StringListType : TypeLiteral<@JvmSuppressWildcards List<String>>() + class DokkaOutputModule(val options: DocumentationOptions, val logger: DokkaLogger) : Module { override fun configure(binder: Binder) { |