xref: /aosp_15_r20/external/dokka/README.md (revision 1b2d298c530bf0473cc943e8414a5ff577a994bc)
1*1b2d298cSOwner Cleanup Botdokka
2*1b2d298cSOwner Cleanup Bot=====
3*1b2d298cSOwner Cleanup Bot
4*1b2d298cSOwner Cleanup Bot**_Note_: This is Google's fork of Dokka, customized for [Android API reference docs](https://developer.android.com/reference/)
5*1b2d298cSOwner Cleanup Boton [developer.android.com](https://developer.android.com/) and other Google products.**
6*1b2d298cSOwner Cleanup Bot
7*1b2d298cSOwner Cleanup BotDokka is a documentation engine for Kotlin, performing the same function as javadoc for Java.
8*1b2d298cSOwner Cleanup BotJust like Kotlin itself, Dokka fully supports mixed-language Java/Kotlin projects. It understands
9*1b2d298cSOwner Cleanup Botstandard Javadoc comments in Java files and [KDoc comments](https://kotlinlang.org/docs/reference/kotlin-doc.html) in Kotlin files,
10*1b2d298cSOwner Cleanup Botand can generate documentation in multiple formats including standard Javadoc, HTML and Markdown.
11*1b2d298cSOwner Cleanup Bot
12*1b2d298cSOwner Cleanup Bot## Using Dokka
13*1b2d298cSOwner Cleanup Bot
14*1b2d298cSOwner Cleanup Bot### Using the Gradle plugin
15*1b2d298cSOwner Cleanup Bot
16*1b2d298cSOwner Cleanup Bot```groovy
17*1b2d298cSOwner Cleanup Botbuildscript {
18*1b2d298cSOwner Cleanup Bot    repositories {
19*1b2d298cSOwner Cleanup Bot        jcenter()
20*1b2d298cSOwner Cleanup Bot    }
21*1b2d298cSOwner Cleanup Bot
22*1b2d298cSOwner Cleanup Bot    dependencies {
23*1b2d298cSOwner Cleanup Bot        classpath "org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}"
24*1b2d298cSOwner Cleanup Bot    }
25*1b2d298cSOwner Cleanup Bot}
26*1b2d298cSOwner Cleanup Bot
27*1b2d298cSOwner Cleanup Botapply plugin: 'org.jetbrains.dokka'
28*1b2d298cSOwner Cleanup Bot```
29*1b2d298cSOwner Cleanup Bot
30*1b2d298cSOwner Cleanup BotThe plugin adds a task named "dokka" to the project.
31*1b2d298cSOwner Cleanup Bot
32*1b2d298cSOwner Cleanup BotMinimal dokka configuration:
33*1b2d298cSOwner Cleanup Bot
34*1b2d298cSOwner Cleanup Bot```groovy
35*1b2d298cSOwner Cleanup Botdokka {
36*1b2d298cSOwner Cleanup Bot    outputFormat = 'html'
37*1b2d298cSOwner Cleanup Bot    outputDirectory = "$buildDir/javadoc"
38*1b2d298cSOwner Cleanup Bot}
39*1b2d298cSOwner Cleanup Bot```
40*1b2d298cSOwner Cleanup Bot
41*1b2d298cSOwner Cleanup Bot[Output formats](#output_formats)
42*1b2d298cSOwner Cleanup Bot
43*1b2d298cSOwner Cleanup BotThe available configuration options are shown below:
44*1b2d298cSOwner Cleanup Bot
45*1b2d298cSOwner Cleanup Bot```groovy
46*1b2d298cSOwner Cleanup Botdokka {
47*1b2d298cSOwner Cleanup Bot    moduleName = 'data'
48*1b2d298cSOwner Cleanup Bot    outputFormat = 'html'
49*1b2d298cSOwner Cleanup Bot    outputDirectory = "$buildDir/javadoc"
50*1b2d298cSOwner Cleanup Bot
51*1b2d298cSOwner Cleanup Bot    // These tasks will be used to determine source directories and classpath
52*1b2d298cSOwner Cleanup Bot    kotlinTasks {
53*1b2d298cSOwner Cleanup Bot        defaultKotlinTasks() + [':some:otherCompileKotlin', project("another").compileKotlin]
54*1b2d298cSOwner Cleanup Bot    }
55*1b2d298cSOwner Cleanup Bot
56*1b2d298cSOwner Cleanup Bot    // List of files with module and package documentation
57*1b2d298cSOwner Cleanup Bot    // http://kotlinlang.org/docs/reference/kotlin-doc.html#module-and-package-documentation
58*1b2d298cSOwner Cleanup Bot    includes = ['packages.md', 'extra.md']
59*1b2d298cSOwner Cleanup Bot
60*1b2d298cSOwner Cleanup Bot    // The list of files or directories containing sample code (referenced with @sample tags)
61*1b2d298cSOwner Cleanup Bot    samples = ['samples/basic.kt', 'samples/advanced.kt']
62*1b2d298cSOwner Cleanup Bot
63*1b2d298cSOwner Cleanup Bot    jdkVersion = 6 // Used for linking to JDK
64*1b2d298cSOwner Cleanup Bot
65*1b2d298cSOwner Cleanup Bot    // Use default or set to custom path to cache directory
66*1b2d298cSOwner Cleanup Bot    // to enable package-list caching
67*1b2d298cSOwner Cleanup Bot    // When set to default, caches stored in $USER_HOME/.cache/dokka
68*1b2d298cSOwner Cleanup Bot    cacheRoot = 'default'
69*1b2d298cSOwner Cleanup Bot
70*1b2d298cSOwner Cleanup Bot    // Use to include or exclude non public members.
71*1b2d298cSOwner Cleanup Bot    includeNonPublic = false
72*1b2d298cSOwner Cleanup Bot
73*1b2d298cSOwner Cleanup Bot    // Do not output deprecated members. Applies globally, can be overridden by packageOptions
74*1b2d298cSOwner Cleanup Bot    skipDeprecated = false
75*1b2d298cSOwner Cleanup Bot
76*1b2d298cSOwner Cleanup Bot    // Emit warnings about not documented members. Applies globally, also can be overridden by packageOptions
77*1b2d298cSOwner Cleanup Bot    reportUndocumented = true
78*1b2d298cSOwner Cleanup Bot
79*1b2d298cSOwner Cleanup Bot    skipEmptyPackages = true // Do not create index pages for empty packages
80*1b2d298cSOwner Cleanup Bot
81*1b2d298cSOwner Cleanup Bot    impliedPlatforms = ["JVM"] // See platforms section of documentation
82*1b2d298cSOwner Cleanup Bot
83*1b2d298cSOwner Cleanup Bot    // Manual adding files to classpath
84*1b2d298cSOwner Cleanup Bot    // This property not overrides classpath collected from kotlinTasks but appends to it
85*1b2d298cSOwner Cleanup Bot    classpath = [new File("$buildDir/other.jar")]
86*1b2d298cSOwner Cleanup Bot
87*1b2d298cSOwner Cleanup Bot    // By default, sourceRoots is taken from kotlinTasks, following roots will be appended to it
88*1b2d298cSOwner Cleanup Bot    // Short form sourceRoots
89*1b2d298cSOwner Cleanup Bot    sourceDirs = files('src/main/kotlin')
90*1b2d298cSOwner Cleanup Bot
91*1b2d298cSOwner Cleanup Bot    // By default, sourceRoots is taken from kotlinTasks, following roots will be appended to it
92*1b2d298cSOwner Cleanup Bot    // Full form sourceRoot declaration
93*1b2d298cSOwner Cleanup Bot    // Repeat for multiple sourceRoots
94*1b2d298cSOwner Cleanup Bot    sourceRoot {
95*1b2d298cSOwner Cleanup Bot        // Path to source root
96*1b2d298cSOwner Cleanup Bot        path = "src"
97*1b2d298cSOwner Cleanup Bot        // See platforms section of documentation
98*1b2d298cSOwner Cleanup Bot        platforms = ["JVM"]
99*1b2d298cSOwner Cleanup Bot    }
100*1b2d298cSOwner Cleanup Bot
101*1b2d298cSOwner Cleanup Bot    // Specifies the location of the project source code on the Web.
102*1b2d298cSOwner Cleanup Bot    // If provided, Dokka generates "source" links for each declaration.
103*1b2d298cSOwner Cleanup Bot    // Repeat for multiple mappings
104*1b2d298cSOwner Cleanup Bot    linkMapping {
105*1b2d298cSOwner Cleanup Bot        // Source directory
106*1b2d298cSOwner Cleanup Bot        dir = "src/main/kotlin"
107*1b2d298cSOwner Cleanup Bot
108*1b2d298cSOwner Cleanup Bot        // URL showing where the source code can be accessed through the web browser
109*1b2d298cSOwner Cleanup Bot        url = "https://github.com/cy6erGn0m/vertx3-lang-kotlin/blob/master/src/main/kotlin"
110*1b2d298cSOwner Cleanup Bot
111*1b2d298cSOwner Cleanup Bot        // Suffix which is used to append the line number to the URL. Use #L for GitHub
112*1b2d298cSOwner Cleanup Bot        suffix = "#L"
113*1b2d298cSOwner Cleanup Bot    }
114*1b2d298cSOwner Cleanup Bot
115*1b2d298cSOwner Cleanup Bot    // No default documentation link to kotlin-stdlib
116*1b2d298cSOwner Cleanup Bot    noStdlibLink = false
117*1b2d298cSOwner Cleanup Bot
118*1b2d298cSOwner Cleanup Bot    // Allows linking to documentation of the project's dependencies (generated with Javadoc or Dokka)
119*1b2d298cSOwner Cleanup Bot    // Repeat for multiple links
120*1b2d298cSOwner Cleanup Bot    externalDocumentationLink {
121*1b2d298cSOwner Cleanup Bot        // Root URL of the generated documentation to link with. The trailing slash is required!
122*1b2d298cSOwner Cleanup Bot        url = new URL("https://example.com/docs/")
123*1b2d298cSOwner Cleanup Bot
124*1b2d298cSOwner Cleanup Bot        // If package-list file located in non-standard location
125*1b2d298cSOwner Cleanup Bot        // packageListUrl = new URL("file:///home/user/localdocs/package-list")
126*1b2d298cSOwner Cleanup Bot    }
127*1b2d298cSOwner Cleanup Bot
128*1b2d298cSOwner Cleanup Bot    // Allows to customize documentation generation options on a per-package basis
129*1b2d298cSOwner Cleanup Bot    // Repeat for multiple packageOptions
130*1b2d298cSOwner Cleanup Bot    packageOptions {
131*1b2d298cSOwner Cleanup Bot        prefix = "kotlin" // will match kotlin and all sub-packages of it
132*1b2d298cSOwner Cleanup Bot        // All options are optional, default values are below:
133*1b2d298cSOwner Cleanup Bot        skipDeprecated = false
134*1b2d298cSOwner Cleanup Bot        reportUndocumented = true // Emit warnings about not documented members
135*1b2d298cSOwner Cleanup Bot        includeNonPublic = false
136*1b2d298cSOwner Cleanup Bot    }
137*1b2d298cSOwner Cleanup Bot    // Suppress a package
138*1b2d298cSOwner Cleanup Bot    packageOptions {
139*1b2d298cSOwner Cleanup Bot        prefix = "kotlin.internal" // will match kotlin.internal and all sub-packages of it
140*1b2d298cSOwner Cleanup Bot        suppress = true
141*1b2d298cSOwner Cleanup Bot    }
142*1b2d298cSOwner Cleanup Bot}
143*1b2d298cSOwner Cleanup Bot```
144*1b2d298cSOwner Cleanup Bot
145*1b2d298cSOwner Cleanup BotTo generate the documentation, use the `dokka` Gradle task:
146*1b2d298cSOwner Cleanup Bot
147*1b2d298cSOwner Cleanup Bot```bash
148*1b2d298cSOwner Cleanup Bot./gradlew dokka
149*1b2d298cSOwner Cleanup Bot```
150*1b2d298cSOwner Cleanup Bot
151*1b2d298cSOwner Cleanup BotMore dokka tasks can be added to a project like this:
152*1b2d298cSOwner Cleanup Bot
153*1b2d298cSOwner Cleanup Bot```groovy
154*1b2d298cSOwner Cleanup Bottask dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) {
155*1b2d298cSOwner Cleanup Bot    outputFormat = 'javadoc'
156*1b2d298cSOwner Cleanup Bot    outputDirectory = "$buildDir/javadoc"
157*1b2d298cSOwner Cleanup Bot}
158*1b2d298cSOwner Cleanup Bot```
159*1b2d298cSOwner Cleanup Bot
160*1b2d298cSOwner Cleanup BotPlease see the [Dokka Gradle example project](https://github.com/JetBrains/kotlin-examples/tree/master/gradle/dokka-gradle-example) for an example.
161*1b2d298cSOwner Cleanup Bot
162*1b2d298cSOwner Cleanup Bot#### Android
163*1b2d298cSOwner Cleanup Bot
164*1b2d298cSOwner Cleanup BotIf you are using Android there is a separate Gradle plugin. Just make sure you apply the plugin after
165*1b2d298cSOwner Cleanup Bot`com.android.library` and `kotlin-android`.
166*1b2d298cSOwner Cleanup Bot
167*1b2d298cSOwner Cleanup Bot```groovy
168*1b2d298cSOwner Cleanup Botbuildscript {
169*1b2d298cSOwner Cleanup Bot    repositories {
170*1b2d298cSOwner Cleanup Bot        jcenter()
171*1b2d298cSOwner Cleanup Bot    }
172*1b2d298cSOwner Cleanup Bot
173*1b2d298cSOwner Cleanup Bot    dependencies {
174*1b2d298cSOwner Cleanup Bot        classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:${dokka_version}"
175*1b2d298cSOwner Cleanup Bot    }
176*1b2d298cSOwner Cleanup Bot}
177*1b2d298cSOwner Cleanup Bot
178*1b2d298cSOwner Cleanup Botapply plugin: 'com.android.library'
179*1b2d298cSOwner Cleanup Botapply plugin: 'kotlin-android'
180*1b2d298cSOwner Cleanup Botapply plugin: 'org.jetbrains.dokka-android'
181*1b2d298cSOwner Cleanup Bot```
182*1b2d298cSOwner Cleanup Bot
183*1b2d298cSOwner Cleanup Bot### Using the Maven plugin
184*1b2d298cSOwner Cleanup Bot
185*1b2d298cSOwner Cleanup BotThe Maven plugin is available in JCenter. You need to add the JCenter repository to the list of plugin repositories if it's not there:
186*1b2d298cSOwner Cleanup Bot
187*1b2d298cSOwner Cleanup Bot```xml
188*1b2d298cSOwner Cleanup Bot<pluginRepositories>
189*1b2d298cSOwner Cleanup Bot    <pluginRepository>
190*1b2d298cSOwner Cleanup Bot        <id>jcenter</id>
191*1b2d298cSOwner Cleanup Bot        <name>JCenter</name>
192*1b2d298cSOwner Cleanup Bot        <url>https://jcenter.bintray.com/</url>
193*1b2d298cSOwner Cleanup Bot    </pluginRepository>
194*1b2d298cSOwner Cleanup Bot</pluginRepositories>
195*1b2d298cSOwner Cleanup Bot```
196*1b2d298cSOwner Cleanup Bot
197*1b2d298cSOwner Cleanup BotMinimal Maven configuration is
198*1b2d298cSOwner Cleanup Bot
199*1b2d298cSOwner Cleanup Bot```xml
200*1b2d298cSOwner Cleanup Bot<plugin>
201*1b2d298cSOwner Cleanup Bot    <groupId>org.jetbrains.dokka</groupId>
202*1b2d298cSOwner Cleanup Bot    <artifactId>dokka-maven-plugin</artifactId>
203*1b2d298cSOwner Cleanup Bot    <version>${dokka.version}</version>
204*1b2d298cSOwner Cleanup Bot    <executions>
205*1b2d298cSOwner Cleanup Bot        <execution>
206*1b2d298cSOwner Cleanup Bot            <phase>pre-site</phase>
207*1b2d298cSOwner Cleanup Bot            <goals>
208*1b2d298cSOwner Cleanup Bot                <goal>dokka</goal>
209*1b2d298cSOwner Cleanup Bot            </goals>
210*1b2d298cSOwner Cleanup Bot        </execution>
211*1b2d298cSOwner Cleanup Bot    </executions>
212*1b2d298cSOwner Cleanup Bot</plugin>
213*1b2d298cSOwner Cleanup Bot```
214*1b2d298cSOwner Cleanup Bot
215*1b2d298cSOwner Cleanup BotBy default files will be generated in `target/dokka`.
216*1b2d298cSOwner Cleanup Bot
217*1b2d298cSOwner Cleanup BotThe following goals are provided by the plugin:
218*1b2d298cSOwner Cleanup Bot
219*1b2d298cSOwner Cleanup Bot  * `dokka:dokka` - generate HTML documentation in Dokka format (showing declarations in Kotlin syntax);
220*1b2d298cSOwner Cleanup Bot  * `dokka:javadoc` - generate HTML documentation in JavaDoc format (showing declarations in Java syntax);
221*1b2d298cSOwner Cleanup Bot  * `dokka:javadocJar` - generate a .jar file with JavaDoc format documentation.
222*1b2d298cSOwner Cleanup Bot
223*1b2d298cSOwner Cleanup BotThe available configuration options are shown below:
224*1b2d298cSOwner Cleanup Bot
225*1b2d298cSOwner Cleanup Bot```xml
226*1b2d298cSOwner Cleanup Bot<plugin>
227*1b2d298cSOwner Cleanup Bot    <groupId>org.jetbrains.dokka</groupId>
228*1b2d298cSOwner Cleanup Bot    <artifactId>dokka-maven-plugin</artifactId>
229*1b2d298cSOwner Cleanup Bot    <version>${dokka.version}</version>
230*1b2d298cSOwner Cleanup Bot    <executions>
231*1b2d298cSOwner Cleanup Bot        <execution>
232*1b2d298cSOwner Cleanup Bot            <phase>pre-site</phase>
233*1b2d298cSOwner Cleanup Bot            <goals>
234*1b2d298cSOwner Cleanup Bot                <goal>dokka</goal>
235*1b2d298cSOwner Cleanup Bot            </goals>
236*1b2d298cSOwner Cleanup Bot        </execution>
237*1b2d298cSOwner Cleanup Bot    </executions>
238*1b2d298cSOwner Cleanup Bot    <configuration>
239*1b2d298cSOwner Cleanup Bot
240*1b2d298cSOwner Cleanup Bot        <!-- Set to true to skip dokka task, default: false -->
241*1b2d298cSOwner Cleanup Bot        <skip>false</skip>
242*1b2d298cSOwner Cleanup Bot
243*1b2d298cSOwner Cleanup Bot        <!-- Default: ${project.artifactId} -->
244*1b2d298cSOwner Cleanup Bot        <moduleName>data</moduleName>
245*1b2d298cSOwner Cleanup Bot        <!-- See list of possible formats below -->
246*1b2d298cSOwner Cleanup Bot        <outputFormat>html</outputFormat>
247*1b2d298cSOwner Cleanup Bot        <!-- Default: ${project.basedir}/target/dokka -->
248*1b2d298cSOwner Cleanup Bot        <outputDir>some/out/dir</outputDir>
249*1b2d298cSOwner Cleanup Bot
250*1b2d298cSOwner Cleanup Bot        <!-- Use default or set to custom path to cache directory to enable package-list caching. -->
251*1b2d298cSOwner Cleanup Bot        <!-- When set to default, caches stored in $USER_HOME/.cache/dokka -->
252*1b2d298cSOwner Cleanup Bot        <cacheRoot>default</cacheRoot>
253*1b2d298cSOwner Cleanup Bot
254*1b2d298cSOwner Cleanup Bot        <!-- List of '.md' files with package and module docs -->
255*1b2d298cSOwner Cleanup Bot        <!-- http://kotlinlang.org/docs/reference/kotlin-doc.html#module-and-package-documentation -->
256*1b2d298cSOwner Cleanup Bot        <includes>
257*1b2d298cSOwner Cleanup Bot            <file>packages.md</file>
258*1b2d298cSOwner Cleanup Bot            <file>extra.md</file>
259*1b2d298cSOwner Cleanup Bot        </includes>
260*1b2d298cSOwner Cleanup Bot
261*1b2d298cSOwner Cleanup Bot        <!-- List of sample roots -->
262*1b2d298cSOwner Cleanup Bot        <samplesDirs>
263*1b2d298cSOwner Cleanup Bot            <dir>src/test/samples</dir>
264*1b2d298cSOwner Cleanup Bot        </samplesDirs>
265*1b2d298cSOwner Cleanup Bot
266*1b2d298cSOwner Cleanup Bot        <!-- Used for linking to JDK, default: 6 -->
267*1b2d298cSOwner Cleanup Bot        <jdkVersion>6</jdkVersion>
268*1b2d298cSOwner Cleanup Bot
269*1b2d298cSOwner Cleanup Bot        <!-- Do not output deprecated members, applies globally, can be overridden by packageOptions -->
270*1b2d298cSOwner Cleanup Bot        <skipDeprecated>false</skipDeprecated>
271*1b2d298cSOwner Cleanup Bot        <!-- Emit warnings about not documented members, applies globally, also can be overridden by packageOptions -->
272*1b2d298cSOwner Cleanup Bot        <reportNotDocumented>true</reportNotDocumented>
273*1b2d298cSOwner Cleanup Bot        <!-- Do not create index pages for empty packages -->
274*1b2d298cSOwner Cleanup Bot        <skipEmptyPackages>true</skipEmptyPackages>
275*1b2d298cSOwner Cleanup Bot
276*1b2d298cSOwner Cleanup Bot        <!-- See platforms section of documentation -->
277*1b2d298cSOwner Cleanup Bot        <impliedPlatforms>
278*1b2d298cSOwner Cleanup Bot            <platform>JVM</platform>
279*1b2d298cSOwner Cleanup Bot        </impliedPlatforms>
280*1b2d298cSOwner Cleanup Bot
281*1b2d298cSOwner Cleanup Bot        <!-- Short form list of sourceRoots, by default, set to ${project.compileSourceRoots} -->
282*1b2d298cSOwner Cleanup Bot        <sourceDirectories>
283*1b2d298cSOwner Cleanup Bot            <dir>src/main/kotlin</dir>
284*1b2d298cSOwner Cleanup Bot        </sourceDirectories>
285*1b2d298cSOwner Cleanup Bot
286*1b2d298cSOwner Cleanup Bot        <!-- Full form list of sourceRoots -->
287*1b2d298cSOwner Cleanup Bot        <sourceRoots>
288*1b2d298cSOwner Cleanup Bot            <root>
289*1b2d298cSOwner Cleanup Bot                <path>src/main/kotlin</path>
290*1b2d298cSOwner Cleanup Bot                <!-- See platforms section of documentation -->
291*1b2d298cSOwner Cleanup Bot                <platforms>JVM</platforms>
292*1b2d298cSOwner Cleanup Bot            </root>
293*1b2d298cSOwner Cleanup Bot        </sourceRoots>
294*1b2d298cSOwner Cleanup Bot
295*1b2d298cSOwner Cleanup Bot        <!-- Specifies the location of the project source code on the Web. If provided, Dokka generates "source" links
296*1b2d298cSOwner Cleanup Bot             for each declaration. -->
297*1b2d298cSOwner Cleanup Bot        <sourceLinks>
298*1b2d298cSOwner Cleanup Bot            <link>
299*1b2d298cSOwner Cleanup Bot                <!-- Source directory -->
300*1b2d298cSOwner Cleanup Bot                <dir>${project.basedir}/src/main/kotlin</dir>
301*1b2d298cSOwner Cleanup Bot                <!-- URL showing where the source code can be accessed through the web browser -->
302*1b2d298cSOwner Cleanup Bot                <url>http://github.com/me/myrepo</url>
303*1b2d298cSOwner Cleanup Bot                <!--Suffix which is used to append the line number to the URL. Use #L for GitHub -->
304*1b2d298cSOwner Cleanup Bot                <urlSuffix>#L</urlSuffix>
305*1b2d298cSOwner Cleanup Bot            </link>
306*1b2d298cSOwner Cleanup Bot        </sourceLinks>
307*1b2d298cSOwner Cleanup Bot
308*1b2d298cSOwner Cleanup Bot        <!-- No default documentation link to kotlin-stdlib -->
309*1b2d298cSOwner Cleanup Bot        <noStdlibLink>false</noStdlibLink>
310*1b2d298cSOwner Cleanup Bot
311*1b2d298cSOwner Cleanup Bot        <!-- Allows linking to documentation of the project's dependencies (generated with Javadoc or Dokka) -->
312*1b2d298cSOwner Cleanup Bot        <externalDocumentationLinks>
313*1b2d298cSOwner Cleanup Bot            <link>
314*1b2d298cSOwner Cleanup Bot                <!-- Root URL of the generated documentation to link with. The trailing slash is required! -->
315*1b2d298cSOwner Cleanup Bot                <url>https://example.com/docs/</url>
316*1b2d298cSOwner Cleanup Bot                <!-- If package-list file located in non-standard location -->
317*1b2d298cSOwner Cleanup Bot                <!-- <packageListUrl>file:///home/user/localdocs/package-list</packageListUrl> -->
318*1b2d298cSOwner Cleanup Bot            </link>
319*1b2d298cSOwner Cleanup Bot        </externalDocumentationLinks>
320*1b2d298cSOwner Cleanup Bot
321*1b2d298cSOwner Cleanup Bot        <!-- Allows to customize documentation generation options on a per-package basis -->
322*1b2d298cSOwner Cleanup Bot        <perPackageOptions>
323*1b2d298cSOwner Cleanup Bot            <packageOptions>
324*1b2d298cSOwner Cleanup Bot                <!-- Will match kotlin and all sub-packages of it -->
325*1b2d298cSOwner Cleanup Bot                <prefix>kotlin</prefix>
326*1b2d298cSOwner Cleanup Bot
327*1b2d298cSOwner Cleanup Bot                <!-- All options are optional, default values are below: -->
328*1b2d298cSOwner Cleanup Bot                <skipDeprecated>false</skipDeprecated>
329*1b2d298cSOwner Cleanup Bot                <!-- Emit warnings about not documented members  -->
330*1b2d298cSOwner Cleanup Bot                <reportUndocumented>true</reportUndocumented>
331*1b2d298cSOwner Cleanup Bot                <includeNonPublic>false</includeNonPublic>
332*1b2d298cSOwner Cleanup Bot            </packageOptions>
333*1b2d298cSOwner Cleanup Bot        </perPackageOptions>
334*1b2d298cSOwner Cleanup Bot    </configuration>
335*1b2d298cSOwner Cleanup Bot</plugin>
336*1b2d298cSOwner Cleanup Bot```
337*1b2d298cSOwner Cleanup Bot
338*1b2d298cSOwner Cleanup BotPlease see the [Dokka Maven example project](https://github.com/JetBrains/kotlin-examples/tree/master/maven/dokka-maven-example) for an example.
339*1b2d298cSOwner Cleanup Bot
340*1b2d298cSOwner Cleanup Bot[Output formats](#output_formats)
341*1b2d298cSOwner Cleanup Bot
342*1b2d298cSOwner Cleanup Bot### Using the Ant task
343*1b2d298cSOwner Cleanup Bot
344*1b2d298cSOwner Cleanup BotThe Ant task definition is also contained in the dokka-fatjar.jar referenced above. Here's an example of using it:
345*1b2d298cSOwner Cleanup Bot
346*1b2d298cSOwner Cleanup Bot```xml
347*1b2d298cSOwner Cleanup Bot<project name="Dokka" default="document">
348*1b2d298cSOwner Cleanup Bot    <typedef resource="dokka-antlib.xml" classpath="dokka-fatjar.jar"/>
349*1b2d298cSOwner Cleanup Bot
350*1b2d298cSOwner Cleanup Bot    <target name="document">
351*1b2d298cSOwner Cleanup Bot        <dokka src="src" outputdir="doc" modulename="myproject"/>
352*1b2d298cSOwner Cleanup Bot    </target>
353*1b2d298cSOwner Cleanup Bot</project>
354*1b2d298cSOwner Cleanup Bot```
355*1b2d298cSOwner Cleanup Bot
356*1b2d298cSOwner Cleanup BotThe Ant task supports the following attributes:
357*1b2d298cSOwner Cleanup Bot
358*1b2d298cSOwner Cleanup Bot  * `outputDir` - the output directory where the documentation is generated
359*1b2d298cSOwner Cleanup Bot  * `outputFormat` - the output format (see the list of supported formats above)
360*1b2d298cSOwner Cleanup Bot  * `classpath` - list of directories or .jar files to include in the classpath (used for resolving references)
361*1b2d298cSOwner Cleanup Bot  * `samples` - list of directories containing sample code (documentation for those directories is not generated but declarations from them can be referenced using the `@sample` tag)
362*1b2d298cSOwner Cleanup Bot  * `moduleName` - the name of the module being documented (used as the root directory of the generated documentation)
363*1b2d298cSOwner Cleanup Bot  * `include` - names of files containing the documentation for the module and individual packages
364*1b2d298cSOwner Cleanup Bot  * `skipDeprecated` - if set, deprecated elements are not included in the generated documentation
365*1b2d298cSOwner Cleanup Bot  * `jdkVersion` - version for linking to JDK
366*1b2d298cSOwner Cleanup Bot  * `impliedPlatforms` - See [platforms](#platforms) section
367*1b2d298cSOwner Cleanup Bot  * `<sourceRoot path="src" platforms="JVM" />` - analogue of src, but allows to specify [platforms](#platforms)
368*1b2d298cSOwner Cleanup Bot  * `<packageOptions prefix="kotlin" includeNonPublic="false" reportUndocumented="true" skipDeprecated="false"/>` -
369*1b2d298cSOwner Cleanup Bot    Per package options for package `kotlin` and sub-packages of it
370*1b2d298cSOwner Cleanup Bot  * `noStdlibLink` - No default documentation link to kotlin-stdlib
371*1b2d298cSOwner Cleanup Bot  * `<externalDocumentationLink url="https://example.com/docs/" packageListUrl="file:///home/user/localdocs/package-list"/>` -
372*1b2d298cSOwner Cleanup Bot    linking to external documentation, packageListUrl should be used if package-list located not in standard location
373*1b2d298cSOwner Cleanup Bot  * `cacheRoot` - Use `default` or set to custom path to cache directory to enable package-list caching. When set to `default`, caches stored in $USER_HOME/.cache/dokka
374*1b2d298cSOwner Cleanup Bot
375*1b2d298cSOwner Cleanup Bot
376*1b2d298cSOwner Cleanup Bot### Using the Command Line
377*1b2d298cSOwner Cleanup Bot
378*1b2d298cSOwner Cleanup BotTo run Dokka from the command line, download the [Dokka jar](https://github.com/Kotlin/dokka/releases/download/0.9.10/dokka-fatjar.jar).
379*1b2d298cSOwner Cleanup BotTo generate documentation, run the following command:
380*1b2d298cSOwner Cleanup Bot
381*1b2d298cSOwner Cleanup Bot    java -jar dokka-fatjar.jar <source directories> <arguments>
382*1b2d298cSOwner Cleanup Bot
383*1b2d298cSOwner Cleanup BotDokka supports the following command line arguments:
384*1b2d298cSOwner Cleanup Bot
385*1b2d298cSOwner Cleanup Bot  * `-output` - the output directory where the documentation is generated
386*1b2d298cSOwner Cleanup Bot  * `-format` - the [output format](#output-formats):
387*1b2d298cSOwner Cleanup Bot  * `-classpath` - list of directories or .jar files to include in the classpath (used for resolving references)
388*1b2d298cSOwner Cleanup Bot  * `-samples` - list of directories containing sample code (documentation for those directories is not generated but declarations from them can be referenced using the `@sample` tag)
389*1b2d298cSOwner Cleanup Bot  * `-module` - the name of the module being documented (used as the root directory of the generated documentation)
390*1b2d298cSOwner Cleanup Bot  * `-include` - names of files containing the documentation for the module and individual packages
391*1b2d298cSOwner Cleanup Bot  * `-nodeprecated` - if set, deprecated elements are not included in the generated documentation
392*1b2d298cSOwner Cleanup Bot  * `-impliedPlatforms` - List of implied platforms (comma-separated)
393*1b2d298cSOwner Cleanup Bot  * `-packageOptions` - List of package options in format `prefix,-deprecated,-privateApi,+warnUndocumented;...`
394*1b2d298cSOwner Cleanup Bot  * `-links` - External documentation links in format `url^packageListUrl^^url2...`
395*1b2d298cSOwner Cleanup Bot  * `-noStdlibLink` - Disable documentation link to stdlib
396*1b2d298cSOwner Cleanup Bot  * `-cacheRoot` - Use `default` or set to custom path to cache directory to enable package-list caching. When set to `default`, caches stored in $USER_HOME/.cache/dokka
397*1b2d298cSOwner Cleanup Bot
398*1b2d298cSOwner Cleanup Bot
399*1b2d298cSOwner Cleanup Bot### Output formats<a name="output_formats"></a>
400*1b2d298cSOwner Cleanup Bot
401*1b2d298cSOwner Cleanup Bot  * `html` - minimalistic html format used by default
402*1b2d298cSOwner Cleanup Bot  * `javadoc` - Dokka mimic to javadoc
403*1b2d298cSOwner Cleanup Bot  * `html-as-java` - as `html` but using java syntax
404*1b2d298cSOwner Cleanup Bot  * `markdown` - Markdown structured as `html`
405*1b2d298cSOwner Cleanup Bot    * `gfm` - GitHub flavored markdown
406*1b2d298cSOwner Cleanup Bot    * `jekyll` - Jekyll compatible markdown
407*1b2d298cSOwner Cleanup Bot  * `kotlin-website*` - internal format used for documentation on [kotlinlang.org](https://kotlinlang.org)
408*1b2d298cSOwner Cleanup Bot
409*1b2d298cSOwner Cleanup Bot### Platforms<a name="platforms"></a>
410*1b2d298cSOwner Cleanup Bot
411*1b2d298cSOwner Cleanup BotDokka can annotate elements with special `platform` block with platform requirements
412*1b2d298cSOwner Cleanup Bot
413*1b2d298cSOwner Cleanup BotExample of usage can be found on [kotlinlang.org](https://kotlinlang.org/api/latest/jvm/stdlib/)
414*1b2d298cSOwner Cleanup Bot
415*1b2d298cSOwner Cleanup BotEach source root has a list of platforms for which members are suitable.
416*1b2d298cSOwner Cleanup BotAlso, the list of 'implied' platforms is passed to Dokka.
417*1b2d298cSOwner Cleanup BotIf a member is not available for all platforms in the implied platforms set, its documentation will show
418*1b2d298cSOwner Cleanup Botthe list of platforms for which it's available.
419*1b2d298cSOwner Cleanup Bot
420*1b2d298cSOwner Cleanup Bot## Dokka Internals
421*1b2d298cSOwner Cleanup Bot
422*1b2d298cSOwner Cleanup Bot### Documentation Model
423*1b2d298cSOwner Cleanup Bot
424*1b2d298cSOwner Cleanup BotDokka uses Kotlin-as-a-service technology to build `code model`, then processes it into `documentation model`.
425*1b2d298cSOwner Cleanup Bot`Documentation model` is graph of items describing code elements such as classes, packages, functions, etc.
426*1b2d298cSOwner Cleanup Bot
427*1b2d298cSOwner Cleanup BotEach node has semantic attached, e.g. Value:name -> Type:String means that some value `name` is of type `String`.
428*1b2d298cSOwner Cleanup Bot
429*1b2d298cSOwner Cleanup BotEach reference between nodes also has semantic attached, and there are three of them:
430*1b2d298cSOwner Cleanup Bot
431*1b2d298cSOwner Cleanup Bot1. Member - reference means that target is member of the source, form tree.
432*1b2d298cSOwner Cleanup Bot2. Detail - reference means that target describes source in more details, form tree.
433*1b2d298cSOwner Cleanup Bot3. Link - any link to any other node, free form.
434*1b2d298cSOwner Cleanup Bot
435*1b2d298cSOwner Cleanup BotMember & Detail has reverse Owner reference, while Link's back reference is also Link.
436*1b2d298cSOwner Cleanup Bot
437*1b2d298cSOwner Cleanup BotNodes that are Details of other nodes cannot have Members.
438*1b2d298cSOwner Cleanup Bot
439*1b2d298cSOwner Cleanup Bot### Rendering Docs
440*1b2d298cSOwner Cleanup Bot
441*1b2d298cSOwner Cleanup BotWhen we have documentation model, we can render docs in various formats, languages and layouts. We have some core services:
442*1b2d298cSOwner Cleanup Bot
443*1b2d298cSOwner Cleanup Bot* FormatService -- represents output format
444*1b2d298cSOwner Cleanup Bot* LocationService -- represents folder and file layout
445*1b2d298cSOwner Cleanup Bot* SignatureGenerator -- represents target language by generating class/function/package signatures from model
446*1b2d298cSOwner Cleanup Bot
447*1b2d298cSOwner Cleanup BotBasically, given the `documentation` as a model, we do this:
448*1b2d298cSOwner Cleanup Bot
449*1b2d298cSOwner Cleanup Bot```kotlin
450*1b2d298cSOwner Cleanup Bot    val signatureGenerator = KotlinSignatureGenerator()
451*1b2d298cSOwner Cleanup Bot    val locationService = FoldersLocationService(arguments.outputDir)
452*1b2d298cSOwner Cleanup Bot    val markdown = JekyllFormatService(locationService, signatureGenerator)
453*1b2d298cSOwner Cleanup Bot    val generator = FileGenerator(signatureGenerator, locationService, markdown)
454*1b2d298cSOwner Cleanup Bot    generator.generate(documentation)
455*1b2d298cSOwner Cleanup Bot```
456*1b2d298cSOwner Cleanup Bot
457*1b2d298cSOwner Cleanup Bot## Building Dokka
458*1b2d298cSOwner Cleanup Bot
459*1b2d298cSOwner Cleanup BotDokka is built with Gradle. To build it, use `./gradlew build`.
460*1b2d298cSOwner Cleanup BotAlternatively, open the project directory in IntelliJ IDEA and use the IDE to build and run Dokka.
461*1b2d298cSOwner Cleanup Bot
462*1b2d298cSOwner Cleanup BotHere's how to import and configure Dokka in IntelliJ IDEA:
463*1b2d298cSOwner Cleanup Bot
464*1b2d298cSOwner Cleanup Bot* Select "Open" from the IDEA welcome screen, or File > Open if a project is
465*1b2d298cSOwner Cleanup Bot  already open
466*1b2d298cSOwner Cleanup Bot* Select the directory with your clone of Dokka
467*1b2d298cSOwner Cleanup Bot  * Note: IDEA may have an error after the project is initally opened; it is OK
468*1b2d298cSOwner Cleanup Bot    to ignore this as the next step will address this error
469*1b2d298cSOwner Cleanup Bot* After IDEA opens the project, select File > New > Module from existing sources
470*1b2d298cSOwner Cleanup Bot  and select the `build.gradle` file from the root directory of your Dokka clone
471*1b2d298cSOwner Cleanup Bot* Use the default options and select "OK"
472*1b2d298cSOwner Cleanup Bot* After Dokka is loaded into IDEA, open the Gradle tool window (View > Tool
473*1b2d298cSOwner Cleanup Bot  Windows > Gradle) and click on the top left "Refresh all Gradle projects"
474*1b2d298cSOwner Cleanup Bot  button
475*1b2d298cSOwner Cleanup Bot* Verify the following project settings.  In File > Settings > Build, Execution,
476*1b2d298cSOwner Cleanup Bot  Deployment > Build Tools > Gradle > Runner:
477*1b2d298cSOwner Cleanup Bot  * Ensure "Delegate IDE build/run actions to gradle" is checked
478*1b2d298cSOwner Cleanup Bot  * "Gradle Test Runner" should be selected in the "Run tests using" drop-down
479*1b2d298cSOwner Cleanup Bot    menu
480*1b2d298cSOwner Cleanup Bot* Note: After closing and re-opening the project, IDEA may give an error
481*1b2d298cSOwner Cleanup Bot  message: "Error Loading Project: Cannot load 3 modules".  Open up the details
482*1b2d298cSOwner Cleanup Bot  of the error, and click "Remove Selected", as these module `.iml` files are
483*1b2d298cSOwner Cleanup Bot  safe to remove.
484