Skip to content

Commit 02f30b1

Browse files
Enable explicit API mode (#3139)
1 parent 6a181a7 commit 02f30b1

File tree

311 files changed

+3158
-2578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

311 files changed

+3158
-2578
lines changed

build-logic/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package org.jetbrains.conventions
66

77
import org.jetbrains.configureDokkaVersion
8+
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
89
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
910

1011
plugins {
@@ -14,25 +15,44 @@ plugins {
1415

1516
configureDokkaVersion()
1617

17-
val projectsWithoutOptInDependency = setOf(
18-
":integration-tests", ":integration-tests:gradle", ":integration-tests:maven", ":integration-tests:cli")
18+
kotlin {
19+
explicitApi = ExplicitApiMode.Strict
20+
21+
compilerOptions {
22+
allWarningsAsErrors.set(true)
23+
languageVersion.set(dokkaBuild.kotlinLanguageLevel)
24+
apiVersion.set(dokkaBuild.kotlinLanguageLevel)
25+
26+
freeCompilerArgs.addAll(
27+
listOf(
28+
// need 1.4 support, otherwise there might be problems
29+
// with Gradle 6.x (it's bundling Kotlin 1.4)
30+
"-Xsuppress-version-warnings",
31+
"-Xjsr305=strict",
32+
"-Xskip-metadata-version-check",
33+
)
34+
)
35+
}
36+
}
37+
38+
val projectsWithoutInternalDokkaApiUsage = setOf(
39+
":integration-tests",
40+
":integration-tests:gradle",
41+
":integration-tests:maven",
42+
":integration-tests:cli"
43+
)
1944

2045
tasks.withType<KotlinCompile>().configureEach {
2146
// By path because Dokka has multiple projects with the same name (i.e. 'cli')
22-
if (project.path in projectsWithoutOptInDependency) return@configureEach
47+
if (project.path in projectsWithoutInternalDokkaApiUsage) {
48+
return@configureEach
49+
}
2350
compilerOptions {
2451
freeCompilerArgs.addAll(
2552
listOf(
2653
"-opt-in=kotlin.RequiresOptIn",
2754
"-opt-in=org.jetbrains.dokka.InternalDokkaApi",
28-
"-Xjsr305=strict",
29-
"-Xskip-metadata-version-check",
30-
// need 1.4 support, otherwise there might be problems with Gradle 6.x (it's bundling Kotlin 1.4)
31-
"-Xsuppress-version-warnings",
3255
)
3356
)
34-
allWarningsAsErrors.set(true)
35-
languageVersion.set(dokkaBuild.kotlinLanguageLevel)
36-
apiVersion.set(dokkaBuild.kotlinLanguageLevel)
3757
}
3858
}

core/api/core.api

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ public final class org/jetbrains/dokka/model/ActualTypealias : org/jetbrains/dok
658658

659659
public final class org/jetbrains/dokka/model/ActualTypealias$Companion : org/jetbrains/dokka/model/properties/ExtraProperty$Key {
660660
public synthetic fun mergeStrategyFor (Ljava/lang/Object;Ljava/lang/Object;)Lorg/jetbrains/dokka/model/properties/MergeStrategy;
661-
public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/ActualTypealias;Lorg/jetbrains/dokka/model/ActualTypealias;)Lorg/jetbrains/dokka/model/properties/MergeStrategy$Fail;
661+
public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/ActualTypealias;Lorg/jetbrains/dokka/model/ActualTypealias;)Lorg/jetbrains/dokka/model/properties/MergeStrategy;
662662
}
663663

664664
public final class org/jetbrains/dokka/model/AdditionalExtrasKt {
@@ -817,7 +817,7 @@ public final class org/jetbrains/dokka/model/CheckedExceptions : org/jetbrains/d
817817

818818
public final class org/jetbrains/dokka/model/CheckedExceptions$Companion : org/jetbrains/dokka/model/properties/ExtraProperty$Key {
819819
public synthetic fun mergeStrategyFor (Ljava/lang/Object;Ljava/lang/Object;)Lorg/jetbrains/dokka/model/properties/MergeStrategy;
820-
public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/CheckedExceptions;Lorg/jetbrains/dokka/model/CheckedExceptions;)Lorg/jetbrains/dokka/model/properties/MergeStrategy$Replace;
820+
public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/CheckedExceptions;Lorg/jetbrains/dokka/model/CheckedExceptions;)Lorg/jetbrains/dokka/model/properties/MergeStrategy;
821821
}
822822

