1 package org.jetbrains.dokka 2 3 import ru.yole.jkid.CustomSerializer 4 import ru.yole.jkid.ValueSerializer 5 import ru.yole.jkid.deserialization.JKidException 6 import java.io.Serializable 7 import java.net.URL 8 9 10 class UrlSerializer : ValueSerializer<URL?> { fromJsonValuenull11 override fun fromJsonValue(jsonValue: Any?): URL? { 12 if (jsonValue !is String?) 13 throw JKidException("Expected string representation of URL, got: $jsonValue") 14 return jsonValue?.let { URL(jsonValue) } 15 } 16 toJsonValuenull17 override fun toJsonValue(value: URL?): Any? = value?.toExternalForm() 18 } 19 20 interface DokkaConfiguration { 21 val moduleName: String 22 val classpath: List<String> 23 val sourceRoots: List<SourceRoot> 24 val samples: List<String> 25 val includes: List<String> 26 val outputDir: String 27 val format: String 28 val includeNonPublic: Boolean 29 val includeRootPackage: Boolean 30 val reportUndocumented: Boolean 31 val skipEmptyPackages: Boolean 32 val skipDeprecated: Boolean 33 val jdkVersion: Int 34 val generateClassIndexPage: Boolean 35 val generatePackageIndexPage: Boolean 36 val sourceLinks: List<SourceLinkDefinition> 37 val impliedPlatforms: List<String> 38 val perPackageOptions: List<PackageOptions> 39 val externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink> 40 val languageVersion: String? 41 val apiVersion: String? 42 val noStdlibLink: Boolean 43 val noJdkLink: Boolean 44 val cacheRoot: String? 45 val suppressedFiles: List<String> 46 val collectInheritedExtensionsFromLibraries: Boolean 47 val outlineRoot: String 48 val dacRoot: String 49 50 interface SourceRoot { 51 val path: String 52 val platforms: List<String> 53 } 54 55 interface SourceLinkDefinition { 56 val path: String 57 val url: String 58 val lineSuffix: String? 59 } 60 61 interface PackageOptions { 62 val prefix: String 63 val includeNonPublic: Boolean 64 val reportUndocumented: Boolean 65 val skipDeprecated: Boolean 66 val suppress: Boolean 67 } 68 69 interface ExternalDocumentationLink { 70 @CustomSerializer(UrlSerializer::class) val url: URL 71 @CustomSerializer(UrlSerializer::class) val packageListUrl: URL 72 73 open class Builder(open var url: URL? = null, 74 open var packageListUrl: URL? = null) { 75 76 constructor(root: String, packageList: String? = null) : this(URL(root), packageList?.let { URL(it) }) 77 78 fun build(): DokkaConfiguration.ExternalDocumentationLink = 79 if (packageListUrl != null && url != null) 80 ExternalDocumentationLinkImpl(url!!, packageListUrl!!) 81 else if (url != null) 82 ExternalDocumentationLinkImpl(url!!, URL(url!!, "package-list")) 83 else 84 throw IllegalArgumentException("url or url && packageListUrl must not be null for external documentation link") 85 } 86 } 87 } 88 89 data class SerializeOnlyDokkaConfiguration( 90 override val moduleName: String, 91 override val classpath: List<String>, 92 override val sourceRoots: List<DokkaConfiguration.SourceRoot>, 93 override val samples: List<String>, 94 override val includes: List<String>, 95 override val outputDir: String, 96 override val format: String, 97 override val includeNonPublic: Boolean, 98 override val includeRootPackage: Boolean, 99 override val reportUndocumented: Boolean, 100 override val skipEmptyPackages: Boolean, 101 override val skipDeprecated: Boolean, 102 override val jdkVersion: Int, 103 override val generateClassIndexPage: Boolean, 104 override val generatePackageIndexPage: Boolean, 105 override val sourceLinks: List<DokkaConfiguration.SourceLinkDefinition>, 106 override val impliedPlatforms: List<String>, 107 override val perPackageOptions: List<DokkaConfiguration.PackageOptions>, 108 override val externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink>, 109 override val noStdlibLink: Boolean, 110 override val noJdkLink: Boolean, 111 override val cacheRoot: String?, 112 override val suppressedFiles: List<String>, 113 override val languageVersion: String?, 114 override val apiVersion: String?, 115 override val collectInheritedExtensionsFromLibraries: Boolean, 116 override val outlineRoot: String, 117 override val dacRoot: String 118 ) : DokkaConfiguration 119 120 121 data class ExternalDocumentationLinkImpl(@CustomSerializer(UrlSerializer::class) override val url: URL, 122 @CustomSerializer(UrlSerializer::class) override val packageListUrl: URL) : Serializable, DokkaConfiguration.ExternalDocumentationLink