aboutsummaryrefslogtreecommitdiff
path: root/mkdocs/src/doc/docs/user_guide/applying/maven.md
blob: 3ea6a56f11f859b6765207a7b697c7fe38f07ac5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# Using the Maven plugin

!!! note
    Dokka Maven plugin does not support multi-platform projects.

Minimal Maven configuration is

```xml
<plugin>
    <groupId>org.jetbrains.dokka</groupId>
    <artifactId>dokka-maven-plugin</artifactId>
    <version>${dokka.version}</version>
    <executions>
        <execution>
            <phase>pre-site</phase>
            <goals>
                <goal>dokka</goal>
            </goals>
        </execution>
    </executions>
</plugin>
```

By default files will be generated in `target/dokka`.

The following goals are provided by the plugin:

* `dokka:dokka` - generate HTML documentation in Dokka format (showing declarations in Kotlin syntax)
* `dokka:javadoc` - generate HTML documentation in Javadoc format (showing declarations in Java syntax)
* `dokka:javadocJar` - generate a .jar file with Javadoc format documentation

## Configuration options

The available configuration options are shown below:

```xml
<plugin>
    <groupId>org.jetbrains.dokka</groupId>
    <artifactId>dokka-maven-plugin</artifactId>
    <version>${dokka.version}</version>
    <executions>
        <execution>
            <phase>pre-site</phase>
            <goals>
                <goal>dokka</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
    
        <!-- Set to true to skip dokka task, default: false -->
        <skip>false</skip>
    
        <!-- Default: ${project.artifactId} -->
        <moduleName>data</moduleName>

        <!-- Default: ${project.basedir}/target/dokka -->
        <outputDir>some/out/dir</outputDir>
        
        <!-- 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 -->
        <cacheRoot>default</cacheRoot>

        <!-- Set to true to to prevent resolving package-lists online. -->
        <!-- When this option is set to true, only local files are resolved, default: false -->
        <offlineMode>false</offlineMode>

        <!-- List of '.md' files with package and module docs -->
        <!-- https://kotlinlang.org/docs/reference/dokka-module-and-package-docs.html -->
        <includes>
            <include>packages.md</include>
            <include>extra.md</include>
        </includes>

        <!-- A list of visibility modifiers that should be documented -->
        <!-- If set by user, overrides includeNonPublic. Default is PUBLIC -->
        <documentedVisibilities>
            <visibility>PUBLIC</visibility> <!-- Same for both kotlin and java -->
            <visibility>PRIVATE</visibility> <!-- Same for both kotlin and java -->
            <visibility>PROTECTED</visibility> <!-- Same for both kotlin and java -->
            <visibility>INTERNAL</visibility> <!-- Kotlin-specific internal modifier -->
            <visibility>PACKAGE</visibility> <!-- Java-specific package-private visibility (default) -->
        </documentedVisibilities>
        
        <!-- List of sample roots -->
        <samples>
            <dir>src/test/samples</dir>
        </samples>

        <!-- Suppress obvious functions like default toString or equals. Defaults to true -->
        <suppressObviousFunctions>false</suppressObviousFunctions>

        <!-- Suppress all inherited members that were not overriden in a given class. -->
        <!-- Eg. using it you can suppress toString or equals functions but you can't suppress componentN or copy on data class. To do that use with suppressObviousFunctions -->
        <!-- Defaults to false -->
        <suppressInheritedMembers>true</suppressInheritedMembers>

        <!-- Used for linking to JDK, default: 6 -->
        <jdkVersion>6</jdkVersion>

        <!-- Do not output deprecated members, applies globally, can be overridden by packageOptions -->
        <skipDeprecated>false</skipDeprecated> 
        <!-- Emit warnings about not documented members, applies globally, also can be overridden by packageOptions -->
        <reportUndocumented>true</reportUndocumented>             
        <!-- Do not create index pages for empty packages -->
        <skipEmptyPackages>true</skipEmptyPackages> 
        
        <!-- Short form list of sourceRoots, by default, set to ${project.compileSourceRoots} -->
        <sourceDirectories>
            <dir>src/main/kotlin</dir>
        </sourceDirectories>
        
        <!-- Full form list of sourceRoots -->
        <sourceRoots>
            <root>
                <path>src/main/kotlin</path>
                <!-- See platforms section of documentation -->
                <platforms>JVM</platforms>
            </root>
        </sourceRoots>
        
        <!-- Specifies the location of the project source code on the Web. If provided, Dokka generates "source" links
             for each declaration. -->
        <sourceLinks>
            <link>
                <!-- Source directory -->
                <path>${project.basedir}/src/main/kotlin</path>
                <!-- URL showing where the source code can be accessed through the web browser -->
                <url>https://github.com/cy6erGn0m/vertx3-lang-kotlin/blob/master/src/main/kotlin</url> <!-- //remove src/main/kotlin if you use "./" above -->
                <!--Suffix which is used to append the line number to the URL. Use #L for GitHub -->
                <lineSuffix>#L</lineSuffix>
            </link>
        </sourceLinks>
        
        <!-- Disable linking to online kotlin-stdlib documentation  -->
        <noStdlibLink>false</noStdlibLink>
        
        <!-- Disable linking to online JDK documentation -->
        <noJdkLink>false</noJdkLink>
        
        <!-- Allows linking to documentation of the project's dependencies (generated with Javadoc or Dokka) -->
        <externalDocumentationLinks>
            <link>
                <!-- Root URL of the generated documentation to link with. The trailing slash is required! -->
                <url>https://example.com/docs/</url>
                <!-- If package-list file located in non-standard location -->
                <!-- <packageListUrl>file:///home/user/localdocs/package-list</packageListUrl> -->
            </link>
        </externalDocumentationLinks>

        <!-- Allows to customize documentation generation options on a per-package basis -->
        <perPackageOptions>
            <packageOptions>
                <!-- Will match kotlin and all sub-packages of it -->
                <matchingRegex>kotlin($|\.).*</matchingRegex>
                
                <!-- All options are optional, default values are below: -->
                <skipDeprecated>false</skipDeprecated>
                
                <!-- Emit warnings about not documented members  -->
                <reportUndocumented>true</reportUndocumented>
                
                <!-- Deprecated. Prefer using documentedVisibilities -->
                <includeNonPublic>false</includeNonPublic>

                <!-- A list of visibility modifiers that should be documented -->
                <!-- If set by user, overrides includeNonPublic. Default is PUBLIC -->
                <documentedVisibilities>
                    <visibility>PUBLIC</visibility> <!-- Same for both kotlin and java -->
                    <visibility>PRIVATE</visibility> <!-- Same for both kotlin and java -->
                    <visibility>PROTECTED</visibility> <!-- Same for both kotlin and java -->
                    <visibility>INTERNAL</visibility> <!-- Kotlin-specific internal modifier -->
                    <visibility>PACKAGE</visibility> <!-- Java-specific package-private visibility (default) -->
                </documentedVisibilities>
            </packageOptions>
        </perPackageOptions>
        
        <!-- Allows to use any dokka plugin, eg. GFM format   -->
        <dokkaPlugins>
            <plugin>
                <groupId>org.jetbrains.dokka</groupId>
                <artifactId>gfm-plugin</artifactId>
                <version>${dokka.version}</version>
            </plugin>
        </dokkaPlugins>
        
        <!-- Configures a plugin separately -->
        <pluginsConfiguration>
            <fullyQualifiedPluginName>
                <!-- Configuration -->
            </fullyQualifiedPluginName>
        </pluginsConfiguration>

    </configuration>
</plugin>
```

## Applying plugins
You can add plugins inside the `dokkaPlugins` block:

```xml
<plugin>
    <groupId>org.jetbrains.dokka</groupId>
    <artifactId>dokka-maven-plugin</artifactId>
    <version>${dokka.version}</version>
    <executions>
        <execution>
            <phase>pre-site</phase>
            <goals>
                <goal>dokka</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <dokkaPlugins>
            <plugin>
                <groupId>org.jetbrains.dokka</groupId>
                <artifactId>kotlin-as-java-plugin</artifactId>
                <version>${dokka.version}</version>
            </plugin>
        </dokkaPlugins>
    </configuration>
</plugin>
```

Some plugins can be configured separately using plugin's fully qualified name. For example:

```xml
<pluginsConfiguration>
    <org.jetbrains.dokka.base.DokkaBase>
        <customStyleSheets>
            <customStyleSheet><!-- path to custom stylesheet --></customStyleSheet>
        </customStyleSheets>
        <customAssets>
            <customAsset><!-- path to custom asset --></customAsset>
        </customAssets>
    </org.jetbrains.dokka.base.DokkaBase>
</pluginsConfiguration>
```

## Example project

Please see the [Dokka Maven example project](https://github.com/Kotlin/dokka/tree/master/examples/maven) for an example.