forked from detekt/detekt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RuleConfigurationPrinter.kt
43 lines (40 loc) · 1.7 KB
/
RuleConfigurationPrinter.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package io.gitlab.arturbosch.detekt.generator.printer
import io.github.detekt.utils.bold
import io.github.detekt.utils.code
import io.github.detekt.utils.crossOut
import io.github.detekt.utils.description
import io.github.detekt.utils.h4
import io.github.detekt.utils.item
import io.github.detekt.utils.list
import io.github.detekt.utils.markdown
import io.gitlab.arturbosch.detekt.generator.collection.Configuration
internal object RuleConfigurationPrinter : DocumentationPrinter<List<Configuration>> {
override fun print(item: List<Configuration>): String {
if (item.isEmpty()) return ""
return markdown {
h4 { "Configuration options:" }
list {
item.forEach {
val defaultValues = it.defaultValue.printAsMarkdownCode()
val defaultAndroidValues = it.defaultAndroidValue?.printAsMarkdownCode()
val defaultString = if (defaultAndroidValues != null) {
"(default: ${code { defaultValues }}) (android default: ${code { defaultAndroidValues }})"
} else {
"(default: ${code { defaultValues }})"
}
if (it.isDeprecated()) {
item {
crossOut { code { it.name } } + " " + defaultString
}
description { "${bold { "Deprecated" }}: ${it.deprecated}" }
} else {
item {
code { it.name } + " " + defaultString
}
}
description { it.description }
}
}
}
}
}