@@ -51,7 +51,7 @@ Alternatively,
51
51
you can use [ version catalog] ( https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog )
52
52
to enable the Dokka Gradle plugin v2.
53
53
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,
55
55
> add the appropriate plugins. For more information, see [ Select documentation output format] ( #select-documentation-output-format ) .
56
56
>
57
57
{style="tip"}
@@ -149,7 +149,7 @@ dokka {
149
149
includes.from(" README.md" )
150
150
sourceLink {
151
151
localDirectory.set(file(" src/main/kotlin" ))
152
- remoteUrl.set( URI ( " https://example.com/src" ) )
152
+ remoteUrl( " https://example.com/src" )
153
153
remoteLineSuffix.set(" #L" )
154
154
}
155
155
}
@@ -167,29 +167,35 @@ dokka {
167
167
``` kotlin
168
168
169
169
// 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
170
174
171
- class CustomPlugin : Plugin <Project > {
175
+ abstract class CustomPlugin : Plugin <Project > {
172
176
override fun apply (project : Project ) {
173
- project.extensions.configure< DokkaExtension > {
177
+ project.plugins. apply ( " org.jetbrains.dokka " )
174
178
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 )
178
184
}
179
185
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" )
186
192
}
187
193
}
188
194
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" )
193
199
}
194
200
}
195
201
}
@@ -229,7 +235,7 @@ documentedVisibilities.set(
229
235
documentedVisibilities(VisibilityModifier .Public )
230
236
```
231
237
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:
233
239
234
240
``` kotlin
235
241
fun documentedVisibilities (vararg visibilities : VisibilityModifier ): Unit =
@@ -270,12 +276,10 @@ due to the use of type-safe accessors in Kotlin DSL.
270
276
// build.gradle.kts
271
277
272
278
dokka {
273
- moduleName.set(" Project Name" )
274
279
dokkaSourceSets.main {
275
- includes.from(" README.md" )
276
280
sourceLink {
277
281
localDirectory.set(file(" src/main/kotlin" ))
278
- remoteUrl.set( URI ( " https://github.com/your-repo" ) )
282
+ remoteUrl( " https://github.com/your-repo" )
279
283
remoteLineSuffix.set(" #L" )
280
284
}
281
285
}
@@ -289,15 +293,20 @@ dokka {
289
293
290
294
// CustomPlugin.kt
291
295
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 > {
293
301
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" )
301
310
}
302
311
}
303
312
}
@@ -453,16 +462,19 @@ dokka {
453
462
454
463
// CustomPlugin.kt
455
464
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 > {
457
470
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" ))
462
476
}
463
477
}
464
- }
465
- }
466
478
```
467
479
468
480
< / tab>
@@ -677,7 +689,7 @@ plugins {
677
689
678
690
dokka {
679
691
// Overrides the module directory to match the V1 structure
680
- modulePath.convention ("maths")
692
+ modulePath.set (" maths" )
681
693
}
682
694
```
683
695
0 commit comments