1 package org.jetbrains.dokka
2
3 import org.jetbrains.dokka.DokkaConfiguration.PackageOptions
4 import ru.yole.jkid.deserialization.deserialize
5 import java.io.File
6 import java.util.function.BiConsumer
7
8
parsePerPackageOptionsnull9 fun parsePerPackageOptions(arg: String): List<PackageOptions> {
10 if (arg.isBlank()) return emptyList()
11
12 return arg.split(";").map { it.split(",") }.map {
13 val prefix = it.first()
14 if (prefix == "")
15 throw IllegalArgumentException("Please do not register packageOptions with all match pattern, use global settings instead")
16 val args = it.subList(1, it.size)
17 val deprecated = args.find { it.endsWith("deprecated") }?.startsWith("+") ?: true
18 val reportUndocumented = args.find { it.endsWith("warnUndocumented") }?.startsWith("+") ?: true
19 val privateApi = args.find { it.endsWith("privateApi") }?.startsWith("+") ?: false
20 val suppress = args.find { it.endsWith("suppress") }?.startsWith("+") ?: false
21 PackageOptionsImpl(prefix, includeNonPublic = privateApi, reportUndocumented = reportUndocumented, skipDeprecated = !deprecated, suppress = suppress)
22 }
23 }
24
25 class DokkaBootstrapImpl : DokkaBootstrap {
26
27 private class DokkaProxyLogger(val consumer: BiConsumer<String, String>) : DokkaLogger {
infonull28 override fun info(message: String) {
29 consumer.accept("info", message)
30 }
31
warnnull32 override fun warn(message: String) {
33 consumer.accept("warn", message)
34 }
35
errornull36 override fun error(message: String) {
37 consumer.accept("error", message)
38 }
39 }
40
41 lateinit var generator: DokkaGenerator
42
configurenull43 override fun configure(logger: BiConsumer<String, String>, serializedConfigurationJSON: String)
44 = configure(DokkaProxyLogger(logger), deserialize<DokkaConfigurationImpl>(serializedConfigurationJSON))
45
46 fun configure(logger: DokkaLogger, configuration: DokkaConfiguration) = with(configuration) {
47 generator = DokkaGenerator(
48 logger,
49 classpath,
50 sourceRoots,
51 samples,
52 includes,
53 moduleName,
54 DocumentationOptions(
55 outputDir = outputDir,
56 outputFormat = format,
57 includeNonPublic = includeNonPublic,
58 includeRootPackage = includeRootPackage,
59 reportUndocumented = reportUndocumented,
60 skipEmptyPackages = skipEmptyPackages,
61 skipDeprecated = skipDeprecated,
62 jdkVersion = jdkVersion,
63 generateClassIndexPage = generateClassIndexPage,
64 generatePackageIndexPage = generatePackageIndexPage,
65 sourceLinks = sourceLinks,
66 impliedPlatforms = impliedPlatforms,
67 perPackageOptions = perPackageOptions,
68 externalDocumentationLinks = externalDocumentationLinks,
69 noStdlibLink = noStdlibLink,
70 noJdkLink = noJdkLink,
71 languageVersion = languageVersion,
72 apiVersion = apiVersion,
73 cacheRoot = cacheRoot,
74 suppressedFiles = suppressedFiles.map { File(it) }.toSet(),
75 collectInheritedExtensionsFromLibraries = collectInheritedExtensionsFromLibraries,
76 outlineRoot = outlineRoot,
77 dacRoot = dacRoot
78 )
79 )
80 }
81
generatenull82 override fun generate() = generator.generate()
83 }