Skip to content

Commit 5866935

Browse files
authored
Add dokka to generate documentation for the project (#56)
1 parent 6fa794f commit 5866935

39 files changed

+195
-119
lines changed

build.gradle.kts

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
*/
1616

1717
import com.android.build.gradle.internal.tasks.factory.dependsOn
18-
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
18+
import org.jetbrains.dokka.gradle.DokkaTask
1919

2020
plugins {
21-
id("com.github.ben-manes.versions") version "0.28.0"
22-
id("io.gitlab.arturbosch.detekt") version "1.9.1"
21+
id("io.gitlab.arturbosch.detekt") version "1.10.0"
2322
id("com.appmattus.markdown") version "0.6.0"
23+
id("org.jetbrains.dokka") version "0.10.1"
2424
}
2525

2626
buildscript {
@@ -34,6 +34,7 @@ buildscript {
3434
}
3535
}
3636

37+
apply(from = "$rootDir/gradle/scripts/dependencyUpdates.gradle.kts")
3738
apply(from = "$rootDir/owaspDependencyCheck.gradle.kts")
3839
apply<JacocoPlugin>()
3940

@@ -50,24 +51,8 @@ task("clean", type = Delete::class) {
5051
delete(rootProject.buildDir)
5152
}
5253

53-
tasks.withType(DependencyUpdatesTask::class.java).all {
54-
resolutionStrategy {
55-
componentSelection {
56-
all {
57-
val rejected = listOf("alpha", "beta", "rc", "cr", "m", "preview")
58-
.map { qualifier -> Regex("(?i).*[.-]$qualifier[.\\d-]*") }
59-
.any { it.matches(candidate.version) }
60-
61-
if (rejected) {
62-
reject("Release candidate")
63-
}
64-
}
65-
}
66-
}
67-
}
68-
6954
dependencies {
70-
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.9.1")
55+
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.10.0")
7156
}
7257

7358
detekt {
@@ -95,7 +80,29 @@ val jacocoTestReport by tasks.registering(JacocoReport::class) {
9580
}
9681
}
9782

98-
tasks.register("check").dependsOn(jacocoTestReport)
83+
val dokka = tasks.named<DokkaTask>("dokka") {
84+
outputFormat = "html"
85+
outputDirectory = "$buildDir/reports/dokka"
86+
87+
subProjects = listOf(
88+
"fixture",
89+
"fixture-generex",
90+
"fixture-javafaker",
91+
"fixture-kotest"
92+
)
93+
94+
configuration {
95+
skipDeprecated = true
96+
97+
sourceLink {
98+
path = "$rootDir"
99+
url = "https://github.com/appmattus/kotlinfixture/blob/master/"
100+
lineSuffix = "#L"
101+
}
102+
}
103+
}
104+
105+
tasks.register("check").dependsOn(jacocoTestReport).dependsOn(dokka)
99106

100107
subprojects {
101108
plugins.withType<JacocoPlugin> {

fixture-android-tests/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ dependencies {
5858
testImplementation("androidx.test:core:1.2.0")
5959
testImplementation("androidx.test:runner:1.2.0")
6060
testImplementation("androidx.test.ext:junit:1.1.1")
61-
testImplementation("org.robolectric:robolectric:4.3.1")
61+
testImplementation("org.robolectric:robolectric:4.3.1") {
62+
exclude(group = "com.google.auto.service", module = "auto-service")
63+
}
6264

6365
testImplementation("junit:junit:4.13")
6466
testImplementation(kotlin("test"))

fixture-generex/src/main/kotlin/com/appmattus/kotlinfixture/config/GeneratorString.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package com.appmattus.kotlinfixture.config
1919
import com.mifmif.common.regex.Generex
2020

2121
/**
22-
* # Generate a random string from a regular expression
22+
* Generate a random string from a regular expression
2323
*
2424
* ```
2525
* data class DataClass(val index: String, val value: String)
@@ -45,7 +45,7 @@ fun Generator<String>.regexToRandom(regex: String, minLength: Int = 1, maxLength
4545
}
4646

4747
/**
48-
* # Generate a random string from a regular expression
48+
* Generate a random string from a regular expression
4949
*
5050
* ```
5151
* data class DataClass(val index: String, val value: String)

fixture-javafaker/src/main/kotlin/com/appmattus/kotlinfixture/decorator/fake/javafaker/JavaFakerConfiguration.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import java.time.temporal.ChronoUnit
3030
import java.util.Locale
3131

3232
/**
33-
* Configuration for the [JavaFakerStrategy]
33+
* Configuration for the JavaFakerStrategy
3434
*/
3535
data class JavaFakerConfiguration internal constructor(
3636
internal val creditCard: CreditCard = CreditCard.Any,
@@ -235,7 +235,7 @@ data class JavaFakerConfiguration internal constructor(
235235
}
236236

237237
/**
238-
* # Fake object generation with `javaFakerStrategy`
238+
* Fake object generation with `javaFakerStrategy`
239239
*
240240
* The faker intercepts the generation of named properties so their values can be replaced with fake data generated by
241241
* the [Java Faker](https://github.com/DiUS/java-faker) library

fixture-kotest/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ apply(from = "$rootDir/gradle/scripts/jacoco.gradle.kts")
2727
dependencies {
2828
api(kotlin("stdlib-jdk8"))
2929
api(project(":fixture"))
30-
api("io.kotest:kotest-property-jvm:4.0.6")
30+
api("io.kotest:kotest-property-jvm:4.1.1")
3131

3232
testImplementation("junit:junit:4.13")
3333
testImplementation(kotlin("test"))

fixture-kotest/src/main/kotlin/com/appmattus/kotlinfixture/kotest/ForAllExt.kt

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import io.kotest.property.internal.proptest
2929
// 1 parameter
3030

3131
/**
32-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
32+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
3333
*/
3434
suspend inline fun <reified A> Fixture.forAll(
3535
crossinline function: suspend PropertyContext.(a: A) -> Boolean
@@ -38,7 +38,7 @@ suspend inline fun <reified A> Fixture.forAll(
3838
}
3939

4040
/**
41-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
41+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
4242
*/
4343
suspend inline fun <reified A> Fixture.forAll(
4444
iterations: Int,
@@ -48,7 +48,7 @@ suspend inline fun <reified A> Fixture.forAll(
4848
}
4949

5050
/**
51-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
51+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
5252
*/
5353
suspend inline fun <reified A> Fixture.forAll(
5454
config: PropTestConfig,
@@ -58,7 +58,7 @@ suspend inline fun <reified A> Fixture.forAll(
5858
}
5959

6060
/**
61-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
61+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
6262
*/
6363
suspend inline fun <reified A> Fixture.forAll(
6464
iterations: Int,
@@ -71,30 +71,30 @@ suspend inline fun <reified A> Fixture.forAll(
7171
// 2 parameters
7272

7373
/**
74-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
74+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
7575
*/
7676
suspend inline fun <reified A, reified B> Fixture.forAll(
7777
noinline function: suspend PropertyContext.(a: A, b: B) -> Boolean
7878
) = forAll(kotestGen(), kotestGen(), function)
7979

8080
/**
81-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
81+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
8282
*/
8383
suspend inline fun <reified A, reified B> Fixture.forAll(
8484
iterations: Int,
8585
noinline function: suspend PropertyContext.(a: A, b: B) -> Boolean
8686
) = forAll(iterations, kotestGen(), kotestGen(), function)
8787

8888
/**
89-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
89+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
9090
*/
9191
suspend inline fun <reified A, reified B> Fixture.forAll(
9292
config: PropTestConfig,
9393
noinline function: suspend PropertyContext.(a: A, b: B) -> Boolean
9494
) = forAll(config, kotestGen(), kotestGen(), function)
9595

9696
/**
97-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
97+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
9898
*/
9999
suspend inline fun <reified A, reified B> Fixture.forAll(
100100
iterations: Int,
@@ -105,30 +105,30 @@ suspend inline fun <reified A, reified B> Fixture.forAll(
105105
// 3 parameters
106106

107107
/**
108-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
108+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
109109
*/
110110
suspend inline fun <reified A, reified B, reified C> Fixture.forAll(
111111
noinline function: suspend PropertyContext.(a: A, b: B, c: C) -> Boolean
112112
) = forAll(kotestGen(), kotestGen(), kotestGen(), function)
113113

114114
/**
115-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
115+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
116116
*/
117117
suspend inline fun <reified A, reified B, reified C> Fixture.forAll(
118118
iterations: Int,
119119
noinline function: suspend PropertyContext.(a: A, b: B, c: C) -> Boolean
120120
) = forAll(iterations, kotestGen(), kotestGen(), kotestGen(), function)
121121

122122
/**
123-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
123+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
124124
*/
125125
suspend inline fun <reified A, reified B, reified C> Fixture.forAll(
126126
config: PropTestConfig,
127127
noinline function: suspend PropertyContext.(a: A, b: B, c: C) -> Boolean
128128
) = forAll(config, kotestGen(), kotestGen(), kotestGen(), function)
129129

130130
/**
131-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
131+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
132132
*/
133133
suspend inline fun <reified A, reified B, reified C> Fixture.forAll(
134134
iterations: Int,
@@ -139,30 +139,30 @@ suspend inline fun <reified A, reified B, reified C> Fixture.forAll(
139139
// 4 parameters
140140

141141
/**
142-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
142+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
143143
*/
144144
suspend inline fun <reified A, reified B, reified C, reified D> Fixture.forAll(
145145
noinline function: suspend PropertyContext.(a: A, b: B, c: C, d: D) -> Boolean
146146
) = forAll(kotestGen(), kotestGen(), kotestGen(), kotestGen(), function)
147147

148148
/**
149-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
149+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
150150
*/
151151
suspend inline fun <reified A, reified B, reified C, reified D> Fixture.forAll(
152152
iterations: Int,
153153
noinline function: suspend PropertyContext.(a: A, b: B, c: C, d: D) -> Boolean
154154
) = forAll(iterations, kotestGen(), kotestGen(), kotestGen(), kotestGen(), function)
155155

156156
/**
157-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
157+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
158158
*/
159159
suspend inline fun <reified A, reified B, reified C, reified D> Fixture.forAll(
160160
config: PropTestConfig,
161161
noinline function: suspend PropertyContext.(a: A, b: B, c: C, d: D) -> Boolean
162162
) = forAll(config, kotestGen(), kotestGen(), kotestGen(), kotestGen(), function)
163163

164164
/**
165-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
165+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
166166
*/
167167
suspend inline fun <reified A, reified B, reified C, reified D> Fixture.forAll(
168168
iterations: Int,
@@ -173,30 +173,30 @@ suspend inline fun <reified A, reified B, reified C, reified D> Fixture.forAll(
173173
// 5 parameters
174174

175175
/**
176-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
176+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
177177
*/
178178
suspend inline fun <reified A, reified B, reified C, reified D, reified E> Fixture.forAll(
179179
noinline function: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E) -> Boolean
180180
) = forAll(kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), function)
181181

182182
/**
183-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
183+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
184184
*/
185185
suspend inline fun <reified A, reified B, reified C, reified D, reified E> Fixture.forAll(
186186
iterations: Int,
187187
noinline function: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E) -> Boolean
188188
) = forAll(iterations, kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), function)
189189

190190
/**
191-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
191+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
192192
*/
193193
suspend inline fun <reified A, reified B, reified C, reified D, reified E> Fixture.forAll(
194194
config: PropTestConfig,
195195
noinline function: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E) -> Boolean
196196
) = forAll(config, kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), function)
197197

198198
/**
199-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
199+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
200200
*/
201201
suspend inline fun <reified A, reified B, reified C, reified D, reified E> Fixture.forAll(
202202
iterations: Int,
@@ -207,30 +207,30 @@ suspend inline fun <reified A, reified B, reified C, reified D, reified E> Fixtu
207207
// 6 parameters
208208

209209
/**
210-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
210+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
211211
*/
212212
suspend inline fun <reified A, reified B, reified C, reified D, reified E, reified F> Fixture.forAll(
213213
noinline function: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F) -> Boolean
214214
) = forAll(kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), function)
215215

216216
/**
217-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
217+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
218218
*/
219219
suspend inline fun <reified A, reified B, reified C, reified D, reified E, reified F> Fixture.forAll(
220220
iterations: Int,
221221
noinline function: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F) -> Boolean
222222
) = forAll(iterations, kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), function)
223223

224224
/**
225-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
225+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
226226
*/
227227
suspend inline fun <reified A, reified B, reified C, reified D, reified E, reified F> Fixture.forAll(
228228
config: PropTestConfig,
229229
noinline function: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F) -> Boolean
230230
) = forAll(config, kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), function)
231231

232232
/**
233-
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true [forAll].
233+
* Use [Fixture] to generate random objects for type parameters and validate the [function] returns true `forAll`.
234234
*/
235235
suspend inline fun <reified A, reified B, reified C, reified D, reified E, reified F> Fixture.forAll(
236236
iterations: Int,

fixture-kotest/src/main/kotlin/com/appmattus/kotlinfixture/kotest/KotestGenerator.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ import io.kotest.property.arbitrary.arb
2222

2323
/**
2424
* Creates a new [Arb] that performs no shrinking, and generates values for the given type, [T].
25+
* @suppress
2526
*/
2627
inline fun <reified T> Fixture.kotestGen() = arb { asSequence<T>() }

fixture/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ apply(from = "$rootDir/gradle/scripts/jacoco.gradle.kts")
2626

2727
dependencies {
2828
api(kotlin("stdlib-jdk8"))
29-
api("io.github.classgraph:classgraph:4.8.80")
29+
api("io.github.classgraph:classgraph:4.8.87")
3030
api(kotlin("reflect"))
3131

3232
compileOnly("joda-time:joda-time:2.10.6")

fixture/src/main/kotlin/com/appmattus/kotlinfixture/Context.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ interface Context {
3939

4040
/**
4141
* Return the configuration for a given strategy or [default] if none is found
42+
* @suppress
4243
*/
4344
inline fun <reified T> Context.strategyOrDefault(default: T): T = configuration.strategies[T::class] as? T ?: default

fixture/src/main/kotlin/com/appmattus/kotlinfixture/KotlinFixture.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class Fixture @JvmOverloads constructor(val fixtureConfiguration: Configuration
9696
}
9797

9898
/**
99-
* Create a [Fixture] with configuration
99+
* Create a [Fixture] with [configuration]
100100
*/
101-
fun kotlinFixture(init: ConfigurationBuilder.() -> Unit = {}) = Fixture(ConfigurationBuilder().apply(init).build())
101+
fun kotlinFixture(configuration: ConfigurationBuilder.() -> Unit = {}) =
102+
Fixture(ConfigurationBuilder().apply(configuration).build())

0 commit comments

Comments
 (0)