Skip to content

Commit 6e41610

Browse files
DGPv2 migration guide: minor tidying (#3844)
* fix `remoteUrl` in new config * Added utility functions code snippets and fixed code lines --------- Co-authored-by: alepedroza <39709865+AlejandraPedroza@users.noreply.github.com>
1 parent 7027da8 commit 6e41610

File tree

1 file changed

+39
-11
lines changed

1 file changed

+39
-11
lines changed

docs/topics/dokka-migration.md

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Ensure that your project meets the minimum version requirements:
5151

5252
2. In the project's `gradle.properties` file, set the following opt-in flag with helpers to activate the new plugin version:
5353

54-
```kotlin
54+
```text
5555
org.jetbrains.dokka.experimental.gradle.pluginMode=V2EnabledWithHelpers
5656
```
5757

@@ -63,7 +63,6 @@ Ensure that your project meets the minimum version requirements:
6363
>
6464
{style="tip"}
6565

66-
6766
3. Sync your project with Gradle to ensure the new plugin is properly applied:
6867

6968
* If you use IntelliJ IDEA, click the **Reload All Gradle Projects** ![Reload button](gradle-reload-button.png){width=30}{type="joined"} button from the Gradle tool window.
@@ -116,7 +115,7 @@ options according to your project setup:
116115
includes.from("README.md")
117116
sourceLink {
118117
localDirectory.set(file("src/main/kotlin"))
119-
remoteUrl.set(URL("https://example.com/src"))
118+
remoteUrl("https://example.com/src")
120119
remoteLineSuffix.set("#L")
121120
}
122121
}
@@ -148,6 +147,17 @@ options according to your project setup:
148147
documentedVisibilities.set(
149148
setOf(VisibilityModifier.Public)
150149
)
150+
151+
// OR
152+
153+
documentedVisibilities(VisibilityModifier.Public)
154+
```
155+
156+
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:
157+
158+
```kotlin
159+
fun documentedVisibilities(vararg visibilities: VisibilityModifier): Unit =
160+
documentedVisibilities.set(visibilities.asList())
151161
```
152162

153163
* **External documentation link:** The source link configuration has [changed](https://docs.gradle.org/current/userguide/upgrading_version_8.html#deprecated_invalid_url_decoding).
@@ -156,15 +166,33 @@ options according to your project setup:
156166
Previous configuration:
157167

158168
```kotlin
159-
remoteUrl.set(URL("https://github.com/your-repo"))
169+
remoteUrl.set(URL("https://github.com/your-repo"))
160170
```
161171

162172
New configuration:
163173

164174
```kotlin
165-
remoteUrl.set(URI("https://github.com/your-repo"))
175+
remoteUrl.set(URI("https://github.com/your-repo"))
176+
177+
// OR
178+
179+
remoteUrl("https://github.com/your-repo")
166180
```
167181

182+
Additionally, DGP v2 has two [utility functions](https://github.com/Kotlin/dokka/blob/220922378e6c68eb148fda2ec80528a1b81478c9/dokka-runners/dokka-gradle-plugin/src/main/kotlin/engine/parameters/DokkaSourceLinkSpec.kt#L82-L96)
183+
for setting the URL:
184+
185+
```kotlin
186+
fun remoteUrl(@Language("http-url-reference") value: String): Unit =
187+
remoteUrl.set(URI(value))
188+
189+
// and
190+
191+
fun remoteUrl(value: Provider<String>): Unit =
192+
remoteUrl.set(value.map(::URI))
193+
```
194+
195+
168196
* **Custom assets:** The [`customAssets`](dokka-html.md#customize-assets) property now uses collections of files
169197
([`FileCollection`)](https://docs.gradle.org/8.10/userguide/lazy_configuration.html#working_with_files_in_lazy_properties)
170198
instead of lists (`var List<File>`).
@@ -266,7 +294,7 @@ After setting up the `buildSrc` directory:
266294
}
267295

268296
dokka {
269-
// The shared configuration goes here
297+
// The shared configuration goes here
270298
}
271299
```
272300

@@ -325,7 +353,7 @@ DGP v2 has renamed the Gradle tasks that generate the API documentation.
325353
326354
Previous task:
327355
328-
```kotlin
356+
```text
329357
./gradlew dokkaHtml
330358
331359
// OR
@@ -335,7 +363,7 @@ Previous task:
335363
336364
New task:
337365
338-
```kotlin
366+
```text
339367
./gradlew :dokkaGenerate
340368
```
341369
@@ -355,7 +383,7 @@ to generate output in HTML, Javadoc or both HTML and Javadoc. For more informati
355383
The default output format for DGP v2 is HTML. However, you can choose to generate the API documentation in HTML, Javadoc,
356384
or both formats at the same time:
357385
358-
1. Place the corresponding plugin `id` in the `plugins{}` block of your project's `build.gradle.kts` file:
386+
1. Place the corresponding plugin `id` in the `plugins {}` block of your project's `build.gradle.kts` file:
359387

360388
```kotlin
361389
plugins {
@@ -379,7 +407,7 @@ Here's a list of the plugin `id` and Gradle task that correspond to each format:
379407
| Gradle task | `./gradlew :dokkaGenerateHtml` | `./gradlew :dokkaGenerateJavadoc` | `./gradlew :dokkaGenerate` |
380408
381409
> The `dokkaGenerate` task generates documentation in all available formats based on the applied plugins.
382-
> If both the HTML and Javadoc plugins are applied, you can choose to generate only HTML format by running the `dokkaGenerateHtml` task,
410+
> If both the HTML and Javadoc plugins are applied, you can choose to generate only HTML by running the `dokkaGenerateHtml` task,
383411
> or only Javadoc by running the `dokkaGenerateJavadoc` task.
384412
>
385413
{style="tip"}
@@ -398,7 +426,7 @@ After you've migrated your project, perform these steps to wrap up and improve p
398426

399427
After successful migration, set the following opt-in flag without helpers in the project's `gradle.properties` file:
400428
401-
```kotlin
429+
```text
402430
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
403431
```
404432

0 commit comments

Comments
 (0)