823823
public abstract interface class org/jetbrains/dokka/model/ClassKind {
@@ -1505,7 +1505,7 @@ public final class org/jetbrains/dokka/model/ExceptionInSupertypes : org/jetbrai
15051505

15061506
public final class org/jetbrains/dokka/model/ExceptionInSupertypes$Companion : org/jetbrains/dokka/model/properties/ExtraProperty$Key {
15071507
public synthetic fun mergeStrategyFor (Ljava/lang/Object;Ljava/lang/Object;)Lorg/jetbrains/dokka/model/properties/MergeStrategy;
1508-
public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/ExceptionInSupertypes;Lorg/jetbrains/dokka/model/ExceptionInSupertypes;)Lorg/jetbrains/dokka/model/properties/MergeStrategy$Replace;
1508+
public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/ExceptionInSupertypes;Lorg/jetbrains/dokka/model/ExceptionInSupertypes;)Lorg/jetbrains/dokka/model/properties/MergeStrategy;
15091509
}
15101510

15111511
public abstract interface class org/jetbrains/dokka/model/Expression {
@@ -1707,7 +1707,7 @@ public final class org/jetbrains/dokka/model/ImplementedInterfaces : org/jetbrai
17071707

17081708
public final class org/jetbrains/dokka/model/ImplementedInterfaces$Companion : org/jetbrains/dokka/model/properties/ExtraProperty$Key {
17091709
public synthetic fun mergeStrategyFor (Ljava/lang/Object;Ljava/lang/Object;)Lorg/jetbrains/dokka/model/properties/MergeStrategy;
1710-
public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/ImplementedInterfaces;Lorg/jetbrains/dokka/model/ImplementedInterfaces;)Lorg/jetbrains/dokka/model/properties/MergeStrategy$Replace;
1710+
public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/ImplementedInterfaces;Lorg/jetbrains/dokka/model/ImplementedInterfaces;)Lorg/jetbrains/dokka/model/properties/MergeStrategy;
17111711
}
17121712

17131713
public final class org/jetbrains/dokka/model/InheritedMember : org/jetbrains/dokka/model/properties/ExtraProperty {
@@ -1726,7 +1726,7 @@ public final class org/jetbrains/dokka/model/InheritedMember : org/jetbrains/dok
17261726

17271727
public final class org/jetbrains/dokka/model/InheritedMember$Companion : org/jetbrains/dokka/model/properties/ExtraProperty$Key {
17281728
public synthetic fun mergeStrategyFor (Ljava/lang/Object;Ljava/lang/Object;)Lorg/jetbrains/dokka/model/properties/MergeStrategy;
1729-
public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/InheritedMember;Lorg/jetbrains/dokka/model/InheritedMember;)Lorg/jetbrains/dokka/model/properties/MergeStrategy$Replace;
1729+
public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/InheritedMember;Lorg/jetbrains/dokka/model/InheritedMember;)Lorg/jetbrains/dokka/model/properties/MergeStrategy;
17301730
}
17311731

