-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add global settings to JSON dokka cli input
- Loading branch information
1 parent
1f82c97
commit 0ae0222
Showing
12 changed files
with
365 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/jsonBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.jetbrains.dokka.it.cli | ||
|
||
fun jsonBuilder( | ||
outputPath: String, | ||
pluginsClasspath: String, | ||
projectPath: String, | ||
globalSourceLinks: String = "", | ||
globalExternalDocumentationLinks: String = "", | ||
globalPerPackageOptions: String = "", | ||
reportUndocumented: Boolean = false | ||
|
||
): String { | ||
return """{ | ||
"moduleName": "Dokka Example", | ||
"moduleVersion": null, | ||
"outputDir": "$outputPath", | ||
"pluginsClasspath": ["$pluginsClasspath"], | ||
"cacheRoot": null, | ||
"offlineMode": false, | ||
"sourceLinks": [$globalSourceLinks], | ||
"externalDocumentationLinks": [$globalExternalDocumentationLinks], | ||
"perPackageOptions": [$globalPerPackageOptions], | ||
"sourceSets": [ | ||
{ | ||
"displayName": "jvm", | ||
"sourceSetID": { | ||
"scopeId": ":dokkaHtml", | ||
"sourceSetName": "main" | ||
}, | ||
"sourceRoots": [ | ||
"$projectPath" | ||
], | ||
"dependentSourceSets": [], | ||
"samples": [], | ||
"includes": [], | ||
"includeNonPublic": false, | ||
"reportUndocumented": $reportUndocumented, | ||
"skipEmptyPackages": true, | ||
"skipDeprecated": false, | ||
"jdkVersion": 8, | ||
"sourceLinks": [], | ||
"perPackageOptions": [], | ||
"externalDocumentationLinks": [], | ||
"noStdlibLink": false, | ||
"noJdkLink": false, | ||
"suppressedFiles": [], | ||
"analysisPlatform": "jvm" | ||
} | ||
] | ||
} | ||
""" | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/ | ||
|
||
# Sample project | ||
|
||
Sample documentation with [external link](https://www.google.pl) | ||
|
||
## All modules: | ||
|
||
| Name | | ||
|---| |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.jetbrains.dokka | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator | ||
import com.fasterxml.jackson.databind.DeserializationFeature | ||
import com.fasterxml.jackson.databind.SerializerProvider | ||
import com.fasterxml.jackson.databind.module.SimpleModule | ||
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer | ||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | ||
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef | ||
import java.io.File | ||
|
||
// THIS IS COPIED FROM BASE SINCE IT NEEDS TO BE INSTANTIATED ON THE SAME CLASS LOADER AS PLUGINS | ||
|
||
private val objectMapper = run { | ||
val module = SimpleModule().apply { | ||
addSerializer(FileSerializer) | ||
} | ||
jacksonObjectMapper() | ||
.registerModule(module) | ||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) | ||
} | ||
|
||
@PublishedApi | ||
internal class TypeReference<T> private constructor( | ||
internal val jackson: com.fasterxml.jackson.core.type.TypeReference<T> | ||
) { | ||
companion object { | ||
internal inline operator fun <reified T> invoke(): TypeReference<T> = TypeReference(jacksonTypeRef()) | ||
} | ||
} | ||
|
||
inline fun <reified T : Any> parseJson(json: String): T = parseJson(json, TypeReference()) | ||
|
||
@PublishedApi | ||
internal fun <T : Any> parseJson(json: String, typeReference: TypeReference<T>): T = | ||
objectMapper.readValue(json, typeReference.jackson) | ||
|
||
private object FileSerializer : StdScalarSerializer<File>(File::class.java) { | ||
override fun serialize(value: File, g: JsonGenerator, provider: SerializerProvider) { | ||
g.writeString(value.path) | ||
} | ||
} | ||
|
||
data class GlobalDokkaConfiguration( | ||
val perPackageOptions: List<PackageOptionsImpl>?, | ||
val externalDocumentationLinks: List<ExternalDocumentationLinkImpl>?, | ||
val sourceLinks: List<SourceLinkDefinitionImpl>? | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.