Skip to content

Commit 09d4e21

Browse files
Adam review
1 parent 3c97360 commit 09d4e21

File tree

1 file changed

+49
-37
lines changed

1 file changed

+49
-37
lines changed

docs/topics/dokka-migration.md

+49-37
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Alternatively,
5151
you can use [version catalog](https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog)
5252
to enable the Dokka Gradle plugin v2.
5353

54-
> By default, the DGP v2 generates HTML documentation. To generate Javadoc or both HTML and Javadoc formats,
54+
> By default, DGP v2 generates HTML documentation. To generate Javadoc or both HTML and Javadoc formats,
5555
> add the appropriate plugins. For more information, see [Select documentation output format](#select-documentation-output-format).
5656
>
5757
{style="tip"}
@@ -149,7 +149,7 @@ dokka {
149149
includes.from("README.md")
150150
sourceLink {
151151
localDirectory.set(file("src/main/kotlin"))
152-
remoteUrl.set(URI("https://example.com/src"))
152+
remoteUrl("https://example.com/src")
153153
remoteLineSuffix.set("#L")
154154
}
155155
}
@@ -167,29 +167,35 @@ dokka {
167167
```kotlin
168168

169169
// CustomPlugin.kt
170+
import org.gradle.api.Plugin
171+
import org.gradle.api.Project
172+
import org.jetbrains.dokka.gradle.DokkaExtension
173+
import org.jetbrains.dokka.gradle.engine.plugins.DokkaHtmlPluginParameters
170174

171-
class CustomPlugin : Plugin<Project> {
175+
abstract class CustomPlugin : Plugin<Project> {
172176
override fun apply(project: Project) {
173-
project.extensions.configure<DokkaExtension> {
177+
project.plugins.apply("org.jetbrains.dokka")
174178

175-
dokkaPublications.named("html") {
176-
suppressInheritedMembers.set(true)
177-
failOnWarning.set(true)
179+
project.extensions.configure(DokkaExtension::class.java) { dokka ->
180+
181+
dokka.dokkaPublications.named("html") { publication ->
182+
publication.suppressInheritedMembers.set(true)
183+
publication.failOnWarning.set(true)
178184
}
179185

180-
dokkaSourceSets.named("main") {
181-
includes.from("README.md")
182-
sourceLink {
183-
localDirectory.set(project.file("src/main/kotlin"))
184-
remoteUrl.set(URI("https://example.com/src"))
185-
remoteLineSuffix.set("#L")
186+
dokka.dokkaSourceSets.named("main") { dss ->
187+
dss.includes.from("README.md")
188+
dss.sourceLink {
189+
it.localDirectory.set(project.file("src/main/kotlin"))
190+
it.remoteUrl("https://example.com/src")
191+
it.remoteLineSuffix.set("#L")
186192
}
187193
}
188194

189-
pluginsConfiguration.named<org.jetbrains.dokka.gradle.engine.plugins.DokkaHtmlPluginParameters>("pluginsConfiguration") {
190-
customStyleSheets.from("styles.css")
191-
customAssets.from("logo.png")
192-
footerMessage.set("(c) Your Company")
195+
dokka.pluginsConfiguration.named("html", DokkaHtmlPluginParameters::class.java) { html ->
196+
html.customStyleSheets.from("styles.css")
197+
html.customAssets.from("logo.png")
198+
html.footerMessage.set("(c) Your Company")
193199
}
194200
}
195201
}
@@ -229,7 +235,7 @@ documentedVisibilities.set(
229235
documentedVisibilities(VisibilityModifier.Public)
230236
```
231237

232-
Additionally, DGP v2 has a [utility function](https://github.com/Kotlin/dokka/blob/220922378e6c68eb148fda2ec80528a1b81478c9/dokka-runners/dokka-gradle-plugin/src/main/kotlin/engine/parameters/HasConfigurableVisibilityModifiers.kt#L14-L16) for adding documented visibilities:
238+
Additionally, DGP v2 has a [utility function](https://github.com/Kotlin/dokka/blob/v2.0.0/dokka-runners/dokka-gradle-plugin/src/main/kotlin/engine/parameters/HasConfigurableVisibilityModifiers.kt#L14-L16) for adding documented visibilities:
233239

234240
```kotlin
235241
fun documentedVisibilities(vararg visibilities: VisibilityModifier): Unit =
@@ -270,12 +276,10 @@ due to the use of type-safe accessors in Kotlin DSL.
270276
// build.gradle.kts
271277

272278
dokka {
273-
moduleName.set("Project Name")
274279
dokkaSourceSets.main {
275-
includes.from("README.md")
276280
sourceLink {
277281
localDirectory.set(file("src/main/kotlin"))
278-
remoteUrl.set(URI("https://github.com/your-repo"))
282+
remoteUrl("https://github.com/your-repo")
279283
remoteLineSuffix.set("#L")
280284
}
281285
}
@@ -289,15 +293,20 @@ dokka {
289293

290294
// CustomPlugin.kt
291295

292-
class CustomPlugin : Plugin<Project> {
296+
import org.gradle.api.Plugin
297+
import org.gradle.api.Project
298+
import org.jetbrains.dokka.gradle.DokkaExtension
299+
300+
abstract class CustomPlugin : Plugin<Project> {
293301
override fun apply(project: Project) {
294-
project.extensions.configure<DokkaExtension> {
295-
dokkaSourceSets.named("main") {
296-
includes.from("README.md")
297-
sourceLink {
298-
localDirectory.set(project.file("src/main/kotlin"))
299-
remoteUrl.set(URI("https://example.com/src"))
300-
remoteLineSuffix.set("#L")
302+
project.plugins.apply("org.jetbrains.dokka")
303+
project.extensions.configure(DokkaExtension::class.java) { dokka ->
304+
dokka.dokkaSourceSets.named("main") { dss ->
305+
dss.includes.from("README.md")
306+
dss.sourceLink {
307+
it.localDirectory.set(project.file("src/main/kotlin"))
308+
it.remoteUrl("https://example.com/src")
309+
it.remoteLineSuffix.set("#L")
301310
}
302311
}
303312
}
@@ -453,16 +462,19 @@ dokka {
453462

454463
// CustomPlugin.kt
455464

456-
class CustomPlugin : Plugin<Project> {
465+
import org.gradle.api.Plugin
466+
import org.gradle.api.Project
467+
import org.jetbrains.dokka.gradle.DokkaExtension
468+
469+
abstract class CustomPlugin : Plugin<Project> {
457470
override fun apply(project: Project) {
458-
project.extensions.configure<DokkaExtension> {
459-
dokkaPublications.named("html") {
460-
outputDirectory.set(project.rootDir.resolve("docs/api/0.x"))
461-
includes.from(project.layout.projectDirectory.file("README.md"))
471+
project.plugins.apply("org.jetbrains.dokka")
472+
project.extensions.configure(DokkaExtension::class.java) { dokka ->
473+
dokka.dokkaPublications.named("html") { html ->
474+
html.outputDirectory.set(project.rootDir.resolve("docs/api/0.x"))
475+
html.includes.from(project.layout.projectDirectory.file("README.md"))
462476
}
463477
}
464-
}
465-
}
466478
```
467479

468480
</tab>
@@ -677,7 +689,7 @@ plugins {
677689

678690
dokka {
679691
// Overrides the module directory to match the V1 structure
680-
modulePath.convention("maths")
692+
modulePath.set("maths")
681693
}
682694
```
683695

0 commit comments

Comments
 (0)