17321732
public final class org/jetbrains/dokka/model/IntValue : org/jetbrains/dokka/model/LiteralValue {
@@ -4103,8 +4103,7 @@ public final class org/jetbrains/dokka/pages/MultimoduleRootPageNode : org/jetbr
41034103
public fun getName ()Ljava/lang/String;
41044104
public synthetic fun modified (Ljava/lang/String;Ljava/util/List;)Lorg/jetbrains/dokka/pages/PageNode;
41054105
public fun modified (Ljava/lang/String;Ljava/util/List;)Lorg/jetbrains/dokka/pages/RootPageNode;
4106-
public synthetic fun modified (Ljava/lang/String;Lorg/jetbrains/dokka/pages/ContentNode;Ljava/util/Set;Ljava/util/List;Ljava/util/List;)Lorg/jetbrains/dokka/pages/ContentPage;
4107-
public fun modified (Ljava/lang/String;Lorg/jetbrains/dokka/pages/ContentNode;Ljava/util/Set;Ljava/util/List;Ljava/util/List;)Lorg/jetbrains/dokka/pages/MultimoduleRootPageNode;
4106+
public fun modified (Ljava/lang/String;Lorg/jetbrains/dokka/pages/ContentNode;Ljava/util/Set;Ljava/util/List;Ljava/util/List;)Lorg/jetbrains/dokka/pages/ContentPage;
41084107
}
41094108

41104109
public final class org/jetbrains/dokka/pages/MultimoduleTable : org/jetbrains/dokka/pages/Style {
@@ -4166,7 +4165,7 @@ public final class org/jetbrains/dokka/pages/PlatformHintedContent : org/jetbrai
41664165
public synthetic fun transformChildren (Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/dokka/pages/ContentComposite;
41674166
public fun transformChildren (Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/dokka/pages/PlatformHintedContent;
41684167
public synthetic fun withNewExtras (Lorg/jetbrains/dokka/model/properties/PropertyContainer;)Ljava/lang/Object;
4169-
public fun withNewExtras (Lorg/jetbrains/dokka/model/properties/PropertyContainer;)Ljava/lang/Void;
4168+
public fun withNewExtras (Lorg/jetbrains/dokka/model/properties/PropertyContainer;)Lorg/jetbrains/dokka/pages/ContentNode;
41704169
public synthetic fun withSourceSets (Ljava/util/Set;)Lorg/jetbrains/dokka/pages/ContentNode;
41714170
public fun withSourceSets (Ljava/util/Set;)Lorg/jetbrains/dokka/pages/PlatformHintedContent;
41724171
}

core/content-matcher-test-utils/src/main/kotlin/matchers/content/ContentMatchersDsl.kt

Lines changed: 77 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import kotlin.test.assertEquals
1212
import kotlin.test.asserter
1313

1414
// entry point:
15-
fun ContentNode.assertNode(block: ContentMatcherBuilder<ContentComposite>.() -> Unit) {
15+
public fun ContentNode.assertNode(block: ContentMatcherBuilder<ContentComposite>.() -> Unit) {
1616
val matcher = ContentMatcherBuilder(ContentComposite::class).apply(block).build()
1717
try {
1818
matcher.tryMatch(this)
@@ -24,123 +24,161 @@ fun ContentNode.assertNode(block: ContentMatcherBuilder<ContentComposite>.() ->
2424

2525
// DSL:
2626
@DslMarker
27-
annotation class ContentMatchersDsl
27+
public annotation class ContentMatchersDsl
2828

2929
@ContentMatchersDsl
30-
class ContentMatcherBuilder<T : ContentComposite> @PublishedApi internal constructor(private val kclass: KClass<T>) {
30+
public class ContentMatcherBuilder<T : ContentComposite> @PublishedApi internal constructor(private val kclass: KClass<T>) {
3131
@PublishedApi
32-
internal val children = mutableListOf<MatcherElement>()
32+
internal val children: MutableList<MatcherElement> = mutableListOf()
3333
internal val assertions = mutableListOf<T.() -> Unit>()
3434

35-
fun build() = CompositeMatcher(kclass, childrenOrSkip()) { assertions.forEach { it() } }
35+
public fun build(): CompositeMatcher<T> = CompositeMatcher(kclass, childrenOrSkip()) { assertions.forEach { it() } }
3636

3737
// part of DSL that cannot be defined as an extension
38-
operator fun String.unaryPlus() {
38+
public operator fun String.unaryPlus() {
3939
children += TextMatcher(this)
4040
}
4141

4242
private fun childrenOrSkip() = if (children.isEmpty() && assertions.isNotEmpty()) listOf(Anything) else children
4343
}
4444

45-
fun <T : ContentComposite> ContentMatcherBuilder<T>.check(assertion: T.() -> Unit) {
45+
public fun <T : ContentComposite> ContentMatcherBuilder<T>.check(assertion: T.() -> Unit) {
4646
assertions += assertion
4747
}
4848

4949
private val ContentComposite.extractedText
5050
get() = withDescendants().filterIsInstance<ContentText>().joinToString(separator = "") { it.text }
5151

52-
fun <T : ContentComposite> ContentMatcherBuilder<T>.hasExactText(expected: String) {
52+
public fun <T : ContentComposite> ContentMatcherBuilder<T>.hasExactText(expected: String) {
5353
assertions += {
5454
assertEquals(expected, this.extractedText)
5555
}
5656
}
5757

58-
inline fun <reified S : ContentComposite> ContentMatcherBuilder<*>.composite(
58+
public inline fun <reified S : ContentComposite> ContentMatcherBuilder<*>.composite(
5959
block: ContentMatcherBuilder<S>.() -> Unit
6060
) {
6161
children += ContentMatcherBuilder(S::class).apply(block).build()
6262
}
6363

64-
inline fun <reified S : ContentNode> ContentMatcherBuilder<*>.node(noinline assertions: S.() -> Unit = {}) {
64+
public inline fun <reified S : ContentNode> ContentMatcherBuilder<*>.node(noinline assertions: S.() -> Unit = {}) {
6565
children += NodeMatcher(S::class, assertions)
6666
}
6767

68-
fun ContentMatcherBuilder<*>.skipAllNotMatching() {
68+
public fun ContentMatcherBuilder<*>.skipAllNotMatching() {
6969
children += Anything
7070
}
7171

7272

7373
// Convenience functions:
74-
fun ContentMatcherBuilder<*>.group(block: ContentMatcherBuilder<ContentGroup>.() -> Unit) = composite(block)
74+
public fun ContentMatcherBuilder<*>.group(block: ContentMatcherBuilder<ContentGroup>.() -> Unit) {
75+
composite(block)
76+
}
7577

76-
fun ContentMatcherBuilder<*>.tabbedGroup(
78+
public fun ContentMatcherBuilder<*>.tabbedGroup(
7779
block: ContentMatcherBuilder<ContentGroup>.() -> Unit
78-
) = composite<ContentGroup> {
79-
block()
80-
check { assertContains(this.style, ContentStyle.TabbedContent) }
80+
) {
81+
composite<ContentGroup> {
82+
block()
83+
check { assertContains(this.style, ContentStyle.TabbedContent) }
84+
}
8185
}
8286

83-
fun ContentMatcherBuilder<*>.tab(
87+
public fun ContentMatcherBuilder<*>.tab(
8488
tabbedContentType: TabbedContentType, block: ContentMatcherBuilder<ContentGroup>.() -> Unit
85-
) = composite<ContentGroup> {
86-
block()
87-
check {
88-
assertEquals(tabbedContentType, this.extra[TabbedContentTypeExtra]?.value)
89+
) {
90+
composite<ContentGroup> {
91+
block()
92+
check {
93+
assertEquals(tabbedContentType, this.extra[TabbedContentTypeExtra]?.value)
94+
}
8995
}
9096
}
9197

92-
fun ContentMatcherBuilder<*>.header(expectedLevel: Int? = null, block: ContentMatcherBuilder<ContentHeader>.() -> Unit) =
98+
public fun ContentMatcherBuilder<*>.header(expectedLevel: Int? = null, block: ContentMatcherBuilder<ContentHeader>.() -> Unit) {
9399
composite<ContentHeader> {
94100
block()
95101
check { if (expectedLevel != null) assertEquals(expectedLevel, this.level) }
96102
}
103+
}
97104

98-
fun ContentMatcherBuilder<*>.p(block: ContentMatcherBuilder<ContentGroup>.() -> Unit) =
105+
public fun ContentMatcherBuilder<*>.p(block: ContentMatcherBuilder<ContentGroup>.() -> Unit) {
99106
composite<ContentGroup> {
100107
block()
101108
check { assertContains(this.style, TextStyle.Paragraph) }
102109
}
110+
}
103111

104-
fun ContentMatcherBuilder<*>.link(block: ContentMatcherBuilder<ContentLink>.() -> Unit) = composite(block)
112+
public fun ContentMatcherBuilder<*>.link(block: ContentMatcherBuilder<ContentLink>.() -> Unit) {
113+
composite(block)
114+
}
105115

106-
fun ContentMatcherBuilder<*>.table(block: ContentMatcherBuilder<ContentTable>.() -> Unit) = composite(block)
116+
public fun ContentMatcherBuilder<*>.table(block: ContentMatcherBuilder<ContentTable>.() -> Unit) {
117+
composite(block)
118+
}
107119

108-
fun ContentMatcherBuilder<*>.platformHinted(block: ContentMatcherBuilder<ContentGroup>.() -> Unit) =
120+
public fun ContentMatcherBuilder<*>.platformHinted(block: ContentMatcherBuilder<ContentGroup>.() -> Unit) {
109121
composite<PlatformHintedContent> { group(block) }
122+
}
110123

111-
fun ContentMatcherBuilder<*>.list(block: ContentMatcherBuilder<ContentList>.() -> Unit) = composite(block)
124+
public fun ContentMatcherBuilder<*>.list(block: ContentMatcherBuilder<ContentList>.() -> Unit) {
125+
composite(block)
126+
}
112127

113-
fun ContentMatcherBuilder<*>.codeBlock(block: ContentMatcherBuilder<ContentCodeBlock>.() -> Unit) = composite(block)
128+
public fun ContentMatcherBuilder<*>.codeBlock(block: ContentMatcherBuilder<ContentCodeBlock>.() -> Unit) {
129+
composite(block)
130+
}
114131

115-
fun ContentMatcherBuilder<*>.codeInline(block: ContentMatcherBuilder<ContentCodeInline>.() -> Unit) = composite(block)
132+
public fun ContentMatcherBuilder<*>.codeInline(block: ContentMatcherBuilder<ContentCodeInline>.() -> Unit) {
133+
composite(block)
134+
}
116135

117-
fun ContentMatcherBuilder<*>.caption(block: ContentMatcherBuilder<ContentGroup>.() -> Unit) = composite<ContentGroup> {
118-
block()
119-
check { assertContains(this.style, ContentStyle.Caption) }
136+
public fun ContentMatcherBuilder<*>.caption(block: ContentMatcherBuilder<ContentGroup>.() -> Unit) {
137+
composite<ContentGroup> {
138+
block()
139+
check { assertContains(this.style, ContentStyle.Caption) }
140+
}
120141
}
121142

122-
fun ContentMatcherBuilder<*>.br() = node<ContentBreakLine>()
143+
public fun ContentMatcherBuilder<*>.br() {
144+
node<ContentBreakLine>()
145+
}
123146

124-
fun ContentMatcherBuilder<*>.somewhere(block: ContentMatcherBuilder<*>.() -> Unit) {
147+
public fun ContentMatcherBuilder<*>.somewhere(block: ContentMatcherBuilder<*>.() -> Unit) {
125148
skipAllNotMatching()
126149
block()
127150
skipAllNotMatching()
128151
}
129152

130-
fun ContentMatcherBuilder<*>.divergentGroup(block: ContentMatcherBuilder<ContentDivergentGroup>.() -> Unit) =
153+
public fun ContentMatcherBuilder<*>.divergentGroup(
154+
block: ContentMatcherBuilder<ContentDivergentGroup>.() -> Unit
155+
) {
131156
composite(block)
157+
}
132158

133-
fun ContentMatcherBuilder<ContentDivergentGroup>.divergentInstance(block: ContentMatcherBuilder<ContentDivergentInstance>.() -> Unit) =
159+
public fun ContentMatcherBuilder<ContentDivergentGroup>.divergentInstance(
160+
block: ContentMatcherBuilder<ContentDivergentInstance>.() -> Unit
161+
) {
134162
composite(block)
163+
}
135164

136-
fun ContentMatcherBuilder<ContentDivergentInstance>.before(block: ContentMatcherBuilder<ContentComposite>.() -> Unit) =
165+
public fun ContentMatcherBuilder<ContentDivergentInstance>.before(
166+
block: ContentMatcherBuilder<ContentComposite>.() -> Unit
167+
) {
137168
composite(block)
169+
}
138170

139-
fun ContentMatcherBuilder<ContentDivergentInstance>.divergent(block: ContentMatcherBuilder<ContentComposite>.() -> Unit) =
171+
public fun ContentMatcherBuilder<ContentDivergentInstance>.divergent(
172+
block: ContentMatcherBuilder<ContentComposite>.() -> Unit
173+
) {
140174
composite(block)
175+
}
141176

142-
fun ContentMatcherBuilder<ContentDivergentInstance>.after(block: ContentMatcherBuilder<ContentComposite>.() -> Unit) =
177+
public fun ContentMatcherBuilder<ContentDivergentInstance>.after(
178+
block: ContentMatcherBuilder<ContentComposite>.() -> Unit
179+
) {
143180
composite(block)
181+
}
144182

145183
/*
146184
* TODO replace with kotlin.test.assertContains after migrating to Kotlin language version 1.5+

core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@ import kotlin.reflect.KClass
1414
import kotlin.reflect.full.cast
1515
import kotlin.reflect.full.safeCast
1616

17-
sealed class MatcherElement
17+
public sealed class MatcherElement
1818

19-
class TextMatcher(val text: String) : MatcherElement()
19+
public class TextMatcher(
20+
public val text: String
21+
) : MatcherElement()
2022

21-
open class NodeMatcher<T : ContentNode>(
22-
val kclass: KClass<T>,
23-
val assertions: T.() -> Unit = {}
23+
public open class NodeMatcher<T : ContentNode>(
24+
public val kclass: KClass<T>,
25+
public val assertions: T.() -> Unit = {}
2426
) : MatcherElement() {
25-
open fun tryMatch(node: ContentNode) {
27+
28+
public open fun tryMatch(node: ContentNode) {
2629
kclass.safeCast(node)?.apply {
2730
try {
2831
assertions()
@@ -37,11 +40,12 @@ open class NodeMatcher<T : ContentNode>(
3740
}
3841
}
3942

40-
class CompositeMatcher<T : ContentComposite>(
43+
public class CompositeMatcher<T : ContentComposite>(
4144
kclass: KClass<T>,
4245
private val children: List<MatcherElement>,
4346
assertions: T.() -> Unit = {}
4447
) : NodeMatcher<T>(kclass, assertions) {
48+
4549
internal val normalizedChildren: List<MatcherElement> by lazy {
4650
children.fold(listOf()) { acc, e ->
4751
when {
@@ -61,7 +65,7 @@ class CompositeMatcher<T : ContentComposite>(
6165
}
6266
}
6367

64-
object Anything : MatcherElement()
68+
public object Anything : MatcherElement()
6569

6670
private sealed class MatchWalkerState {
6771
abstract fun next(node: ContentNode): MatchWalkerState
@@ -176,7 +180,7 @@ private fun ContentNode.debugRepresentation() = asPrintableTree { element ->
176180
)
177181
}
178182

179-
data class MatcherError(
183+
public data class MatcherError(
180184
override val message: String,
181185
val anchor: MatcherElement,
182186
val anchorAfter: Boolean = false,

0 commit comments

Comments
 (0)